From 2db9f22aac8ac2cb65fa0f56f75d5c0b60a88113 Mon Sep 17 00:00:00 2001 From: Douglas Stebila Date: Mon, 25 Feb 2019 23:42:48 -0500 Subject: [PATCH] Compute touch timestamps in Python --- test/test_makefile_dependencies.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/test_makefile_dependencies.py b/test/test_makefile_dependencies.py index fd2a888d..a678a850 100644 --- a/test/test_makefile_dependencies.py +++ b/test/test_makefile_dependencies.py @@ -9,6 +9,7 @@ import pqclean import helpers import subprocess import glob +import datetime def test_makefile_dependencies(): @@ -35,15 +36,18 @@ def check_makefile_dependencies(scheme_name, implementation_name, file): # modification time-based calculations is tricky on a sub-second basis # so we reset all the modification times to a known and "sensible" order - helpers.run_subprocess(['touch'] + cfiles + hfiles + ofiles) - helpers.run_subprocess(['touch', libfile]) - helpers.run_subprocess(['touch', '-A', '-15', '-m'] + cfiles + hfiles) - helpers.run_subprocess(['touch', '-A', '-10', '-m'] + ofiles) - helpers.run_subprocess(['touch', '-A', '-05', '-m', libfile]) + now = datetime.datetime.now() + ago15 = now - datetime.timedelta(seconds=15) + ago10 = now - datetime.timedelta(seconds=10) + ago5 = now - datetime.timedelta(seconds=5) + formatstring = "%Y%m%d%H%M.%S" + helpers.run_subprocess(['touch', '-t', ago15.strftime(formatstring)] + cfiles + hfiles) + helpers.run_subprocess(['touch', '-t', ago10.strftime(formatstring)] + ofiles) + helpers.run_subprocess(['touch', '-t', ago5.strftime(formatstring), libfile]) mtime_lib_orig = os.stat(libfile).st_mtime_ns # touch the candidate .c / .h file - helpers.run_subprocess(['touch', '-A', '15', '-m', file]) + helpers.run_subprocess(['touch', '-t', now.strftime(formatstring), file]) # rebuild helpers.run_subprocess(['make'], implementation.path())