blob: e6b4363c942b6050ebe5ab237b4d45fa8c39687c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
}
|