diff options
| author | Felipe Boeira <felipe.boeira@liu.se> | 2020-03-04 14:49:23 +0100 |
|---|---|---|
| committer | Felipe Boeira <felipe.boeira@liu.se> | 2020-03-04 14:49:23 +0100 |
| commit | aa02564229d69a16da3d34a3742233aac81fd8b1 (patch) | |
| tree | c958a2f70d55ae7c3720d28559b3a5448b3f42b2 /src/examples/pfs_writer.c | |
| parent | a2730d47f02ddd8c40021bfdd962b986b09fc556 (diff) | |
| download | pintos-aa02564229d69a16da3d34a3742233aac81fd8b1.tar.gz | |
Updated tests
Diffstat (limited to 'src/examples/pfs_writer.c')
| -rw-r--r-- | src/examples/pfs_writer.c | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/src/examples/pfs_writer.c b/src/examples/pfs_writer.c index 0ebd772..80f0826 100644 --- a/src/examples/pfs_writer.c +++ b/src/examples/pfs_writer.c @@ -6,42 +6,52 @@ #include <syscall.h> #include <stdio.h> #include <string.h> +#include <random.h> + #include "pfs.h" + char buffer[BIG]; int main(int argc, char* argv[]) { - int i,j; - char c; - int id; - int write_count; - char start; - char end; - - if (argc != 3 || strlen(argv[1]) != 1 || strlen(argv[2]) != 1) - exit(1); - - start = argv[1][0]; - end = argv[2][0]; - - for (i = 0; i < TIMES / (end - start + 1) + 1; ++i) - { - for (c = start; c <= end; ++c) - { - for (j = 0; j < BIG; j++) - buffer[j] = c; - - id = open("file.1"); - write_count = write(id, buffer, BIG); - - if ( write_count != BIG ) - { - printf("TEST ERROR: write() wrote only %d bytes out of %d bytes\n", - write_count, BIG); - } - close(id); - } - } - exit(0); + int i; + char c; + int id; + int write_count; + char start; + char end; + + random_init((int)argv[3][0]); + printf("+\n"); + + if (argc != 4 || strlen(argv[1]) != 1 || strlen(argv[2]) != 1) + exit(1); + + start = argv[1][0]; + end = argv[2][0]; + + for (i = 0; i < TIMES / (end - start + 1) + 1; ++i) + { + for (c = start; c <= end; ++c) + { + memset(buffer, (int)c, BIG); + + id = open("file.1"); + + seek(id,(random_ulong() % (TIMES-1)) * BIG); + write_count = write(id, buffer, BIG); + + if ( write_count != BIG ) + { + printf("TEST ERROR: write() wrote only %d bytes out of %d bytes\n", + write_count, BIG); + close(id); + exit(-1); + } + close(id); + } + } + printf("*+\n"); + exit(0); } |
