]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
testcrypto.sh: run in TMPDIR if possible
authorTom Krizek <tkrizek@isc.org>
Mon, 19 Dec 2022 16:44:35 +0000 (17:44 +0100)
committerMichal Nowak <mnowak@isc.org>
Thu, 23 Mar 2023 16:17:59 +0000 (17:17 +0100)
Avoid creating any temporary files in the current workdir.

Additional/changing files in the bin/tests/system directory are
problematic for pytest/xdist collection phase, which assumes the list of
files doesn't change between the collection phase of the main pytest
thread and the subsequent collection phase of the xdist worker threads.

Since the testcrypto.sh is also called during pytest initialization
through conf.sh.common (to detect feature support), this could
occasionally cause a race condition when the list of files would be
different for the main pytest thread and the xdist worker.

(cherry picked from commit 61330a7863c0dfe65f3add97bd363ec4998066aa)

bin/tests/system/get_algorithms.py
bin/tests/system/testcrypto.sh

index 3bef92d5d5c9458cebd249dba4306f8c9822b5df..529487a8aca45af250d58ca7ad7633992998e8c3 100755 (executable)
@@ -111,7 +111,10 @@ def is_supported(alg: Algorithm) -> bool:
             f"{TESTCRYPTO} -q {alg.name}",
             shell=True,
             check=True,
-            env={"KEYGEN": KEYGEN},
+            env={
+                "KEYGEN": KEYGEN,
+                "TMPDIR": os.getenv("TMPDIR", "/tmp"),
+            },
             stdout=subprocess.DEVNULL,
         )
     except subprocess.CalledProcessError as exc:
index dd1d583527dd39162ff6dd6f24188a56bd11c519..020aa9ab72e267246faf6edc96f12d146f8a46cf 100755 (executable)
@@ -15,6 +15,7 @@ SYSTEMTESTTOP=${SYSTEMTESTTOP:=..}
 prog=$0
 args=""
 quiet=0
+dir=""
 msg="cryptography"
 
 if test -z "$KEYGEN"; then
@@ -75,9 +76,18 @@ if test -z "$alg"; then
     exit 1
 fi
 
+if test -n "$TMPDIR"; then
+    dir=$(mktemp -d "$TMPDIR/XXXXXX")
+    args="$args -K $dir"
+fi
+
 if $KEYGEN $args $alg foo > /dev/null 2>&1
 then
-    rm -f Kfoo*
+    if test -z "$dir"; then
+        rm -f Kfoo*
+    else
+        rm -rf "$dir"
+    fi
 else
     if test $quiet -eq 0; then
         echo_i "This test requires support for $msg" >&2