00001
00002
00003
00004
00005
00006
00007 #include <string.h>
00008 #include <syscall.h>
00009 #include "tests/vm/sample.inc"
00010 #include "tests/lib.h"
00011 #include "tests/main.h"
00012
00013 void
00014 test_main (void)
00015 {
00016 int handle;
00017 int slen = strlen (sample);
00018 char buf2[65536];
00019
00020
00021 CHECK (create ("sample.txt", slen), "create \"sample.txt\"");
00022 CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
00023 CHECK (write (handle, sample, slen) == slen, "write \"sample.txt\"");
00024 close (handle);
00025
00026
00027 CHECK ((handle = open ("sample.txt")) > 1, "2nd open \"sample.txt\"");
00028 CHECK (read (handle, buf2 + 32768, slen) == slen, "read \"sample.txt\"");
00029
00030 CHECK (!memcmp (sample, buf2 + 32768, slen), "compare written data against read data");
00031 close (handle);
00032 }