diff options
| author | klaar36 <klas.arvidsson@liu.se> | 2016-05-09 18:10:23 +0200 |
|---|---|---|
| committer | klaar36 <klas.arvidsson@liu.se> | 2016-05-09 18:10:23 +0200 |
| commit | c4e42961e885612ca2b84dd0246d09b86aad2b97 (patch) | |
| tree | 3fd5665708f3ddf6a534d1dde53a3773b58d4013 /src/tests/klaar/pfs-reader.c | |
| parent | c71baf223e8de56d8cef3814952d704987125ce2 (diff) | |
| download | pintos-rs-c4e42961e885612ca2b84dd0246d09b86aad2b97.tar.gz | |
pfs test
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; +} |
