From c4e42961e885612ca2b84dd0246d09b86aad2b97 Mon Sep 17 00:00:00 2001 From: klaar36 Date: Mon, 9 May 2016 18:10:23 +0200 Subject: pfs test --- src/tests/klaar/pfs-reader.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/tests/klaar/pfs-reader.c (limited to 'src/tests/klaar/pfs-reader.c') 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 +#include + +#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; +} -- cgit v1.2.1