From: Nikos Mavrogiannopoulos Date: Sun, 28 Feb 2016 09:45:02 +0000 (+0100) Subject: tests: use 'datefudge -s' to avoid loops X-Git-Tag: gnutls_3_5_0~298 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4156885beac91ac45fc5853a8d034d0b7daab0c0;p=thirdparty%2Fgnutls.git tests: use 'datefudge -s' to avoid loops This avoids repeated loops of the same test as well as random failures in the test suite. --- diff --git a/tests/cert-tests/krb5-test b/tests/cert-tests/krb5-test index ed32da57c2..6ad121cdcb 100755 --- a/tests/cert-tests/krb5-test +++ b/tests/cert-tests/krb5-test @@ -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} \ diff --git a/tests/cert-tests/othername-test b/tests/cert-tests/othername-test index 0197331f7c..40cedea7bf 100755 --- a/tests/cert-tests/othername-test +++ b/tests/cert-tests/othername-test @@ -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 diff --git a/tests/cert-tests/sha3-test b/tests/cert-tests/sha3-test index ade2c8d41f..114f2b1805 100755 --- a/tests/cert-tests/sha3-test +++ b/tests/cert-tests/sha3-test @@ -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 diff --git a/tests/cert-tests/template-test b/tests/cert-tests/template-test index ce68ce117d..9e40696adc 100755 --- a/tests/cert-tests/template-test +++ b/tests/cert-tests/template-test @@ -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