aboutsummaryrefslogtreecommitdiffstats
path: root/debian/tests
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-06-15 20:29:06 +0200
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-06-15 20:37:12 +0200
commit199e427d5dea3051eec1726eb9c857aa3d5fdde2 (patch)
tree5477b3bd4868676a210bbd3ef67a469d34814e61 /debian/tests
parentb5cdd645c9fc62341d55aebbfc93a1b648415512 (diff)
Merge Ubuntu DPDK packaging as of 15th June 2016
As discussed this shall be our initial baseline. If history is needed for any sort of debugging or analysis it can be found at https://code.launchpad.net/~ubuntu-server/dpdk/+git/dpdk Change-Id: Ie95c7effbbea34d723df14f6451c1f782000cbc1 Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Diffstat (limited to 'debian/tests')
-rw-r--r--debian/tests/check-dpdk-supported-arch.sh12
-rw-r--r--debian/tests/control13
-rw-r--r--debian/tests/test-dkms18
-rw-r--r--debian/tests/test-initscripts143
-rw-r--r--debian/tests/test-linkage51
5 files changed, 237 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..3de6e467
--- /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)
+ 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..5afed744
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,13 @@
+Tests: test-initscripts
+Restrictions: allow-stderr, isolation-machine, needs-root
+Depends: dpdk [amd64 arm64 i386], gawk, mount, systemd, sysvinit-utils
+
+Tests: test-linkage
+Restrictions: allow-stderr
+Depends: libdpdk-dev [amd64 arm64 i386], 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],
+ dpdk-rte-kni-dkms [amd64 arm64 i386]
diff --git a/debian/tests/test-dkms b/debian/tests/test-dkms
new file mode 100644
index 00000000..ab3aca00
--- /dev/null
+++ b/debian/tests/test-dkms
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -eu
+
+basedir=$(dirname "$0")
+. "${basedir}"/check-dpdk-supported-arch.sh
+
+# 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..f465d6d6
--- /dev/null
+++ b/debian/tests/test-initscripts
@@ -0,0 +1,143 @@
+#!/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
+
+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-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}"
+ # We do not check 1G 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
+ systemctl reset-failed dpdk.service
+
+ 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" 2 "${PRE}" "${POST}" "active"
+ echo "### Restarting Service ###"
+ ${PRE} restart "${POST}"
+ checkstatus "${TYPE}-RESTART" 2 "${PRE}" "${POST}" "active"
+}
+
+echo "NR_2M_PAGES=$EXPECT2MHP" >> ${DPDK_CONF}
+echo "NR_1G_PAGES=$EXPECT1GHP" >> ${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..fabe1c84
--- /dev/null
+++ b/debian/tests/test-linkage
@@ -0,0 +1,51 @@
+#!/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'
+lddtree testlinkage.bin | grep '^ librt.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
+ldd /usr/lib/*/librte_pmd_xenvirt.so | grep libxenstore
+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"