From 357d94e834c33ff09d2e993b7a930ebb7819919c Mon Sep 17 00:00:00 2001 From: Patrick Pelletier Date: Mon, 20 Aug 2018 10:53:35 -0700 Subject: [PATCH] seek test: Test some additional error cases. --- testcode/lib/seek.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/testcode/lib/seek.c b/testcode/lib/seek.c index 59603a795..200f344c2 100644 --- a/testcode/lib/seek.c +++ b/testcode/lib/seek.c @@ -173,6 +173,35 @@ int main(int argc, char **argv) } else { printf("NOT OK, no error\n"); + fclose(file); + return(1); + } + + /* ProDOS on the Apple II only supports 24-bit file offsets, + ** so anything beyond that should be an error. I don't know + ** about other platforms, but I'm guessing no 6502-based + ** operating systems support 32-bit offsets? + */ + printf("seeking to position 2^24:\n\t"); + pos = lseek(fd, 0x1000000L, SEEK_SET); + if (pos == -1) { + printf("Ok, error %s\n", strerror(errno)); + } + else { + printf("NOT OK, returned %ld but expected -1\n", pos); + fclose(file); + return(1); + } + + printf("trying invalid value for whence:\n\t"); + pos = lseek(fd, 0L, 3); + if (pos == -1) { + printf("Ok, error %s\n", strerror(errno)); + } + else { + printf("NOT OK, returned %ld but expected -1\n", pos); + fclose(file); + return(1); } fclose(file); -- 2.39.5