X-Git-Url: http://akaros.cs.berkeley.edu/gitweb/?p=akaros.git;a=blobdiff_plain;f=tests%2Ffile_test.c;h=e6e111f0de6dbafc3aa53e3267fdbf11ce23dbd5;hp=610a1ea8ba7ff280b06c793d016f581ef0d692ba;hb=e5e8d36d04cbe16e2f9366ea4cbbb3856c309e1e;hpb=f49d0da3692b09f01acc68299b80d7ec88f77e5d diff --git a/tests/file_test.c b/tests/file_test.c index 610a1ea..e6e111f 100644 --- a/tests/file_test.c +++ b/tests/file_test.c @@ -1,4 +1,6 @@ -#include +#define _LARGEFILE64_SOURCE /* needed to use lseek64 */ + +#include #include #include #include @@ -7,7 +9,9 @@ #include #include #include +#include +#define DUMMY_STR "AAAaaaBBBbbb" int main() { FILE *file; @@ -22,13 +26,26 @@ int main() int retval; retval = read(fd, rbuf, 16); printf("Tried to read, got %d bytes of buf: %s\n", retval, rbuf); - strcpy(wbuf, "paul <3's the new 61c"); - retval = write(fd, wbuf, 22); + strcpy(wbuf, DUMMY_STR); + retval = write(fd, wbuf, strlen(DUMMY_STR)); printf("Tried to write, wrote %d bytes\n", retval); + printf("Trying to seek to 0\n"); lseek(fd, 0, SEEK_SET); retval = read(fd, rbuf, 64); printf("Tried to read again, got %d bytes of buf: %s\n", retval, rbuf); + if (strcmp(DUMMY_STR, rbuf)) { + printf("Failed to read back our dummy string!\n"); + return -1; + } + printf("Trying to lseek64 to 0\n"); + lseek64(fd, 0, SEEK_SET); + retval = read(fd, rbuf, 64); + printf("Tried to read again, got %d bytes of buf: %s\n", retval, rbuf); + if (strcmp(DUMMY_STR, rbuf)) { + printf("Failed to read back our dummy string!\n"); + return -1; + } retval = access("/bin/laden", X_OK); if (errno != ENOENT) @@ -155,7 +172,19 @@ int main() printf("Trying a chmod\n"); retval = chmod("/dir1/dir1-1/f1-1.txt", S_IRWXO); if (retval < 0) - printf("WARNING! chmod failed with %d!\n", retval); + printf("WARNING! chmod failed with %d!\n", errno); + /* Try adding a directory or two! */ + printf("Add dir3 and dir4, then remove dir4\n"); + retval = mkdir("/dir3", S_IRWXU | S_IRWXG | S_IRWXO); + if (retval < 0) + printf("WARNING! mkdir failed with %d!\n", errno); + retval = mkdir("/dir4", S_IRWXU | S_IRWXG | S_IRWXO); + if (retval < 0) + printf("WARNING! mkdir failed with %d!\n", errno); + retval = rmdir("/dir4"); + if (retval < 0) + printf("WARNING! rmdir failed with %d!\n", errno); breakpoint(); + }