Update release-README after completing the 2.43 release.
[binutils-gdb.git] / sim / testsuite / cris / c / seek4.c
blob16f3bb0b0cd1adde0714c9ce3fd0a0dc8bd138bf
1 /* Check for a sim bug, whereby an invalid seek (to a negative offset)
2 did not return an error. */
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <errno.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <fcntl.h>
10 #include <unistd.h>
12 int
13 main (void)
15 FILE *f;
16 const char fname[] = "sk1test.dat";
17 const char tsttxt[]
18 = "A random line of text, used to test correct read, write and seek.\n";
19 char buf[sizeof tsttxt] = "";
20 int fd;
22 f = fopen (fname, "wb");
23 if (f == NULL
24 || fwrite (tsttxt, 1, strlen (tsttxt), f) != strlen (tsttxt)
25 || fclose (f) != 0)
27 printf ("fail\n");
28 exit (1);
31 fd = open (fname, O_RDONLY);
32 if (fd < 0
33 || lseek (fd, -1L, SEEK_CUR) != -1
34 || errno != EINVAL
35 || read (fd, buf, strlen (tsttxt)) != strlen (tsttxt)
36 || strcmp (buf, tsttxt) != 0)
38 printf ("fail\n");
39 exit (1);
42 printf ("pass\n");
43 exit (0);