Test keytrans in addition to testing the basic suite
[monkeysphere.git] / tests / keytrans
index e1ccda599bbcdede8496660017c80793ab67b2a3..bad2ae3a15839f8dd27d2245f3bd2fcfce3ac178 100755 (executable)
@@ -30,17 +30,16 @@ trap failed_cleanup EXIT
 ## set up some variables to ensure that we're operating strictly in
 ## the tests, not system-wide:
 
-# make temp dir
-TEMPDIR="$TESTDIR"/tmp
-if [ -e "$TEMPDIR" ] ; then
-    echo "tempdir '$TEMPDIR' already exists."
-    exit 1
-fi
-mkdir -p "$TEMPDIR"
+mkdir -p "$TESTDIR"/tmp
+TEMPDIR=$(mktemp -d "${TMPDIR:-$TESTDIR/tmp}/monkeyspheretest.XXXXXXX")
+
+mkdir "$TEMPDIR"/bin
+ln -s "$TESTDIR"/../src/share/keytrans "$TEMPDIR"/bin/openpgp2ssh
+ln -s "$TESTDIR"/../src/share/keytrans "$TEMPDIR"/bin/pem2openpgp
 
 # Use the local copy of executables first, instead of system ones.
 # This should help us test without installing.
-export PATH="$TESTDIR"/../src/keytrans:"$PATH"
+export PATH="$TEMPDIR"/bin:"$PATH"
 
 ######################################################################
 ### TEST KEYTRANS
@@ -78,3 +77,11 @@ diff -u \
     <(PEM2OPENPGP_USAGE_FLAGS=sign,certify \
     PEM2OPENPGP_TIMESTAMP="$timestamp" pem2openpgp testtest < \
     "$TEMPDIR"/test.pem | hd )
+
+trap - EXIT
+
+echo "##################################################"
+echo " Monkeysphere keytrans test completed successfully!"
+echo "##################################################"
+
+cleanup