00001
00002
00003
00004 #include <random.h>
00005 #include <string.h>
00006 #include <syscall.h>
00007 #include "tests/lib.h"
00008 #include "tests/main.h"
00009
00010 char buf1[1234];
00011 char buf2[1234];
00012
00013 void
00014 test_main (void)
00015 {
00016 const char *file_name = "deleteme";
00017 int fd;
00018
00019 CHECK (create (file_name, sizeof buf1), "create \"%s\"", file_name);
00020 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
00021 CHECK (remove (file_name), "remove \"%s\"", file_name);
00022 random_bytes (buf1, sizeof buf1);
00023 CHECK (write (fd, buf1, sizeof buf1) > 0, "write \"%s\"", file_name);
00024 msg ("seek \"%s\" to 0", file_name);
00025 seek (fd, 0);
00026 CHECK (read (fd, buf2, sizeof buf2) > 0, "read \"%s\"", file_name);
00027 compare_bytes (buf2, buf1, sizeof buf1, 0, file_name);
00028 msg ("close \"%s\"", file_name);
00029 close (fd);
00030 }