This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include <unistd.h>
22
23 #include "signature.h"
24 SIGNATURE_CHECK (lseek, off_t, (int, off_t, int));
25
26 #include <errno.h>
27
28 #include "macros.h"
29
30
31
32
33 int
34 main (int argc, char **argv)
35 {
36 if (argc != 2)
37 return 2;
38 switch (*argv[1])
39 {
40 case '0':
41 ASSERT (lseek (0, (off_t)2, SEEK_SET) == 2);
42 ASSERT (lseek (0, (off_t)-4, SEEK_CUR) == -1);
43 ASSERT (errno == EINVAL);
44 errno = 0;
45 #if ! defined __BEOS__
46
47
48 ASSERT (lseek (0, (off_t)0, SEEK_CUR) == 2);
49 #endif
50 #if 0
51 ASSERT (lseek (0, (off_t)0, (SEEK_SET | SEEK_CUR | SEEK_END) + 1) == -1);
52 ASSERT (errno == EINVAL);
53 #endif
54 ASSERT (lseek (1, (off_t)2, SEEK_SET) == 2);
55 errno = 0;
56 ASSERT (lseek (1, (off_t)-4, SEEK_CUR) == -1);
57 ASSERT (errno == EINVAL);
58 errno = 0;
59 #if ! defined __BEOS__
60
61
62 ASSERT (lseek (1, (off_t)0, SEEK_CUR) == 2);
63 #endif
64 #if 0
65 ASSERT (lseek (1, (off_t)0, (SEEK_SET | SEEK_CUR | SEEK_END) + 1) == -1);
66 ASSERT (errno == EINVAL);
67 #endif
68 break;
69
70 case '1':
71 errno = 0;
72 ASSERT (lseek (0, (off_t)0, SEEK_CUR) == -1);
73 ASSERT (errno == ESPIPE);
74 errno = 0;
75 ASSERT (lseek (1, (off_t)0, SEEK_CUR) == -1);
76 ASSERT (errno == ESPIPE);
77 break;
78
79 case '2':
80
81
82 close (0);
83 close (1);
84
85 errno = 0;
86 ASSERT (lseek (0, (off_t)0, SEEK_CUR) == -1);
87 ASSERT (errno == EBADF);
88
89 errno = 0;
90 ASSERT (lseek (1, (off_t)0, SEEK_CUR) == -1);
91 ASSERT (errno == EBADF);
92
93
94 errno = 0;
95 ASSERT (lseek (-1, (off_t)0, SEEK_CUR) == -1);
96 ASSERT (errno == EBADF);
97
98 close (99);
99 errno = 0;
100 ASSERT (lseek (99, (off_t)0, SEEK_CUR) == -1);
101 ASSERT (errno == EBADF);
102
103 break;
104
105 default:
106 return 1;
107 }
108 return 0;
109 }