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/child-syn-read.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/child-syn-read.c')
| -rw-r--r-- | tests/filesys/base/child-syn-read.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/filesys/base/child-syn-read.c b/tests/filesys/base/child-syn-read.c new file mode 100644 index 0000000..77a5e26 --- /dev/null +++ b/tests/filesys/base/child-syn-read.c | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | /* Child process for syn-read test. | ||
| 2 | Reads the contents of a test file a byte at a time, in the | ||
| 3 | hope that this will take long enough that we can get a | ||
| 4 | significant amount of contention in the kernel file system | ||
| 5 | code. */ | ||
| 6 | |||
| 7 | #include <random.h> | ||
| 8 | #include <stdio.h> | ||
| 9 | #include <stdlib.h> | ||
| 10 | #include <syscall.h> | ||
| 11 | #include "tests/lib.h" | ||
| 12 | #include "tests/filesys/base/syn-read.h" | ||
| 13 | |||
| 14 | const char *test_name = "child-syn-read"; | ||
| 15 | |||
| 16 | static char buf[BUF_SIZE]; | ||
| 17 | |||
| 18 | int | ||
| 19 | main (int argc, const char *argv[]) | ||
| 20 | { | ||
| 21 | int child_idx; | ||
| 22 | int fd; | ||
| 23 | size_t i; | ||
| 24 | |||
| 25 | quiet = true; | ||
| 26 | |||
| 27 | CHECK (argc == 2, "argc must be 2, actually %d", argc); | ||
| 28 | child_idx = atoi (argv[1]); | ||
| 29 | |||
| 30 | random_init (0); | ||
| 31 | random_bytes (buf, sizeof buf); | ||
| 32 | |||
| 33 | CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name); | ||
| 34 | for (i = 0; i < sizeof buf; i++) | ||
| 35 | { | ||
| 36 | char c; | ||
| 37 | CHECK (read (fd, &c, 1) > 0, "read \"%s\"", file_name); | ||
| 38 | compare_bytes (&c, buf + i, 1, i, file_name); | ||
| 39 | } | ||
| 40 | close (fd); | ||
| 41 | |||
| 42 | return child_idx; | ||
| 43 | } | ||
| 44 | |||
