random: Fix behavior of kernel option "-rs".
[pintos-anon] / src / tests / userprog / read-boundary.c
1 /* Reads data spanning two pages in virtual address space,
2    which must succeed. */
3
4 #include <string.h>
5 #include <syscall.h>
6 #include "tests/userprog/boundary.h"
7 #include "tests/userprog/sample.inc"
8 #include "tests/lib.h"
9 #include "tests/main.h"
10
11 void
12 test_main (void) 
13 {
14   int handle;
15   int byte_cnt;
16   char *buffer;
17
18   CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
19
20   buffer = get_boundary_area () - sizeof sample / 2;
21   byte_cnt = read (handle, buffer, sizeof sample - 1);
22   if (byte_cnt != sizeof sample - 1)
23     fail ("read() returned %d instead of %zu", byte_cnt, sizeof sample - 1);
24   else if (strcmp (sample, buffer)) 
25     {
26       msg ("expected text:\n%s", sample);
27       msg ("text actually read:\n%s", buffer);
28       fail ("expected text differs from actual");
29     }
30 }