diff --git a/tests/devices/virtio_9p.js b/tests/devices/virtio_9p.js index d646b736..57cdd75f 100755 --- a/tests/devices/virtio_9p.js +++ b/tests/devices/virtio_9p.js @@ -33,6 +33,16 @@ function assert_equal(actual, expected) } } +function assert_not_equal(actual, expected) +{ + if(actual === expected) + { + log_warn("Failed assert not equal (Test: %s)", tests[test_num].name); + log_warn("Expected something different than:\n" + expected); + test_fail(); + } +} + // Random printable characters. const test_file = new Uint8Array(512).map(v => 0x20 + Math.random() * 0x5e); const test_file_string = Buffer.from(test_file).toString(); @@ -158,6 +168,26 @@ const tests = done(); }, }, + { + name: "New file time", + timeout: 10, + start: () => + { + emulator.serial0_send("echo start-capture; echo foo > /mnt/bar; ls -l --full-time --color=never /mnt/bar; echo; echo done-write-new\n"); + }, + capture_trigger: "start-capture", + end_trigger: "done-write-new", + end: (capture, done) => + { + const outputs = capture.split("\n").map(output => output.split(/\s+/)); + + // atime: Should be fresh + const [year, month, day] = outputs[0][5].split("-"); + assert_not_equal(year, "1970"); + + done(); + }, + }, { name: "Move", timeout: 10,