summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-10-24 17:54:30 +1100
committerDamien George <damien@micropython.org>2024-10-24 23:24:09 +1100
commit1ec0c9b886450e0f4d9f88817a8553e7177fb27f (patch)
tree948bbbd848d1aa6b75ae0eedf3ec56f7f4546831
parent120ac0f8d25fe6ee6269c31b11690373c5b55653 (diff)
tests/extmod: Use time_ns instead of time in lfs mtime test.
Because VfsLfs2 uses time_ns to create timestamps for files, and for the test to give consistent results it also needs to use this same function. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--tests/extmod/vfs_lfs_mtime.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/extmod/vfs_lfs_mtime.py b/tests/extmod/vfs_lfs_mtime.py
index 3d163dc26..d4404de4d 100644
--- a/tests/extmod/vfs_lfs_mtime.py
+++ b/tests/extmod/vfs_lfs_mtime.py
@@ -3,7 +3,7 @@
try:
import time, vfs
- time.time
+ time.time_ns
time.sleep
vfs.VfsLfs2
except (ImportError, AttributeError):
@@ -47,7 +47,8 @@ def test(bdev, vfs_class):
fs = vfs_class(bdev, mtime=True)
# Create an empty file, should have a timestamp.
- current_time = int(time.time())
+ # Use time_ns() for current time because that's what's used for VfsLfs2 time.
+ current_time = time.time_ns() // 1_000_000_000
fs.open("test1", "wt").close()
# Wait 1 second so mtime will increase by at least 1.
@@ -61,7 +62,7 @@ def test(bdev, vfs_class):
stat2 = fs.stat("test2")
print(stat1[8] != 0, stat2[8] != 0)
- # Check that test1 has mtime which matches time.time() at point of creation.
+ # Check that test1 has mtime which matches time.time_ns() at point of creation.
print(current_time <= stat1[8] <= current_time + 1)
# Check that test1 is older than test2.