Filesystem: Add tests for whole-file locks.
This commit is contained in:
parent
68c9fb111c
commit
e14ef4b8a9
1 changed files with 43 additions and 0 deletions
|
|
@ -957,6 +957,49 @@ const tests =
|
|||
done();
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "File Locks",
|
||||
timeout: 60,
|
||||
start: () =>
|
||||
{
|
||||
emulator.serial0_send("touch /mnt/file\n");
|
||||
emulator.serial0_send("mkfifo /mnt/fifo1\n");
|
||||
emulator.serial0_send("mkfifo /mnt/fifo2\n");
|
||||
|
||||
emulator.serial0_send("flock -s /mnt/file -c 'cat /mnt/fifo1 >> /mnt/file' &\n");
|
||||
emulator.serial0_send("flock -s /mnt/file -c 'echo lock-shared-2 >> /mnt/file' \n");
|
||||
emulator.serial0_send("echo lock-shared-1 > /mnt/fifo1\n");
|
||||
|
||||
emulator.serial0_send("flock -x /mnt/file -c 'cat /mnt/fifo1 >> /mnt/file' &\n");
|
||||
emulator.serial0_send("flock -x /mnt/file -c 'echo lock-exclusive-2 >> /mnt/file' &\n");
|
||||
emulator.serial0_send("echo lock-exclusive-1 > /mnt/fifo1\n");
|
||||
|
||||
emulator.serial0_send("flock -s /mnt/file -c 'cat /mnt/fifo1 >> /mnt/file' &\n");
|
||||
emulator.serial0_send("flock -s /mnt/file -c 'cat /mnt/fifo2 >> /mnt/file' &\n");
|
||||
emulator.serial0_send("flock -x /mnt/file -c 'echo lock-exclusive-3 >> /mnt/file' &\n");
|
||||
emulator.serial0_send("echo lock-shared-4 > /mnt/fifo2\n");
|
||||
emulator.serial0_send("echo lock-shared-3 > /mnt/fifo1\n");
|
||||
|
||||
emulator.serial0_send("echo start-capture;\\\n");
|
||||
emulator.serial0_send("cat /mnt/file;\\\n");
|
||||
emulator.serial0_send("echo done-locks\n");
|
||||
},
|
||||
capture_trigger: "start-capture",
|
||||
end_trigger: "done-locks",
|
||||
end: (capture, done) =>
|
||||
{
|
||||
assert_equal(capture,
|
||||
"lock-shared-2\n" +
|
||||
"lock-shared-1\n" +
|
||||
"lock-exclusive-1\n" +
|
||||
"lock-exclusive-2\n" +
|
||||
"lock-shared-4\n" +
|
||||
"lock-shared-3\n" +
|
||||
"lock-exclusive-3\n");
|
||||
|
||||
done();
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Stress Files",
|
||||
timeout: 360,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue