]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests/pkcs11-tool.sh: skip if neither p11tool nor certool is built
authorDaiki Ueno <ueno@gnu.org>
Mon, 1 Jan 2024 05:26:08 +0000 (14:26 +0900)
committerDaiki Ueno <ueno@gnu.org>
Mon, 15 Jan 2024 00:47:11 +0000 (09:47 +0900)
When compiled with --disable-tools, we can't assume p11tool and
certool are available.  This also switches to using create_testdir and
locate any intermediate files under a temporary directory which is
cleaned up at exit.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
tests/pkcs11-tool.sh

index 1ad5089e5fa9ff729eda914b081232501f0bd18d..999a3ea657f2a4b5f782d284d4f792a176a0bf13 100755 (executable)
@@ -28,11 +28,24 @@ set -x
 : ${CERTTOOL=../src/certtool${EXEEXT}}
 : ${P11TOOL=../src/p11tool${EXEEXT}}
 : ${DIFF=diff}
-TMP_SOFTHSM_DIR="./softhsm-load.$$.tmp"
-TEMPLATE="./cert.cfg"
+
+. "$srcdir/scripts/common.sh"
+
+testdir=`create_testdir ktls_keyupdate`
+
+TMP_SOFTHSM_DIR="$testdir/softhsm-load.$$.tmp"
+TEMPLATE="$testdir/cert.cfg"
 PIN=1234
 PUK=1234
 
+if ! test -x "${P11TOOL}"; then
+       exit 77
+fi
+
+if ! test -x "${CERTTOOL}"; then
+       exit 77
+fi
+
 for lib in ${libdir} ${libdir}/pkcs11 /usr/lib64/pkcs11/ /usr/lib/pkcs11/ /usr/lib/x86_64-linux-gnu/pkcs11/ /usr/lib/softhsm/; do
        if test -f "${lib}/libsofthsm2.so"; then
                SOFTHSM_MODULE="${lib}/libsofthsm2.so"
@@ -91,7 +104,7 @@ cert_signing_key
 expiration_days = 1
 _EOF_
 
-GNUTLS_PIN="$PIN" ${CERTTOOL} --generate-self-signed --outfile="${CRT}.crt" \
+GNUTLS_PIN="$PIN" ${CERTTOOL} --generate-self-signed --outfile="$testdir/ed25519-ca.crt" \
     --template=${TEMPLATE} --provider="$SOFTHSM_MODULE" \
     --load-privkey "pkcs11:object=$LABEL;type=private" \
     --load-pubkey "pkcs11:object=$LABEL;type=public" --outder
@@ -109,4 +122,5 @@ fi
 #fi
 
 
+rm -rf "$testdir"
 exit 0