8000 tests/extmod: Use time_ns instead of time in lfs mtime test. · micropython/micropython@1ec0c9b · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ec0c9b

Browse files
committed
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>
1 parent 120ac0f commit 1ec0c9b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/extmod/vfs_lfs_mtime.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
try:
44
import time, vfs
55

6-
time.time
6+
time.time_ns
77
time.sleep
88
vfs.VfsLfs2
99
except (ImportError, AttributeError):
@@ -47,7 +47,8 @@ def test(bdev, vfs_class):
4747
fs = vfs_class(bdev, mtime=True)
4848

4949
# Create an empty file, should have a timestamp.
50-
current_time = int(time.time())
50+
# Use time_ns() for current time because that's what's used for VfsLfs2 time.
51+
current_time = time.time_ns() // 1_000_000_000
5152
fs.open("test1", "wt").close()
5253

5354
# Wait 1 second so mtime will increase by at least 1.
@@ -61,7 +62,7 @@ def test(bdev, vfs_class):
6162
stat2 = fs.stat("test2")
6263
print(stat1[8] != 0, stat2[8] != 0)
6364

64-
# Check that test1 has mtime which matches time.time() at point of creation.
65+
# Check that test1 has mtime which matches time.time_ns() at point of creation.
6566
print(current_time <= stat1[8] <= current_time + 1)
6667

6768
# Check that test1 is older than test2.

0 commit comments

Comments
 (0)
0