summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/vfs_lfs_mtime.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2020-08-31 15:01:10 +1000
committerDamien George <damien@micropython.org>2020-09-02 00:19:38 +1000
commit0e6ef403598a7a5fbc44b28e43c264c24aa02416 (patch)
tree4cab0136d25b91e93ff4bda3a5ef55ec9519957b /tests/extmod/vfs_lfs_mtime.py
parenta909c215879d94e7e76046f71f38e881949fe7dc (diff)
downloadmicropython-0e6ef403598a7a5fbc44b28e43c264c24aa02416.tar.gz
micropython-0e6ef403598a7a5fbc44b28e43c264c24aa02416.zip
tests/extmod: Add tests for verifying FAT and littlefs mtime values.
Verifies mtime timestamps on files match the value returned by time.time(). Also update vfs_fat_ramdisk.py so it doesn't check FAT timestamp of the root, because that may change across runs/ports. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/extmod/vfs_lfs_mtime.py')
-rw-r--r--tests/extmod/vfs_lfs_mtime.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/extmod/vfs_lfs_mtime.py b/tests/extmod/vfs_lfs_mtime.py
index 0108076884..bacdd2246c 100644
--- a/tests/extmod/vfs_lfs_mtime.py
+++ b/tests/extmod/vfs_lfs_mtime.py
@@ -3,6 +3,7 @@
try:
import utime, uos
+ utime.time
utime.sleep
uos.VfsLfs2
except (ImportError, AttributeError):
@@ -46,6 +47,7 @@ def test(bdev, vfs_class):
vfs = vfs_class(bdev, mtime=True)
# Create an empty file, should have a timestamp.
+ current_time = int(utime.time())
vfs.open("test1", "wt").close()
# Wait 1 second so mtime will increase by at least 1.
@@ -54,10 +56,15 @@ def test(bdev, vfs_class):
# Create another empty file, should have a timestamp.
vfs.open("test2", "wt").close()
- # Stat the files and check that test1 is older than test2.
+ # Stat the files and check mtime is non-zero.
stat1 = vfs.stat("test1")
stat2 = vfs.stat("test2")
print(stat1[8] != 0, stat2[8] != 0)
+
+ # Check that test1 has mtime which matches time.time() at point of creation.
+ print(current_time <= stat1[8] <= current_time + 1)
+
+ # Check that test1 is older than test2.
print(stat1[8] < stat2[8])
# Wait 1 second so mtime will increase by at least 1.