diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2018-07-01 12:39:28 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-07-02 12:44:12 +0200 |
commit | d788d6225662e7d5e56ef8aa6ca962b840b6d3e9 (patch) | |
tree | 53f7495e59ee6c6bbd1663c13d1599b0dd968838 | |
parent | f1ef12ffa7d7ea18f035fa53163b12b5d694bf5b (diff) | |
download | gnutls-d788d6225662e7d5e56ef8aa6ca962b840b6d3e9.tar.gz |
tests: check explicitly the size of time_t
Previously we were disabling the 2038 tests on 32-bit systems,
but there can be 32-bit systems with a 64-bit time_t. Ensure
that we run the right tests.
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | tests/cert-tests/Makefile.am | 2 | ||||
-rwxr-xr-x | tests/cert-tests/crl | 4 | ||||
-rwxr-xr-x | tests/cert-tests/template-test | 29 |
4 files changed, 24 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac index 548abbeebd..c328ff7213 100644 --- a/configure.ac +++ b/configure.ac @@ -739,9 +739,10 @@ AC_CHECK_TYPE(ssize_t, # For minitasn1. AC_CHECK_SIZEOF(unsigned long int, 4) AC_CHECK_SIZEOF(unsigned int, 4) +AC_CHECK_SIZEOF(time_t, 4) # export for use in scripts -AC_SUBST(ac_cv_sizeof_unsigned_long_int) +AC_SUBST(ac_cv_sizeof_time_t) AC_SUBST(GNUTLS_REQUIRES_PRIVATE) diff --git a/tests/cert-tests/Makefile.am b/tests/cert-tests/Makefile.am index ff38b23bc4..4b14d4174b 100644 --- a/tests/cert-tests/Makefile.am +++ b/tests/cert-tests/Makefile.am @@ -138,7 +138,7 @@ TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT) \ VALGRIND="$(VALGRIND)" \ LIBTOOL="$(LIBTOOL)" \ top_builddir="$(top_builddir)" \ - ac_cv_sizeof_unsigned_long_int="$(ac_cv_sizeof_unsigned_long_int)" \ + ac_cv_sizeof_time_t="$(ac_cv_sizeof_time_t)" \ ASAN_OPTIONS="detect_leaks=0:exitcode=6" \ srcdir="$(srcdir)" diff --git a/tests/cert-tests/crl b/tests/cert-tests/crl index b7febc3bb2..f82bb0196c 100755 --- a/tests/cert-tests/crl +++ b/tests/cert-tests/crl @@ -25,7 +25,7 @@ export TZ="UTC" srcdir="${srcdir:-.}" CERTTOOL="${CERTTOOL:-../../src/certtool${EXEEXT}}" DIFF="${DIFF:-diff}" -ac_cv_sizeof_unsigned_long_int="${ac_cv_sizeof_unsigned_long_int:-8}" +ac_cv_sizeof_time_t="${ac_cv_sizeof_time_t:-8}" if ! test -x "${CERTTOOL}"; then exit 77 @@ -179,7 +179,7 @@ if test "$?" != "0"; then exit 1 fi -if test "${ac_cv_sizeof_unsigned_long_int}" = 8;then +if test "${ac_cv_sizeof_time_t}" = 8;then # we should test that on systems which have 64-bit time_t datefudge -s "2138-01-20 10:00:00" ${VALGRIND} \ "${CERTTOOL}" --generate-crl --load-ca-privkey "${srcdir}/data/template-test.key" \ diff --git a/tests/cert-tests/template-test b/tests/cert-tests/template-test index 3d32b78c90..2007acab3b 100755 --- a/tests/cert-tests/template-test +++ b/tests/cert-tests/template-test @@ -21,7 +21,7 @@ #set -e srcdir="${srcdir:-.}" -ac_cv_sizeof_unsigned_long_int="${ac_cv_sizeof_unsigned_long_int:-8}" +ac_cv_sizeof_time_t="${ac_cv_sizeof_time_t:-8}" CERTTOOL="${CERTTOOL:-../../src/certtool${EXEEXT}}" DIFF="${DIFF:-diff}" @@ -36,6 +36,8 @@ TMPFILE=tmp-tt.pem.$$.tmp check_for_datefudge +echo "Running test for ${ac_cv_sizeof_time_t}-byte time_t" + # Note that in rare cases this test may fail because the # time set using datefudge could have changed since the generation # (if example the system was busy) @@ -123,7 +125,6 @@ fi rm -f ${TMPFILE} # The following test works in 64-bit systems -if test "${ac_cv_sizeof_unsigned_long_int}" = 8;then datefudge -s "2007-04-22" \ "${CERTTOOL}" --generate-self-signed \ @@ -131,17 +132,25 @@ datefudge -s "2007-04-22" \ --template "${srcdir}/templates/template-overflow2.tmpl" \ --outfile ${TMPFILE} 2>/dev/null -${DIFF} "${srcdir}/data/template-overflow2.pem" ${TMPFILE} >/dev/null 2>&1 rc=$? +if test "${ac_cv_sizeof_time_t}" = 8;then + if test "$rc" != "0"; then + echo "Test 5-1 (overflow2) failed" + exit ${rc} + fi -# We're done. -if test "${rc}" != "0"; then - echo "Test 5 (overflow2) failed" - exit ${rc} -fi + ${DIFF} "${srcdir}/data/template-overflow2.pem" ${TMPFILE} #>/dev/null 2>&1 + rc=$? + + # We're done. + if test "${rc}" != "0"; then + echo $TMPFILE + echo "Test 5-2 (overflow2) failed" + exit ${rc} + fi -rm -f ${TMPFILE} fi +rm -f ${TMPFILE} datefudge -s "2007-04-22" \ "${CERTTOOL}" --generate-self-signed \ @@ -181,7 +190,7 @@ rm -f ${TMPFILE} # Test the GeneralizedTime support -if test "${ac_cv_sizeof_unsigned_long_int}" = 8;then +if test "${ac_cv_sizeof_time_t}" = 8;then # we should test that on systems which have 64-bit time_t. datefudge -s "2051-04-22" \ "${CERTTOOL}" --generate-self-signed \ |