]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: use 'datefudge -s' to avoid loops
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 28 Feb 2016 09:45:02 +0000 (10:45 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 28 Feb 2016 09:45:05 +0000 (10:45 +0100)
This avoids repeated loops of the same test as well as
random failures in the test suite.

tests/cert-tests/krb5-test
tests/cert-tests/othername-test
tests/cert-tests/sha3-test
tests/cert-tests/template-test

index ed32da57c252b43e8f73d1d200bac839ad0ce161..6ad121cdcb66cb89ad766b1b043ae93a6f1d39d5 100755 (executable)
@@ -44,21 +44,14 @@ fi
 # time set using datefudge could have changed since the generation
 # (if example the system was busy)
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 5 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-krb5name.tmpl" \
                --outfile ${OUTFILE} 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-krb5name.pem" ${OUTFILE} >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-krb5name.pem" ${OUTFILE} >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -70,7 +63,7 @@ fi
 cp template-krb5name.tmpl ${TMPLFILE}
 echo "krb5_principal = 'xxxxxxxxxxxxxx'" >>${TMPLFILE}
 
-datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
 ${VALGRIND} "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template ${TMPLFILE} \
@@ -87,7 +80,7 @@ fi
 cp template-krb5name.tmpl ${TMPLFILE}
 echo "krb5_principal = 'comp1/comp2/comp3/comp4/comp5/comp6/comp7/comp8/comp9/comp10@REALM.COM'" >>${TMPLFILE}
 
-datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
 ${VALGRIND} "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template ${TMPLFILE} \
index 0197331f7c0ffbf6c3d76095451bbb5ef2fea49e..40cedea7bf3b47ec223fc3aa3df32cb8da8f8d54 100755 (executable)
@@ -39,21 +39,14 @@ fi
 # time set using datefudge could have changed since the generation
 # (if example the system was busy)
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-othername.tmpl" \
                --outfile ${OUTFILE} 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-othername.pem" ${OUTFILE} >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-othername.pem" ${OUTFILE} >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -61,21 +54,14 @@ if test "${rc}" != "0"; then
        exit ${rc}
 fi
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-othername-xmpp.tmpl" \
                --outfile ${OUTFILE} 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-othername-xmpp.pem" ${OUTFILE} >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-othername-xmpp.pem" ${OUTFILE} >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
index ade2c8d41f52acc0a696c63b5c14406fbf13571e..114f2b180532f1e950a0b054bb65bff6d1cfafd9 100755 (executable)
@@ -40,21 +40,14 @@ fi
 
 # Test SHA3 signatures
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
-       "${CERTTOOL}" --generate-self-signed \
+datefudge -s "2007-04-22" \
+"${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-test.tmpl" \
                --outfile "${TMPFILE}" --hash sha3-256 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-rsa-sha3-256.pem" "${TMPFILE}" >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-rsa-sha3-256.pem" "${TMPFILE}" >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -62,7 +55,7 @@ if test "${rc}" != "0"; then
        exit ${rc}
 fi
 
-datefudge "2007-04-25" \
+datefudge -s "2007-04-25" \
        "${CERTTOOL}" --load-ca-certificate "${TMPFILE}" --verify --infile "${TMPFILE}" >/dev/null 2>&1
 rc=$?
 if test "${rc}" != "0"; then
@@ -71,21 +64,14 @@ if test "${rc}" != "0"; then
 fi
 
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-test.tmpl" \
                --outfile "${TMPFILE}" --hash sha3-512 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-rsa-sha3-512.pem" "${TMPFILE}" >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-rsa-sha3-512.pem" "${TMPFILE}" >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -93,7 +79,7 @@ if test "${rc}" != "0"; then
        exit ${rc}
 fi
 
-datefudge "2007-04-25" \
+datefudge -s "2007-04-25" \
        "${CERTTOOL}" --load-ca-certificate "${TMPFILE}" --verify --infile "${TMPFILE}" >/dev/null 2>&1
 rc=$?
 if test "${rc}" != "0"; then
@@ -103,7 +89,7 @@ fi
 
 # Test SHA3 signatures with ECDSA
 
-datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
 "${CERTTOOL}" --generate-self-signed \
        --load-privkey "${srcdir}/template-test-ecc.key" \
        --template "${srcdir}/template-test.tmpl" \
@@ -116,7 +102,7 @@ if test "${rc}" != "0"; then
        exit ${rc}
 fi
 
-datefudge "2007-04-25" \
+datefudge -s "2007-04-25" \
        "${CERTTOOL}" --load-ca-certificate "${TMPFILE}" --verify --infile "${TMPFILE}" >/dev/null 2>&1
 rc=$?
 if test "${rc}" != "0"; then
@@ -125,7 +111,7 @@ if test "${rc}" != "0"; then
 fi
 
 
-datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
 "${CERTTOOL}" --generate-self-signed \
        --load-privkey "${srcdir}/template-test-ecc.key" \
        --template "${srcdir}/template-test.tmpl" \
@@ -139,7 +125,7 @@ if test "${rc}" != "0"; then
        exit ${rc}
 fi
 
-datefudge "2007-04-25" \
+datefudge -s "2007-04-25" \
        "${CERTTOOL}" --load-ca-certificate "${TMPFILE}" --verify --infile "${TMPFILE}" >/dev/null 2>&1
 rc=$?
 if test "${rc}" != "0"; then
index ce68ce117d76a1cd4f663a44cae2ae05d2acf4a6..9e40696adcfeed9a8f9e8d0f2ad2493e9b3827bd 100755 (executable)
@@ -38,21 +38,14 @@ fi
 # time set using datefudge could have changed since the generation
 # (if example the system was busy)
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-test.tmpl" \
                --outfile tmp-tt.pem 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-test.pem" tmp-tt.pem >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-test.pem" tmp-tt.pem >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -62,21 +55,14 @@ fi
 
 rm -f tmp-tt.pem
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-utf8.tmpl" \
                --outfile tmp-tt.pem 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-utf8.pem" tmp-tt.pem >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-utf8.pem" tmp-tt.pem >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -86,21 +72,14 @@ fi
 
 rm -f tmp-tt.pem
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-dn.tmpl" \
                --outfile tmp-tt.pem 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-dn.pem" tmp-tt.pem >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-dn.pem" tmp-tt.pem >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -110,7 +89,7 @@ fi
 
 rm -f tmp-tt.pem
 
-datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-dn-err.tmpl" \
@@ -124,21 +103,14 @@ fi
 
 rm -f tmp-tt.pem
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-overflow.tmpl" \
                --outfile tmp-tt.pem 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-overflow.pem" tmp-tt.pem >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-overflow.pem" tmp-tt.pem >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -151,21 +123,14 @@ rm -f tmp-tt.pem
 # The following test works in 64-bit systems
 if echo __SIZEOF_POINTER__ | cpp -E - - | grep '^8$' >/dev/null; then
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-overflow2.tmpl" \
                --outfile tmp-tt.pem 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-overflow2.pem" tmp-tt.pem >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-overflow2.pem" tmp-tt.pem >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -176,21 +141,14 @@ fi
 rm -f tmp-tt.pem
 fi
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-date.tmpl" \
                --outfile tmp-tt.pem 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-date.pem" tmp-tt.pem >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-date.pem" tmp-tt.pem >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -202,21 +160,14 @@ rm -f tmp-tt.pem
 
 # Test name constraints generation
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-nc.tmpl" \
                --outfile tmp-tt.pem 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-nc.pem" tmp-tt.pem >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-nc.pem" tmp-tt.pem >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then
@@ -230,21 +181,14 @@ rm -f tmp-tt.pem
 # Test the GeneralizedTime support
 if test "$(getconf LONG_BIT)" = "64"; then
        # we should test that on systems which have 64-bit time_t.
-       rc=1
-       counter=1
-
-       while [ "${rc}" != "0" -a $counter -le 3 ]; do
-               datefudge "2051-04-22" \
+       datefudge -s "2051-04-22" \
                        "${CERTTOOL}" --generate-self-signed \
                                --load-privkey "${srcdir}/template-test.key" \
                                --template "${srcdir}/template-generalized.tmpl" \
                                --outfile tmp-tt.pem 2>/dev/null
 
-               ${DIFF} "${srcdir}/template-generalized.pem" tmp-tt.pem >/dev/null 2>&1
-               rc=$?
-               test ${rc} != 0 && sleep 3
-               counter=`expr $counter + 1`
-       done
+       ${DIFF} "${srcdir}/template-generalized.pem" tmp-tt.pem >/dev/null 2>&1
+       rc=$?
 
        # We're done.
        if test "${rc}" != "0"; then
@@ -257,21 +201,14 @@ rm -f tmp-tt.pem
 
 # Test unique ID field generation
 
-rc=1
-counter=1
-
-while [ "${rc}" != "0" -a $counter -le 3 ]; do
-       datefudge "2007-04-22" \
+datefudge -s "2007-04-22" \
        "${CERTTOOL}" --generate-self-signed \
                --load-privkey "${srcdir}/template-test.key" \
                --template "${srcdir}/template-unique.tmpl" \
                --outfile tmp-tt.pem 2>/dev/null
 
-       ${DIFF} "${srcdir}/template-unique.pem" tmp-tt.pem >/dev/null 2>&1
-       rc=$?
-       test ${rc} != 0 && sleep 3
-       counter=`expr $counter + 1`
-done
+${DIFF} "${srcdir}/template-unique.pem" tmp-tt.pem >/dev/null 2>&1
+rc=$?
 
 # We're done.
 if test "${rc}" != "0"; then