diff options
| author | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
| commit | 4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch) | |
| tree | 868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /tests/filesys/base/syn-write.c | |
| parent | eae0bd57f0a26314a94785061888d193d186944a (diff) | |
| download | progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2 progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip | |
reorganize file structure to match the upstream requirements
Diffstat (limited to 'tests/filesys/base/syn-write.c')
| -rw-r--r-- | tests/filesys/base/syn-write.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/filesys/base/syn-write.c b/tests/filesys/base/syn-write.c new file mode 100644 index 0000000..1439862 --- /dev/null +++ b/tests/filesys/base/syn-write.c | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | /* Spawns several child processes to write out different parts of | ||
| 2 | the contents of a file and waits for them to finish. Then | ||
| 3 | reads back the file and verifies its contents. */ | ||
| 4 | |||
| 5 | #include <random.h> | ||
| 6 | #include <stdio.h> | ||
| 7 | #include <string.h> | ||
| 8 | #include <syscall.h> | ||
| 9 | #include "tests/filesys/base/syn-write.h" | ||
| 10 | #include "tests/lib.h" | ||
| 11 | #include "tests/main.h" | ||
| 12 | |||
| 13 | char buf1[BUF_SIZE]; | ||
| 14 | char buf2[BUF_SIZE]; | ||
| 15 | |||
| 16 | void | ||
| 17 | test_main (void) | ||
| 18 | { | ||
| 19 | pid_t children[CHILD_CNT]; | ||
| 20 | int fd; | ||
| 21 | |||
| 22 | CHECK (create (file_name, sizeof buf1), "create \"%s\"", file_name); | ||
| 23 | |||
| 24 | exec_children ("child-syn-wrt", children, CHILD_CNT); | ||
| 25 | wait_children (children, CHILD_CNT); | ||
| 26 | |||
| 27 | CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name); | ||
| 28 | CHECK (read (fd, buf1, sizeof buf1) > 0, "read \"%s\"", file_name); | ||
| 29 | random_bytes (buf2, sizeof buf2); | ||
| 30 | compare_bytes (buf1, buf2, sizeof buf1, 0, file_name); | ||
| 31 | } | ||
