Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 61330a7

Browse files
committed
testcrypto.sh: run in TMPDIR if possible
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.
1 parent 6f0c821 commit 61330a7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

bin/tests/system/get_algorithms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ def is_supported(alg: Algorithm) -> bool:
111111
f"{TESTCRYPTO} -q {alg.name}",
112112
shell=True,
113113
check=True,
114-
env={"KEYGEN": KEYGEN},
114+
env={
115+
"KEYGEN": KEYGEN,
116+
"TMPDIR": os.getenv("TMPDIR", "/tmp"),
117+
},
115118
stdout=subprocess.DEVNULL,
116119
)
117120
except subprocess.CalledProcessError as exc:

bin/tests/system/testcrypto.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
prog=$0
1515
args=""
1616
quiet=0
17+
dir=""
1718
msg="cryptography"
1819

1920
if test -z "$KEYGEN"; then
@@ -74,9 +75,18 @@ if test -z "$alg"; then
7475
exit 1
7576
fi
7677

78+
if test -n "$TMPDIR"; then
79+
dir=$(mktemp -d "$TMPDIR/XXXXXX")
80+
args="$args -K $dir"
81+
fi
82+
7783
if $KEYGEN $args $alg foo > /dev/null 2>&1
7884
then
79-
rm -f Kfoo*
85+
if test -z "$dir"; then
86+
rm -f Kfoo*
87+
else
88+
rm -rf "$dir"
89+
fi
8090
else
8191
if test $quiet -eq 0; then
8292
echo_i "This test requires support for $msg" >&2

0 commit comments

Comments
 (0)