Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Apr 2019 16:28:06 +0000 (UTC)
From:      Enji Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r346451 - user/ngie/bug-237403/tests/sys/opencrypto
Message-ID:  <201904201628.x3KGS6Yv062455@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sat Apr 20 16:28:06 2019
New Revision: 346451
URL: https://svnweb.freebsd.org/changeset/base/346451

Log:
  Fix up `kern.cryptodevallowsoft` handling
  
  - Always ensure `kern.cryptodevallowsoft` is unset when completing the tests,
    otherwise `/dev/crypto` access could remain on after the tests are complete
    if interrupted.
  - Check for errors when setting `kern.cryptodevallowsoft`. While this isn't
    strictly needed in positive cases, it helps when dealing with the myriad of
    problems that might ensue because `/dev/crypto` doesn't exist when the sysctl
    isn't enabled.

Modified:
  user/ngie/bug-237403/tests/sys/opencrypto/runtests.sh

Modified: user/ngie/bug-237403/tests/sys/opencrypto/runtests.sh
==============================================================================
--- user/ngie/bug-237403/tests/sys/opencrypto/runtests.sh	Sat Apr 20 16:20:57 2019	(r346450)
+++ user/ngie/bug-237403/tests/sys/opencrypto/runtests.sh	Sat Apr 20 16:28:06 2019	(r346451)
@@ -48,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
@@ -66,9 +70,15 @@ for required_module in nexus/aesni cryptodev; do
 	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
 
 echo "1..1"
 if "$PYTHON" $(dirname $0)/cryptotest.py; then
@@ -76,5 +86,3 @@ if "$PYTHON" $(dirname $0)/cryptotest.py; then
 else
 	echo "not ok 1"
 fi
-
-sysctl "$oldcdas"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904201628.x3KGS6Yv062455>