diff options
Diffstat (limited to 'src/tests/klaar/pfs-reader.c')
| -rw-r--r-- | src/tests/klaar/pfs-reader.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tests/klaar/pfs-reader.c b/src/tests/klaar/pfs-reader.c new file mode 100644 index 0000000..e6b4363 --- /dev/null +++ b/src/tests/klaar/pfs-reader.c @@ -0,0 +1,44 @@ +/* Part of pfs.c suite. + + Reads from the file and checks consistency. + The buffer should all contain the same character!! + */ + +#include <syscall.h> +#include <stdio.h> + +#include "../lib.h" +#include "pfs.h" + +static bool check_consistency(char* buf, int size) +{ + for (int i = 1; i < size; ++i) + { + if (buf[0] != buf[i]) + { + /* Ooops, inconsistency */ + return false; + } + } + return true; +} + +char buffer[BIG]; + +int main (int argc UNUSED, char *argv[]) +{ + test_name = argv[0]; + quiet = true; + + for (int i = 0; i < TIMES; ++i) + { + int id = open ("file.1"); + CHECK ( id > 1, "open \"file.1\""); + int bytes = read(id, buffer, BIG); + CHECK ( bytes == BIG, "read \"file.1\""); + close(id); + + CHECK ( check_consistency(buffer, BIG), "inconsistency"); + } + return 0; +} |
