aboutsummaryrefslogtreecommitdiffstats
path: root/debian/tests
diff options
context:
space:
mode:
Diffstat (limited to 'debian/tests')
-rw-r--r--debian/tests/check-dpdk-supported-arch.sh12
-rw-r--r--debian/tests/control17
-rw-r--r--debian/tests/test-autotest62
-rw-r--r--debian/tests/test-dkms22
-rw-r--r--debian/tests/test-initscripts149
-rw-r--r--debian/tests/test-linkage49
6 files changed, 311 insertions, 0 deletions
diff --git a/debian/tests/check-dpdk-supported-arch.sh b/debian/tests/check-dpdk-supported-arch.sh
new file mode 100644
index 00000000..1105dc2e
--- /dev/null
+++ b/debian/tests/check-dpdk-supported-arch.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+arch=$(dpkg --print-architecture)
+case $arch in
+ amd64|arm64|i386|ppc64el)
+ echo "Architecture ${arch} supported, go on with test"
+ ;;
+ *)
+ echo "Architecture ${arch} not supported, SKIP test"
+ exit 0
+ ;;
+esac
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 00000000..7d624212
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,17 @@
+Tests: test-initscripts
+Restrictions: allow-stderr, isolation-machine, needs-root
+Depends: dpdk [amd64 arm64 i386 ppc64el], gawk, mount, systemd, sysvinit-utils
+
+Tests: test-linkage
+Restrictions: allow-stderr
+Depends: libdpdk-dev [amd64 arm64 i386 ppc64el], libc6, libc6-dev, gcc,
+ grep, libpcap-dev, libxenstore3.0 [amd64 arm64 i386], pax-utils
+
+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
index 00000000..0ab308fd
--- /dev/null
+++ b/debian/tests/test-autotest
@@ -0,0 +1,62 @@
+#!/bin/bash
+set -u
+
+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" \
+
+# Pass/Fail
+# For now the autotest is too unreliable, so we run it to get some logs in
+# different environments, but never (want to) fail until it is stable.
+
+echo "OK"
diff --git a/debian/tests/test-dkms b/debian/tests/test-dkms
new file mode 100644
index 00000000..5db36af9
--- /dev/null
+++ b/debian/tests/test-dkms
@@ -0,0 +1,22 @@
+#!/bin/bash
+set -eu
+
+basedir=$(dirname "$0")
+. "${basedir}"/check-dpdk-supported-arch.sh
+
+if [ -d /var/lib/dkms ]; then
+ (cd /var/lib/dkms; find -name "make.log" -print0 | xargs -0 tar c) > "$ADT_ARTIFACTS/dkms-make-logs.tar"
+fi
+
+# check that the dkms build fine (on dep install), load and unload
+printf "\n\nChecking igb_uio\n"
+modinfo igb_uio
+modprobe igb_uio
+rmmod igb_uio
+echo "OK"
+
+printf "\n\nChecking igb_uio\n"
+modinfo rte_kni
+modprobe rte_kni
+rmmod rte_kni
+echo "OK"
diff --git a/debian/tests/test-initscripts b/debian/tests/test-initscripts
new file mode 100644
index 00000000..1643a2ea
--- /dev/null
+++ b/debian/tests/test-initscripts
@@ -0,0 +1,149 @@
+#!/bin/sh
+set -e
+
+basedir=$(dirname "$0")
+. "${basedir}"/check-dpdk-supported-arch.sh
+
+# Overall that could require up to 1.2G for hugepages in the test environment
+EXPECT2MHP=10
+# Some page sizes like e.g. 1G might not be available in all test environments
+# The test still configures 1 page of 1G size.
+# One of two things will happen, depending on the test environment:
+# - has 1G huge page size => they will tried to be allocated (usually env is
+# too small, but we want to see it fail gracefully for that)
+# We will not check for the 1G alloc, as we know it often fails in small adt's
+# - has no 1G huge page size (HW feature) => we check if it fails gracefully
+EXPECT1GHP=1
+EXPECT16MHP=2
+
+DPDK_CONF="/etc/dpdk/dpdk.conf"
+DPDK_INTERF="/etc/dpdk/interfaces"
+
+checkhp() {
+ MMDIR="/sys/kernel/mm/hugepages/${1}"
+ EXPECTHP="${2}"
+ if [ -d "$MMDIR" -a -r "$MMDIR/nr_hugepages" ]; then
+ hpcount=$(cat "$MMDIR/nr_hugepages")
+ if [ "${hpcount}" -ne "${EXPECTHP}" ]; then
+ echo "Hugepages (${hpcount}) not as expected (${EXPECTHP})"
+ exit 1
+ else
+ echo "Hugepages ok (${hpcount})"
+ fi
+ fi
+}
+
+checkstatus() {
+ MARK=${1}
+ EXPMPCOUNT=${2}
+ PRE=${3}
+ POST=${4}
+ EXPECTEDSTATUS=${5}
+ echo "Status after ${MARK}"
+ echo "Status of the Service"
+ ${PRE} status "${POST}" || true
+
+ GOTSTATUS=$(${PRE} status "${POST}" | awk '/^ *Active: / { print $2 }')
+ if [ "${GOTSTATUS}" != "${EXPECTEDSTATUS}" ]; then
+ echo "Service status (${GOTSTATUS}) not as expected (${EXPECTEDSTATUS})"
+ exit 1
+ else
+ echo "Service status (${GOTSTATUS}) as expected"
+ fi
+
+ echo "Status of hugetlbfs mount points"
+ # this section is ok to create bad RCs when no mounts are available
+ set +e
+ grep hugetlbfs < /proc/mounts
+ htlbfscount=$(grep -c hugetlbfs < /proc/mounts)
+ set -e
+
+ # we have to reduce the expected mountpoint count in case some sizes are
+ # not supported by the current kernel/environment
+ if [ ${EXPMPCOUNT} -gt 0 ]; then
+ if [ ! -d /sys/kernel/mm/hugepages/hugepages-2048kB ]; then
+ EXPMPCOUNT=$((EXPMPCOUNT-1))
+ fi
+ if [ ! -d /sys/kernel/mm/hugepages/hugepages-16384kB ]; then
+ EXPMPCOUNT=$((EXPMPCOUNT-1))
+ fi
+ if [ ! -d /sys/kernel/mm/hugepages/hugepages-1048576kB ]; then
+ EXPMPCOUNT=$((EXPMPCOUNT-1))
+ fi
+ fi
+
+ if [ "${htlbfscount}" -eq "${EXPMPCOUNT}" ]; then
+ echo "MP Count (${htlbfscount}) as expected (${EXPMPCOUNT})"
+ else
+ echo "MP Count (${htlbfscount}) not as expected (${EXPMPCOUNT})"
+ exit 1
+ fi
+
+ # check if setting HP worked
+ if [ "${EXPMPCOUNT}" -ne "0" ]; then
+ checkhp "hugepages-2048kB" "${EXPECT2MHP}"
+ checkhp "hugepages-16384kB" "${EXPECT16MHP}"
+ # We do not check 1G/16M alloc, as it is known to be often not available
+ fi
+}
+
+resetservice() {
+ # help a bit with memory fragmentation regarding huge page allocation
+ sync
+ echo 3 > /proc/sys/vm/drop_caches
+
+ # stopping and resetting Service
+ systemctl stop dpdk.service || /bin/true
+ systemctl reset-failed dpdk.service || /bin/true
+
+ echo "Unmounting all potential hugetlbfs mounts"
+ awk '/hugetlbfs/ {print $2}' /proc/mounts | while read hugetlbmount; do
+ umount -v "$hugetlbmount"
+ done
+}
+
+checkinitstyle() {
+ # We want to verify that
+ # - initially our environment has no hugetlbfs mount
+ # - a system without hugetlbfs mount gets it mounted
+ # - a restart of the service does neither drop nor duplicate the mount
+ PRE=${1}
+ POST=${2}
+ TYPE=${3}
+ printf "\n\n### Checking Type %s ###\n" "${TYPE}"
+ resetservice
+ checkstatus "${TYPE}-BEGIN" 0 "${PRE}" "${POST}" "inactive"
+ echo "### Starting Service ###"
+ ${PRE} start "${POST}"
+ checkstatus "${TYPE}-START" 3 "${PRE}" "${POST}" "active"
+ echo "### Restarting Service ###"
+ ${PRE} restart "${POST}"
+ checkstatus "${TYPE}-RESTART" 3 "${PRE}" "${POST}" "active"
+}
+
+echo "NR_2M_PAGES=$EXPECT2MHP" >> ${DPDK_CONF}
+echo "NR_1G_PAGES=$EXPECT1GHP" >> ${DPDK_CONF}
+echo "NR_16M_PAGES=$EXPECT16MHP" >> ${DPDK_CONF}
+
+# We can't rely on any real device for DPDK tests in adt-* environments. But
+# we can expect all kind of broken configuration not to break it (would be
+# detected via set -e).
+# So add all kind of known-to-be-broken definitions and expect it not to fail.
+cat <<EOF > ${DPDK_INTERF}
+# wrong bus
+pTi 0000:04:00.0 uio-pci-generic
+# not enough parms
+0000:04:00.0 uio-pci-generic
+# empty line
+
+# non existing device
+pci 1234:56:78.9 uio-pci-generic
+EOF
+
+# some had issues in the past caused by different init systems, so we test all
+# Direct Calls
+checkinitstyle "/etc/init.d/dpdk" "" "Direct"
+# System V style init
+checkinitstyle "service dpdk" "" "SysV"
+# SystemD style init
+checkinitstyle "systemctl" "dpdk.service" "SystemD"
diff --git a/debian/tests/test-linkage b/debian/tests/test-linkage
new file mode 100644
index 00000000..31e409eb
--- /dev/null
+++ b/debian/tests/test-linkage
@@ -0,0 +1,49 @@
+#!/bin/bash
+set -eu
+
+basedir=$(dirname "$0")
+. "${basedir}"/check-dpdk-supported-arch.sh
+
+cat > testlinkage.c << EOF
+#include <stdio.h>
+#include "dpdk/rte_common.h"
+
+int main()
+{
+ printf("Hello rte_exit %p\n", rte_exit);
+ return 0;
+}
+EOF
+
+# -ldpdk actually refers to a linker script now, not a real .so
+# with broken linkage this will fail with undefined symbols
+printf "\n\nChecking compile with link against DPDK\n"
+gcc -v testlinkage.c -o testlinkage.bin -Wall -Werror -ldpdk
+echo "OK"
+
+printf "\n\nLinkage info\n"
+lddtree testlinkage.bin
+
+printf "\n\nChecking for expected internal libraries\n"
+# a few of the sublibs that it should use
+lddtree testlinkage.bin | grep '^ librte_eal.so'
+echo "OK"
+
+printf "\n\nChecking for expected secondary library dependencies\n"
+lddtree testlinkage.bin | grep '^ libpthread.so'
+echo "OK"
+
+printf "\n\nChecking for expected feature dependent library dependencies\n"
+# features only used by the lib that we enabled
+ldd /usr/lib/*/librte_pmd_pcap.so | grep libpcap
+echo "OK"
+
+printf "\n\nChecking test execution\n"
+# It doesn't do much, but it should work - so calling it is a minor extra test.
+# It is known to fail without SSE3 in e.g. some adt environments, in that
+# case check at least that we get the correct error message (this will trigger
+# a test fail if it neither finds the success nor the expected error message)
+(./testlinkage.bin 2>&1 || /bin/true ) | \
+grep -E 'ERROR: This system does not support "SSSE3".|Hello rte_exit 0x'
+
+echo "OK"