summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/testutils/site.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/testutils/site.py b/tests/testutils/site.py
index 7dc01a613..bf3ae8db5 100644
--- a/tests/testutils/site.py
+++ b/tests/testutils/site.py
@@ -3,6 +3,7 @@
#
import os
import sys
+import tempfile
from buildstream import utils, ProgramNotFoundError
@@ -49,3 +50,34 @@ except ImportError:
HAVE_ARPY = False
IS_LINUX = os.getenv('BST_FORCE_BACKEND', sys.platform).startswith('linux')
+
+
+# Check if we have subsecond mtime support on the
+# filesystem where @directory is located.
+#
+def have_subsecond_mtime(directory):
+
+ try:
+ test_file, test_filename = tempfile.mkstemp(dir=directory)
+ os.close(test_file)
+ except OSError:
+ # If we can't create a temp file, lets just say this is False
+ return False
+
+ try:
+ os.utime(test_filename, times=None, ns=(int(12345), int(12345)))
+ except OSError:
+ # If we can't set the mtime, lets just say this is False
+ os.unlink(test_filename)
+ return False
+
+ try:
+ stat_result = os.stat(test_filename)
+ except OSError:
+ # If we can't stat the file, lets just say this is False
+ os.unlink(test_filename)
+ return False
+
+ os.unlink(test_filename)
+
+ return stat_result.st_mtime_ns == 12345