enable dpdk autotests as dep8 tests 71/3371/1
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>
Wed, 12 Oct 2016 11:22:18 +0000 (13:22 +0200)
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>
Wed, 12 Oct 2016 11:27:49 +0000 (13:27 +0200)
The autotests we bundle can be used on machines able to run DPDK.
But sadly almost none of them can run inside most common build
environments which makes it unavailable for a classic "dh_autotest".
But we can define certain characteristics of an dep8 test.
In there at least the majority of the tests runs fine.

So this adds the autotests as dep8 test.
To do so it defines the test as "isolation-machine, needs-root", but
even then checks further required capabilities like sse3 and the
required huge pages.
If prereqs are not met it exits by skipping the test, which counts as
PASS.

The tests can run successful e.g. with an autopkgtest call that adds the
required CPU characteristics. To do so run it like usual but with:
  autopkgtest [...] -- qemu --qemu-options='-cpu qemu64,+ssse3' [...]

So far only amd64 is supported and as mentioned before only if the
prereqs are met. But it is written in a way that this can be the groundwork
for any other architecture that wants to enable the autotests as well.

Change-Id: Ia2a2839ce349b3ea5c22f0b8a589f8a71378adc1
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
debian/tests/control
debian/tests/test-autotest [new file with mode: 0644]

index 4eb7103..7d62421 100644 (file)
@@ -11,3 +11,7 @@ Tests: test-dkms
 Restrictions: allow-stderr, isolation-machine, needs-root
 Depends: kmod, dpdk-igb-uio-dkms [amd64 arm64 i386 ppc64el],
  dpdk-rte-kni-dkms [amd64 arm64 i386 ppc64el]
+
+Tests: test-autotest
+Restrictions: allow-stderr, isolation-machine, needs-root
+Depends: dpdk-dev, python, python-pexpect
diff --git a/debian/tests/test-autotest b/debian/tests/test-autotest
new file mode 100644 (file)
index 0000000..b18ad2a
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/bash
+set -eu
+
+basedir=$(dirname "$0")
+. "${basedir}"/check-dpdk-supported-arch.sh
+
+# since these tests really execute dpdk code they have to check for the
+# required minimum cpu features
+ARCH=$(dpkg --print-architecture)
+echo "Check required features on arch: ${ARCH}"
+case "${ARCH}" in
+    amd64)
+        if ! grep -q '^flags.*sse3' /proc/cpuinfo; then
+            echo "Missing sse3 on ${ARCH} - not supported, SKIP test"
+            exit 0
+        fi
+        ;;
+    *)
+        echo "DPDK autotest not supported on ${ARCH}, SKIP test"
+        exit 0
+        ;;
+esac
+echo "no known missing feature on ${ARCH}, continue test"
+
+echo "Get required 1G huge pages"
+echo 512 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
+sleep 5s
+realhp=$(cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages)
+if [[ "$realhp" != "512" ]]; then
+    echo "Unable to allocate the huge pages required for the test, SKIP test"
+    exit 0
+fi
+
+# fetch build config
+. /usr/share/dpdk/dpdk-sdk-env.sh
+
+# Reasons for not being an dh_autotest
+# - needs root and hugepages
+# - build environment capabilities too unpredictable
+# - certain workarounds needed to get running, needing root for some which is
+#   not available in the build environment
+
+# blacklist reasons:
+# known upstream: http://www.dpdk.org/ml/archives/dev/2016-May/038849.html
+# - KNI: we deliver via dkms but test doesn't match
+# - power_acpi_cpufreq: in many environments blocked by other cpufreq
+# - power_kvm_vm_autotest: no avail in all environments, only for virt power management e.g. /dev/virtio-ports/virtio.serial.port.poweragent.0
+# - IVSHMEM fails in virtual environment
+# - eal_flags needs at least 8 cpus for lcores test not to fail
+# - pci doesn't initialize in all virt env causing command not found issues
+# - rather slow performance tests not suited for regular build associated tests: ring_perf,mempool_perf,memcpy_perf,hash_perf,timer_perf
+
+python "${RTE_SDK}/test/autotest.py" \
+    "${RTE_SDK}/test/test" \
+    "${RTE_TARGET}" \
+    "-KNI,power_acpi_cpufreq,power_kvm_vm,IVSHMEM,eal_flags,pci,ring_perf,mempool_perf,memcpy_perf,hash_perf,timer_perf" \
+
+echo "OK"