From 1208ea108253d0a0f22c0b93180177c991fc48c9 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Sat, 9 Mar 2024 10:39:17 +0000 Subject: [PATCH] test: Fix generate_cert cache age logic The generate_cert cache has a bug because it uses the directory's age, which won't necessarily change, and it was always re-generating certificates after 10m. This patch fixes the bug by checking the age of the private key file instead of the directory. --- test/util/lib.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/util/lib.sh b/test/util/lib.sh index 5ed52bc..c373dd4 100644 --- a/test/util/lib.sh +++ b/test/util/lib.sh @@ -195,11 +195,10 @@ function generate_certs_for() { # Generating certs is takes time and slows the tests down, so we keep # a little cache that is common to all tests. CACHEDIR="${TBASE}/../.generate_certs_cache" - mkdir -p "${CACHEDIR}" + mkdir -p "${CACHEDIR}/$1/" touch -d "10 minutes ago" "${CACHEDIR}/.reference" - if [ "${CACHEDIR}/$1/" -ot "${CACHEDIR}/.reference" ]; then + if [ "${CACHEDIR}/$1/privkey.pem" -ot "${CACHEDIR}/.reference" ]; then # Cache miss (either was not there, or was too old). - mkdir -p "${CACHEDIR}/$1/" ( cd "${CACHEDIR}/$1/" || exit 1 generate_cert -ca -validfor=1h -host="$1"