summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Metzler <ametzler@bebt.de>2023-03-17 18:18:46 +0100
committerAndreas Metzler <ametzler@bebt.de>2023-04-04 17:56:05 +0200
commitedf92eb4881542de09bb72a9598cf528af25a9b2 (patch)
tree4989b4674d53a547a9461cd1e67967fd03e3a567
parent31ece95986d2735421f3461b447acf2755c59838 (diff)
downloadgnutls-edf92eb4881542de09bb72a9598cf528af25a9b2.tar.gz
Add wrapper around faketime/datefudge
Prefer faketime, fall back to datefudge. Signed-off-by: Andreas Metzler <ametzler@bebt.de>
-rw-r--r--tests/scripts/common.sh48
1 files changed, 45 insertions, 3 deletions
diff --git a/tests/scripts/common.sh b/tests/scripts/common.sh
index 8afc50f17f..cbc57c23c7 100644
--- a/tests/scripts/common.sh
+++ b/tests/scripts/common.sh
@@ -109,12 +109,54 @@ check_for_datefudge() {
}
skip_if_no_datefudge() {
- if ! check_for_datefudge; then
- echo "You need datefudge to run this test"
- exit 77
+ # Prefer faketime, fall back to datefudge.
+ # Allow datefudge/faketime to be manually selected by setting env-var
+ if test -z "${GNUTLS_TIMEWRAPPER_CMD}" ; then
+ if test "$WINDOWS" = 1; then
+ exit 77
+ fi
+
+ TSTAMP=`faketime -f "2006-09-23 00:00:00" "${top_builddir}/tests/datefudge-check" || true`
+ if test "$TSTAMP" = "1158969600"; then
+ GNUTLS_TIMEWRAPPER_CMD=faketime
+ else
+ TSTAMP=`datefudge -s "2006-09-23 00:00:00" "${top_builddir}/tests/datefudge-check" || true`
+ if test "$TSTAMP" = "1158969600"; then
+ GNUTLS_TIMEWRAPPER_CMD=datefudge
+ else
+ echo "You need faketime/datefudge to run this test"
+ exit 77
+ fi
+ fi
fi
}
+gnutls_timewrapper_standalone() {
+ if test -z "${GNUTLS_TIMEWRAPPER_CMD}" ; then
+ echo "Missing invocation of skip_if_no_datefudge()"
+ exit 1
+ fi
+
+ if [ "$1" = "static" ] ; then
+ shift
+ case ${GNUTLS_TIMEWRAPPER_CMD} in
+ faketime)
+ faketime -f "$@"
+ ;;
+ datefudge)
+ datefudge -s "$@"
+ ;;
+ *)
+ echo "GNUTLS_TIMEWRAPPER_CMD ${GNUTLS_TIMEWRAPPER_CMD} invalid" 1>&2
+ exit 1
+ ;;
+ esac
+ else
+ ${GNUTLS_TIMEWRAPPER_CMD} "$@"
+ fi
+}
+
+
fail() {
PID="$1"
shift