00001
00002
00003
00004 #include <string.h>
00005 #include <syscall.h>
00006 #include "tests/userprog/boundary.h"
00007 #include "tests/userprog/sample.inc"
00008 #include "tests/lib.h"
00009 #include "tests/main.h"
00010
00011 void
00012 test_main (void)
00013 {
00014 int handle;
00015 int byte_cnt;
00016 char *buffer;
00017
00018 CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
00019
00020 buffer = get_boundary_area () - sizeof sample / 2;
00021 byte_cnt = read (handle, buffer, sizeof sample - 1);
00022 if (byte_cnt != sizeof sample - 1)
00023 fail ("read() returned %d instead of %zu", byte_cnt, sizeof sample - 1);
00024 else if (strcmp (sample, buffer))
00025 {
00026 msg ("expected text:\n%s", sample);
00027 msg ("text actually read:\n%s", buffer);
00028 fail ("expected text differs from actual");
00029 }
00030 }