svn commit: r347417 - in head: . tests/sys/opencrypto

Enji Cooper ngie at FreeBSD.org
Fri May 10 00:03:34 UTC 2019


Author: ngie
Date: Fri May 10 00:03:32 2019
New Revision: 347417
URL: https://svnweb.freebsd.org/changeset/base/347417

Log:
  Refactor tests/sys/opencrypto/runtests
  
  * Convert from plain to TAP for slightly improved introspection when skipping
    the tests due to requirements not being met.
  * Test for the net/py-dpkt (origin) package being required when running the
    tests, instead of relying on a copy of the dpkt.py module from 2014. This
    enables the tests to work with py3. Subsequently, remove
    `tests/sys/opencrypto/dpkt.py(c)?` via `make delete-old`.
  * Parameterize out `python2` as `$PYTHON`.
  
  PR:		237403
  MFC after:	1 week

Deleted:
  head/tests/sys/opencrypto/dpkt.py
Modified:
  head/ObsoleteFiles.inc
  head/tests/sys/opencrypto/Makefile
  head/tests/sys/opencrypto/runtests.sh

Modified: head/ObsoleteFiles.inc
==============================================================================
--- head/ObsoleteFiles.inc	Thu May  9 23:57:02 2019	(r347416)
+++ head/ObsoleteFiles.inc	Fri May 10 00:03:32 2019	(r347417)
@@ -38,6 +38,9 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20190509: tests/sys/opencrypto requires the net/py-dpkt package.
+OLD_FILES+=usr/tests/sys/opencrypto/dpkt.py
+OLD_FILES+=usr/tests/sys/opencrypto/dpkt.pyc
 # 20190304: new libc++ import which bumps version from 7.0.1 to 8.0.0.
 OLD_FILES+=usr/include/c++/v1/experimental/dynarray
 # 20190304: new clang import which bumps version from 7.0.1 to 8.0.0.

Modified: head/tests/sys/opencrypto/Makefile
==============================================================================
--- head/tests/sys/opencrypto/Makefile	Thu May  9 23:57:02 2019	(r347416)
+++ head/tests/sys/opencrypto/Makefile	Fri May 10 00:03:32 2019	(r347417)
@@ -12,12 +12,12 @@ CFLAGS.poly1305_test.c	+= -I${SRCTOP}/sys/opencrypto
 
 ATF_TESTS_C+=	blake2_test poly1305_test
 
-PLAIN_TESTS_SH=	runtests
+TAP_TESTS_SH+=	runtests
 
 TEST_METADATA.runtests+= required_programs="python2"
 TEST_METADATA.runtests+= required_user="root"
 
-PYMODULES=	cryptodev.py cryptodevh.py cryptotest.py dpkt.py
+PYMODULES=	cryptodev.py cryptodevh.py cryptotest.py
 
 ${PACKAGE}FILES+=	${PYMODULES}
 

Modified: head/tests/sys/opencrypto/runtests.sh
==============================================================================
--- head/tests/sys/opencrypto/runtests.sh	Thu May  9 23:57:02 2019	(r347416)
+++ head/tests/sys/opencrypto/runtests.sh	Fri May 10 00:03:32 2019	(r347417)
@@ -29,13 +29,18 @@
 # $FreeBSD$
 #
 
-set -ex
+: ${PYTHON=python2}
 
 if [ ! -d /usr/local/share/nist-kat ]; then
-	echo 'Skipping, nist-kat package not installed for test vectors.'
+	echo "1..0 # SKIP: nist-kat package not installed for test vectors"
 	exit 0
 fi
 
+if ! $PYTHON -c "from dpkt import dpkt"; then
+	echo "1..0 # SKIP: py-dpkt package not installed"
+	exit 0
+fi
+
 loaded_modules=
 cleanup_tests()
 {
@@ -43,6 +48,10 @@ cleanup_tests()
 
 	set +e
 
+	if [ -n "$oldcdas" ]; then
+		sysctl "$oldcdas" 2>/dev/null
+	fi
+
 	# Unload modules in reverse order
 	for loaded_module in $(echo $loaded_modules | tr ' ' '\n' | sort -r); do
 		kldunload $loaded_module
@@ -52,15 +61,28 @@ trap cleanup_tests EXIT INT TERM
 
 for required_module in nexus/aesni cryptodev; do
 	if ! kldstat -q -m $required_module; then
-		kldload ${required_module#nexus/}
+		module_to_load=${required_module#nexus/}
+		if ! kldload ${module_to_load}; then
+			echo "1..0 # SKIP: could not load ${module_to_load}"
+			exit 0
+		fi
 		loaded_modules="$loaded_modules $required_module"
 	fi
 done
 
-# Run software crypto test
-oldcdas=$(sysctl -e kern.cryptodevallowsoft)
-sysctl kern.cryptodevallowsoft=1
+cdas_sysctl=kern.cryptodevallowsoft
+if ! oldcdas=$(sysctl -e $cdas_sysctl); then
+	echo "1..0 # SKIP: could not resolve sysctl: $cdas_sysctl"
+	exit 0
+fi
+if ! sysctl $cdas_sysctl=1; then
+	echo "1..0 # SKIP: could not enable /dev/crypto access via $cdas_sysctl sysctl."
+	exit 0
+fi
 
-python2 $(dirname $0)/cryptotest.py
-
-sysctl "$oldcdas"
+echo "1..1"
+if "$PYTHON" $(dirname $0)/cryptotest.py; then
+	echo "ok 1"
+else
+	echo "not ok 1"
+fi


More information about the svn-src-head mailing list