diff options
-rw-r--r-- | tests/files.cpp | 10 | ||||
-rw-r--r-- | tests/unistd/io.c | 6 | ||||
-rw-r--r-- | tests/unistd/io.out | 4 |
3 files changed, 11 insertions, 9 deletions
diff --git a/tests/files.cpp b/tests/files.cpp index 5d158ba9..176cdb62 100644 --- a/tests/files.cpp +++ b/tests/files.cpp @@ -2,7 +2,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> int main() { @@ -62,14 +61,7 @@ int main() char data2[10]; FILE *inf = fopen("go.out", "rb"); - - // make sure pread returns 0 if we read starting at the end (or past the end) of the file - int num = pread(fileno(inf), data2, 10, 5); - assert(num == 0); - num = pread(fileno(inf), data2, 10, sizeof(data)*8); - assert(num == 0); - - num = fread(data2, 1, 10, inf); + int num = fread(data2, 1, 10, inf); fclose(inf); printf("%d : %d,%d,%d,%d,%d\n", num, data2[0], data2[1], data2[2], data2[3], data2[4]); diff --git a/tests/unistd/io.c b/tests/unistd/io.c index 0ff5f4fb..6bf22593 100644 --- a/tests/unistd/io.c +++ b/tests/unistd/io.c @@ -104,6 +104,12 @@ int main() { printf("errno: %d\n\n", errno); errno = 0; + printf("pread past end of file: %d\n", pread(f, readBuffer, sizeof readBuffer, 99999999999)); + printf("data: %s\n", readBuffer); + memset(readBuffer, 0, sizeof readBuffer); + printf("errno: %d\n\n", errno); + errno = 0; + printf("seek: %d\n", lseek(f, 3, SEEK_SET)); printf("errno: %d\n\n", errno); printf("partial read from file: %d\n", read(f, readBuffer, 3)); diff --git a/tests/unistd/io.out b/tests/unistd/io.out index 037d0c34..c979557e 100644 --- a/tests/unistd/io.out +++ b/tests/unistd/io.out @@ -31,6 +31,10 @@ read from file: 10 data: 1234567890 errno: 0 +pread past end of file: 0 +data: +errno: 0 + seek: 3 errno: 0 |