1*86d7f5d3SJohn Marino /*-
2*86d7f5d3SJohn Marino * Copyright (c) 2007 Roman Divacky <pho@FreeBSD.org>
3*86d7f5d3SJohn Marino * All rights reserved.
4*86d7f5d3SJohn Marino *
5*86d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without
6*86d7f5d3SJohn Marino * modification, are permitted provided that the following conditions
7*86d7f5d3SJohn Marino * are met:
8*86d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright
9*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer.
10*86d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright
11*86d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in the
12*86d7f5d3SJohn Marino * documentation and/or other materials provided with the distribution.
13*86d7f5d3SJohn Marino *
14*86d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*86d7f5d3SJohn Marino * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*86d7f5d3SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*86d7f5d3SJohn Marino * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*86d7f5d3SJohn Marino * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*86d7f5d3SJohn Marino * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*86d7f5d3SJohn Marino * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*86d7f5d3SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*86d7f5d3SJohn Marino * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*86d7f5d3SJohn Marino * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*86d7f5d3SJohn Marino * SUCH DAMAGE.
25*86d7f5d3SJohn Marino *
26*86d7f5d3SJohn Marino */
27*86d7f5d3SJohn Marino
28*86d7f5d3SJohn Marino #include <errno.h>
29*86d7f5d3SJohn Marino #include <fcntl.h>
30*86d7f5d3SJohn Marino #include <stdbool.h>
31*86d7f5d3SJohn Marino #include <stdio.h>
32*86d7f5d3SJohn Marino #include <stdlib.h>
33*86d7f5d3SJohn Marino #include <unistd.h>
34*86d7f5d3SJohn Marino #include <string.h>
35*86d7f5d3SJohn Marino #include <sys/types.h>
36*86d7f5d3SJohn Marino #include <sys/syscall.h>
37*86d7f5d3SJohn Marino #include <sys/stat.h>
38*86d7f5d3SJohn Marino #include <sys/param.h>
39*86d7f5d3SJohn Marino
40*86d7f5d3SJohn Marino union param {
41*86d7f5d3SJohn Marino int i;
42*86d7f5d3SJohn Marino char *cp;
43*86d7f5d3SJohn Marino mode_t m;
44*86d7f5d3SJohn Marino dev_t d;
45*86d7f5d3SJohn Marino void *vp;
46*86d7f5d3SJohn Marino uid_t u;
47*86d7f5d3SJohn Marino gid_t g;
48*86d7f5d3SJohn Marino char **cpp;
49*86d7f5d3SJohn Marino };
50*86d7f5d3SJohn Marino
51*86d7f5d3SJohn Marino struct testcase {
52*86d7f5d3SJohn Marino int result;
53*86d7f5d3SJohn Marino union param params[5]; // no *at syscall with more than 5 params
54*86d7f5d3SJohn Marino };
55*86d7f5d3SJohn Marino
56*86d7f5d3SJohn Marino struct test {
57*86d7f5d3SJohn Marino int syscall;
58*86d7f5d3SJohn Marino int num_of_cases;
59*86d7f5d3SJohn Marino char *name;
60*86d7f5d3SJohn Marino struct testcase tests[10]; // no more than 10 tests
61*86d7f5d3SJohn Marino
62*86d7f5d3SJohn Marino };
63*86d7f5d3SJohn Marino
64*86d7f5d3SJohn Marino struct test *tests;
65*86d7f5d3SJohn Marino #define NUM_OF_TESTS 15
66*86d7f5d3SJohn Marino
67*86d7f5d3SJohn Marino char *absolute_path = NULL;
68*86d7f5d3SJohn Marino char *relative_path = "tmp/";
69*86d7f5d3SJohn Marino char *not_dir_path = "/bin/date";
70*86d7f5d3SJohn Marino
71*86d7f5d3SJohn Marino char *file = "foo";
72*86d7f5d3SJohn Marino char *absolute_file = NULL;
73*86d7f5d3SJohn Marino char *relative_file = NULL;
74*86d7f5d3SJohn Marino char *symlinkf = "link";
75*86d7f5d3SJohn Marino char *newlink = "nlink1";
76*86d7f5d3SJohn Marino char *newlink2 = "nlink2";
77*86d7f5d3SJohn Marino char *newlink3 = "nlink3";
78*86d7f5d3SJohn Marino char *newdir = "newdir";
79*86d7f5d3SJohn Marino char *fifo = "fifo";
80*86d7f5d3SJohn Marino char *nod = "nod";
81*86d7f5d3SJohn Marino char *newfile = "newfile";
82*86d7f5d3SJohn Marino char *newslink = "nslink1";
83*86d7f5d3SJohn Marino
84*86d7f5d3SJohn Marino bool dir_exist = false;
85*86d7f5d3SJohn Marino bool file_exist = false;
86*86d7f5d3SJohn Marino bool link_exist = false;
87*86d7f5d3SJohn Marino
88*86d7f5d3SJohn Marino int rel_fd, abs_fd, notd_fd, exec_fd;
89*86d7f5d3SJohn Marino
90*86d7f5d3SJohn Marino struct timeval times[2];
91*86d7f5d3SJohn Marino struct stat buf;
92*86d7f5d3SJohn Marino char *pargv[2] = { "/bin/date", NULL };
93*86d7f5d3SJohn Marino char cbuf[PATH_MAX];
94*86d7f5d3SJohn Marino
95*86d7f5d3SJohn Marino void
setup()96*86d7f5d3SJohn Marino setup()
97*86d7f5d3SJohn Marino {
98*86d7f5d3SJohn Marino int i, error;
99*86d7f5d3SJohn Marino struct stat sb;
100*86d7f5d3SJohn Marino
101*86d7f5d3SJohn Marino tests = calloc(NUM_OF_TESTS, sizeof(struct test));
102*86d7f5d3SJohn Marino if (tests == NULL) {
103*86d7f5d3SJohn Marino perror("");
104*86d7f5d3SJohn Marino exit(0);
105*86d7f5d3SJohn Marino }
106*86d7f5d3SJohn Marino
107*86d7f5d3SJohn Marino absolute_path = getcwd(NULL, 0);
108*86d7f5d3SJohn Marino if (absolute_path == NULL) {
109*86d7f5d3SJohn Marino perror("getcwd");
110*86d7f5d3SJohn Marino exit(0);
111*86d7f5d3SJohn Marino }
112*86d7f5d3SJohn Marino
113*86d7f5d3SJohn Marino absolute_path = realloc(absolute_path, strlen(absolute_path) + 5);
114*86d7f5d3SJohn Marino if (absolute_path == NULL) {
115*86d7f5d3SJohn Marino perror("realloc");
116*86d7f5d3SJohn Marino exit(0);
117*86d7f5d3SJohn Marino }
118*86d7f5d3SJohn Marino
119*86d7f5d3SJohn Marino strcat(absolute_path, "/");
120*86d7f5d3SJohn Marino strcat(absolute_path, relative_path);
121*86d7f5d3SJohn Marino
122*86d7f5d3SJohn Marino absolute_file = malloc(strlen(absolute_path) + 1 + strlen(file));
123*86d7f5d3SJohn Marino bzero(absolute_file, strlen(absolute_path) + 1 + strlen(file));
124*86d7f5d3SJohn Marino if (absolute_file == NULL) {
125*86d7f5d3SJohn Marino perror("malloc");
126*86d7f5d3SJohn Marino exit(0);
127*86d7f5d3SJohn Marino }
128*86d7f5d3SJohn Marino strcpy(absolute_file, absolute_path);
129*86d7f5d3SJohn Marino absolute_file[strlen(absolute_file)] = '/';
130*86d7f5d3SJohn Marino strcpy(absolute_file + strlen(absolute_path), file);
131*86d7f5d3SJohn Marino
132*86d7f5d3SJohn Marino printf("XX: %s\n", absolute_file);
133*86d7f5d3SJohn Marino
134*86d7f5d3SJohn Marino relative_file = malloc(strlen(relative_path) + 1 + strlen(file));
135*86d7f5d3SJohn Marino bzero(relative_file, strlen(relative_path) + 1 + strlen(file));
136*86d7f5d3SJohn Marino if (relative_file == NULL) {
137*86d7f5d3SJohn Marino perror("malloc");
138*86d7f5d3SJohn Marino exit(0);
139*86d7f5d3SJohn Marino }
140*86d7f5d3SJohn Marino strcpy(relative_file, relative_path);
141*86d7f5d3SJohn Marino relative_file[strlen(relative_file)] = '/';
142*86d7f5d3SJohn Marino strcpy(relative_file + strlen(relative_path), file);
143*86d7f5d3SJohn Marino
144*86d7f5d3SJohn Marino printf("YY: %s\n", relative_file);
145*86d7f5d3SJohn Marino
146*86d7f5d3SJohn Marino error = mkdir(relative_path, 0744);
147*86d7f5d3SJohn Marino dir_exist = (errno == EEXIST);
148*86d7f5d3SJohn Marino if (error && errno != EEXIST) {
149*86d7f5d3SJohn Marino perror("tmp");
150*86d7f5d3SJohn Marino exit(0);
151*86d7f5d3SJohn Marino }
152*86d7f5d3SJohn Marino
153*86d7f5d3SJohn Marino error = stat("tmp/foo", &sb);
154*86d7f5d3SJohn Marino file_exist = (errno != ENOENT);
155*86d7f5d3SJohn Marino i = open("tmp/foo", O_RDONLY | O_CREAT, 0644);
156*86d7f5d3SJohn Marino if (i == -1) {
157*86d7f5d3SJohn Marino perror("foo");
158*86d7f5d3SJohn Marino exit(0);
159*86d7f5d3SJohn Marino }
160*86d7f5d3SJohn Marino
161*86d7f5d3SJohn Marino rel_fd = open(relative_path, O_RDONLY);
162*86d7f5d3SJohn Marino if (rel_fd == -1) {
163*86d7f5d3SJohn Marino perror("relative path");
164*86d7f5d3SJohn Marino exit(0);
165*86d7f5d3SJohn Marino }
166*86d7f5d3SJohn Marino
167*86d7f5d3SJohn Marino abs_fd = open(absolute_path, O_RDONLY);
168*86d7f5d3SJohn Marino if (abs_fd == -1) {
169*86d7f5d3SJohn Marino perror("absolute path");
170*86d7f5d3SJohn Marino exit(0);
171*86d7f5d3SJohn Marino }
172*86d7f5d3SJohn Marino
173*86d7f5d3SJohn Marino notd_fd = open(not_dir_path, O_RDONLY);
174*86d7f5d3SJohn Marino if (notd_fd == -1) {
175*86d7f5d3SJohn Marino perror("not a directory");
176*86d7f5d3SJohn Marino exit(0);
177*86d7f5d3SJohn Marino }
178*86d7f5d3SJohn Marino
179*86d7f5d3SJohn Marino exec_fd = open(not_dir_path, O_RDONLY);
180*86d7f5d3SJohn Marino if (exec_fd == -1) {
181*86d7f5d3SJohn Marino perror("not a directory");
182*86d7f5d3SJohn Marino exit(0);
183*86d7f5d3SJohn Marino }
184*86d7f5d3SJohn Marino
185*86d7f5d3SJohn Marino error = symlink(absolute_file, symlinkf);
186*86d7f5d3SJohn Marino link_exist = (errno == EEXIST);
187*86d7f5d3SJohn Marino if (error && errno != EEXIST) {
188*86d7f5d3SJohn Marino perror("symlink");
189*86d7f5d3SJohn Marino exit(0);
190*86d7f5d3SJohn Marino }
191*86d7f5d3SJohn Marino
192*86d7f5d3SJohn Marino // faccessat
193*86d7f5d3SJohn Marino tests[0].syscall = SYS_faccessat;
194*86d7f5d3SJohn Marino tests[0].num_of_cases = 6;
195*86d7f5d3SJohn Marino tests[0].name = "faccessat";
196*86d7f5d3SJohn Marino tests[0].tests[0].result = EBADF;
197*86d7f5d3SJohn Marino tests[0].tests[0].params[0].i = 106; // invalid fd
198*86d7f5d3SJohn Marino tests[0].tests[0].params[1].cp = relative_path;
199*86d7f5d3SJohn Marino tests[0].tests[0].params[2].m = 0;
200*86d7f5d3SJohn Marino tests[0].tests[0].params[3].i = 0;
201*86d7f5d3SJohn Marino tests[0].tests[1].result = EBADF;
202*86d7f5d3SJohn Marino tests[0].tests[1].params[0].i = 106; // invalid fd
203*86d7f5d3SJohn Marino tests[0].tests[1].params[1].cp = relative_path;
204*86d7f5d3SJohn Marino tests[0].tests[1].params[2].m = 0;
205*86d7f5d3SJohn Marino tests[0].tests[1].params[3].i = AT_EACCESS;
206*86d7f5d3SJohn Marino tests[0].tests[2].result = EINVAL;
207*86d7f5d3SJohn Marino tests[0].tests[2].params[0].i = rel_fd;
208*86d7f5d3SJohn Marino tests[0].tests[2].params[1].cp = absolute_path;
209*86d7f5d3SJohn Marino tests[0].tests[2].params[2].m = 0;
210*86d7f5d3SJohn Marino tests[0].tests[2].params[3].i = 123; // invalid flag
211*86d7f5d3SJohn Marino tests[0].tests[3].result = ENOTDIR;
212*86d7f5d3SJohn Marino tests[0].tests[3].params[0].i = notd_fd;
213*86d7f5d3SJohn Marino tests[0].tests[3].params[1].cp = relative_file;
214*86d7f5d3SJohn Marino tests[0].tests[3].params[2].m = 0;
215*86d7f5d3SJohn Marino tests[0].tests[3].params[3].i = 0;
216*86d7f5d3SJohn Marino tests[0].tests[4].result = 0;
217*86d7f5d3SJohn Marino tests[0].tests[4].params[0].i = rel_fd;
218*86d7f5d3SJohn Marino tests[0].tests[4].params[1].cp = file;
219*86d7f5d3SJohn Marino tests[0].tests[4].params[2].m = 0;
220*86d7f5d3SJohn Marino tests[0].tests[4].params[3].i = 0;
221*86d7f5d3SJohn Marino tests[0].tests[5].result = 0;
222*86d7f5d3SJohn Marino tests[0].tests[5].params[0].i = rel_fd;
223*86d7f5d3SJohn Marino tests[0].tests[5].params[1].cp = file;
224*86d7f5d3SJohn Marino tests[0].tests[5].params[2].m = 0;
225*86d7f5d3SJohn Marino tests[0].tests[5].params[3].i = AT_EACCESS;
226*86d7f5d3SJohn Marino tests[0].tests[6].result = 0;
227*86d7f5d3SJohn Marino tests[0].tests[6].params[0].i = 106; // invalid fd
228*86d7f5d3SJohn Marino tests[0].tests[6].params[1].cp = absolute_path;
229*86d7f5d3SJohn Marino tests[0].tests[6].params[2].m = 0;
230*86d7f5d3SJohn Marino tests[0].tests[6].params[3].i = 0;
231*86d7f5d3SJohn Marino
232*86d7f5d3SJohn Marino // fchmodat
233*86d7f5d3SJohn Marino tests[1].syscall = SYS_fchmodat;
234*86d7f5d3SJohn Marino tests[1].num_of_cases = 6;
235*86d7f5d3SJohn Marino tests[1].name = "fchmodat";
236*86d7f5d3SJohn Marino tests[1].tests[0].result = EBADF;
237*86d7f5d3SJohn Marino tests[1].tests[0].params[0].i = 106; // invalid fd
238*86d7f5d3SJohn Marino tests[1].tests[0].params[1].cp = relative_path;
239*86d7f5d3SJohn Marino tests[1].tests[0].params[2].m = 33190;
240*86d7f5d3SJohn Marino tests[1].tests[0].params[3].i = 0;
241*86d7f5d3SJohn Marino tests[1].tests[1].result = EINVAL;
242*86d7f5d3SJohn Marino tests[1].tests[1].params[0].i = rel_fd;
243*86d7f5d3SJohn Marino tests[1].tests[1].params[1].cp = absolute_path;
244*86d7f5d3SJohn Marino tests[1].tests[1].params[2].m = 33190; // mode 646 translated
245*86d7f5d3SJohn Marino tests[1].tests[1].params[3].i = 123; // invalid flag
246*86d7f5d3SJohn Marino tests[1].tests[2].result = ENOTDIR;
247*86d7f5d3SJohn Marino tests[1].tests[2].params[0].i = notd_fd;
248*86d7f5d3SJohn Marino tests[1].tests[2].params[1].cp = relative_file;
249*86d7f5d3SJohn Marino tests[1].tests[2].params[2].m = 33190;
250*86d7f5d3SJohn Marino tests[1].tests[2].params[3].i = 0;
251*86d7f5d3SJohn Marino tests[1].tests[3].result = 0;
252*86d7f5d3SJohn Marino tests[1].tests[3].params[0].i = notd_fd;
253*86d7f5d3SJohn Marino tests[1].tests[3].params[1].cp = absolute_file;
254*86d7f5d3SJohn Marino tests[1].tests[3].params[2].m = 33190;
255*86d7f5d3SJohn Marino tests[1].tests[3].params[3].i = 0;
256*86d7f5d3SJohn Marino tests[1].tests[4].result = 0;
257*86d7f5d3SJohn Marino tests[1].tests[4].params[0].i = AT_FDCWD;
258*86d7f5d3SJohn Marino tests[1].tests[4].params[1].cp = symlinkf;
259*86d7f5d3SJohn Marino tests[1].tests[4].params[2].m = 33190;
260*86d7f5d3SJohn Marino tests[1].tests[4].params[3].i = AT_SYMLINK_NOFOLLOW;
261*86d7f5d3SJohn Marino tests[1].tests[5].result = 0;
262*86d7f5d3SJohn Marino tests[1].tests[5].params[0].i = rel_fd;
263*86d7f5d3SJohn Marino tests[1].tests[5].params[1].cp = file;
264*86d7f5d3SJohn Marino tests[1].tests[5].params[2].m = 33190;
265*86d7f5d3SJohn Marino tests[1].tests[5].params[3].i = 0;
266*86d7f5d3SJohn Marino
267*86d7f5d3SJohn Marino // fchownat
268*86d7f5d3SJohn Marino tests[2].syscall = SYS_fchownat;
269*86d7f5d3SJohn Marino tests[2].num_of_cases = 6;
270*86d7f5d3SJohn Marino tests[2].name = "fchownat";
271*86d7f5d3SJohn Marino tests[2].tests[0].result = EBADF;
272*86d7f5d3SJohn Marino tests[2].tests[0].params[0].i = 106; // invalid fd
273*86d7f5d3SJohn Marino tests[2].tests[0].params[1].cp = relative_file;
274*86d7f5d3SJohn Marino tests[2].tests[0].params[2].u = 65534;
275*86d7f5d3SJohn Marino tests[2].tests[0].params[3].g = 65534;
276*86d7f5d3SJohn Marino tests[2].tests[0].params[4].i = 0;
277*86d7f5d3SJohn Marino tests[2].tests[1].result = EINVAL;
278*86d7f5d3SJohn Marino tests[2].tests[1].params[0].i = rel_fd;
279*86d7f5d3SJohn Marino tests[2].tests[1].params[1].cp = file;
280*86d7f5d3SJohn Marino tests[2].tests[1].params[2].u = 65534;
281*86d7f5d3SJohn Marino tests[2].tests[1].params[3].g = 65534;
282*86d7f5d3SJohn Marino tests[2].tests[1].params[4].i = 123; // invalid flag
283*86d7f5d3SJohn Marino tests[2].tests[2].result = ENOTDIR;
284*86d7f5d3SJohn Marino tests[2].tests[2].params[0].i = notd_fd;
285*86d7f5d3SJohn Marino tests[2].tests[2].params[1].cp = relative_file;
286*86d7f5d3SJohn Marino tests[2].tests[2].params[2].u = 65534;
287*86d7f5d3SJohn Marino tests[2].tests[2].params[3].g = 65534;
288*86d7f5d3SJohn Marino tests[2].tests[2].params[4].i = 0;
289*86d7f5d3SJohn Marino tests[2].tests[3].result = 0;
290*86d7f5d3SJohn Marino tests[2].tests[3].params[0].i = notd_fd;
291*86d7f5d3SJohn Marino tests[2].tests[3].params[1].cp = absolute_file;
292*86d7f5d3SJohn Marino tests[2].tests[3].params[2].u = 65534;
293*86d7f5d3SJohn Marino tests[2].tests[3].params[3].g = 65534;
294*86d7f5d3SJohn Marino tests[2].tests[3].params[4].i = 0;
295*86d7f5d3SJohn Marino tests[2].tests[4].result = 0;
296*86d7f5d3SJohn Marino tests[2].tests[4].params[0].i = AT_FDCWD;
297*86d7f5d3SJohn Marino tests[2].tests[4].params[1].cp = symlinkf;
298*86d7f5d3SJohn Marino tests[2].tests[4].params[2].u = 65534;
299*86d7f5d3SJohn Marino tests[2].tests[4].params[3].g = 65534;
300*86d7f5d3SJohn Marino tests[2].tests[4].params[4].i = AT_SYMLINK_NOFOLLOW;
301*86d7f5d3SJohn Marino tests[2].tests[5].result = 0;
302*86d7f5d3SJohn Marino tests[2].tests[5].params[0].i = rel_fd;
303*86d7f5d3SJohn Marino tests[2].tests[5].params[1].cp = file;
304*86d7f5d3SJohn Marino tests[2].tests[5].params[2].u = 0;
305*86d7f5d3SJohn Marino tests[2].tests[5].params[3].g = 0;
306*86d7f5d3SJohn Marino tests[2].tests[5].params[4].i = 0;
307*86d7f5d3SJohn Marino
308*86d7f5d3SJohn Marino // fstatat
309*86d7f5d3SJohn Marino tests[3].syscall = SYS_fstatat;
310*86d7f5d3SJohn Marino tests[3].num_of_cases = 5;
311*86d7f5d3SJohn Marino tests[3].name = "fstatat";
312*86d7f5d3SJohn Marino tests[3].tests[0].result = EBADF;
313*86d7f5d3SJohn Marino tests[3].tests[0].params[0].i = 106; // invalid fd
314*86d7f5d3SJohn Marino tests[3].tests[0].params[1].cp = relative_file;
315*86d7f5d3SJohn Marino tests[3].tests[0].params[2].vp = &buf;
316*86d7f5d3SJohn Marino tests[3].tests[0].params[3].i = 0;
317*86d7f5d3SJohn Marino tests[3].tests[1].result = EINVAL;
318*86d7f5d3SJohn Marino tests[3].tests[1].params[0].i = rel_fd;
319*86d7f5d3SJohn Marino tests[3].tests[1].params[1].cp = relative_file;
320*86d7f5d3SJohn Marino tests[3].tests[1].params[2].vp = &buf;
321*86d7f5d3SJohn Marino tests[3].tests[1].params[3].i = 123; // invalid flags
322*86d7f5d3SJohn Marino tests[3].tests[2].result = ENOTDIR;
323*86d7f5d3SJohn Marino tests[3].tests[2].params[0].i = notd_fd;
324*86d7f5d3SJohn Marino tests[3].tests[2].params[1].cp = relative_file;
325*86d7f5d3SJohn Marino tests[3].tests[2].params[2].vp = &buf;
326*86d7f5d3SJohn Marino tests[3].tests[2].params[3].i = 0;
327*86d7f5d3SJohn Marino tests[3].tests[2].result = 0;
328*86d7f5d3SJohn Marino tests[3].tests[2].params[0].i = rel_fd;
329*86d7f5d3SJohn Marino tests[3].tests[2].params[1].cp = file;
330*86d7f5d3SJohn Marino tests[3].tests[2].params[2].vp = &buf;
331*86d7f5d3SJohn Marino tests[3].tests[2].params[3].i = 0;
332*86d7f5d3SJohn Marino tests[3].tests[3].result = 0;
333*86d7f5d3SJohn Marino tests[3].tests[3].params[0].i = AT_FDCWD;
334*86d7f5d3SJohn Marino tests[3].tests[3].params[1].cp = symlinkf;
335*86d7f5d3SJohn Marino tests[3].tests[3].params[2].vp = &buf;
336*86d7f5d3SJohn Marino tests[3].tests[3].params[3].i = AT_SYMLINK_NOFOLLOW;
337*86d7f5d3SJohn Marino tests[3].tests[4].result = 0;
338*86d7f5d3SJohn Marino tests[3].tests[4].params[0].i = notd_fd;
339*86d7f5d3SJohn Marino tests[3].tests[4].params[1].cp = absolute_file;
340*86d7f5d3SJohn Marino tests[3].tests[4].params[2].vp = &buf;
341*86d7f5d3SJohn Marino tests[3].tests[4].params[3].i = 0;
342*86d7f5d3SJohn Marino
343*86d7f5d3SJohn Marino // futimesat
344*86d7f5d3SJohn Marino tests[4].syscall = SYS_futimesat;
345*86d7f5d3SJohn Marino tests[4].num_of_cases = 4;
346*86d7f5d3SJohn Marino tests[4].name = "futimesat";
347*86d7f5d3SJohn Marino tests[4].tests[0].result = EBADF;
348*86d7f5d3SJohn Marino tests[4].tests[0].params[0].i = 106; // invalid fd
349*86d7f5d3SJohn Marino tests[4].tests[0].params[1].cp = relative_file;
350*86d7f5d3SJohn Marino tests[4].tests[0].params[2].vp = times;
351*86d7f5d3SJohn Marino tests[4].tests[1].result = ENOTDIR;
352*86d7f5d3SJohn Marino tests[4].tests[1].params[0].i = notd_fd;
353*86d7f5d3SJohn Marino tests[4].tests[1].params[1].cp = relative_file;
354*86d7f5d3SJohn Marino tests[4].tests[1].params[2].vp = times;
355*86d7f5d3SJohn Marino tests[4].tests[2].result = 0;
356*86d7f5d3SJohn Marino tests[4].tests[2].params[0].i = rel_fd;
357*86d7f5d3SJohn Marino tests[4].tests[2].params[1].cp = file;
358*86d7f5d3SJohn Marino tests[4].tests[2].params[2].vp = times;
359*86d7f5d3SJohn Marino tests[4].tests[3].result = 0;
360*86d7f5d3SJohn Marino tests[4].tests[3].params[0].i = notd_fd;
361*86d7f5d3SJohn Marino tests[4].tests[3].params[1].cp = absolute_file;
362*86d7f5d3SJohn Marino tests[4].tests[3].params[2].vp = times;
363*86d7f5d3SJohn Marino
364*86d7f5d3SJohn Marino // linkat
365*86d7f5d3SJohn Marino tests[5].syscall = SYS_linkat;
366*86d7f5d3SJohn Marino tests[5].num_of_cases = 7;
367*86d7f5d3SJohn Marino tests[5].name = "linkat";
368*86d7f5d3SJohn Marino tests[5].tests[0].result = EBADF;
369*86d7f5d3SJohn Marino tests[5].tests[0].params[0].i = 106; // invalid fd
370*86d7f5d3SJohn Marino tests[5].tests[0].params[1].cp = relative_file;
371*86d7f5d3SJohn Marino tests[5].tests[0].params[2].i = AT_FDCWD;
372*86d7f5d3SJohn Marino tests[5].tests[0].params[3].cp = newlink;
373*86d7f5d3SJohn Marino tests[5].tests[0].params[4].i = 0;
374*86d7f5d3SJohn Marino tests[5].tests[1].result = EBADF;
375*86d7f5d3SJohn Marino tests[5].tests[1].params[0].i = AT_FDCWD;
376*86d7f5d3SJohn Marino tests[5].tests[1].params[1].cp = relative_file;
377*86d7f5d3SJohn Marino tests[5].tests[1].params[2].i = 106; // invalid fd
378*86d7f5d3SJohn Marino tests[5].tests[1].params[3].cp = newlink;
379*86d7f5d3SJohn Marino tests[5].tests[1].params[4].i = 0;
380*86d7f5d3SJohn Marino tests[5].tests[2].result = EINVAL;
381*86d7f5d3SJohn Marino tests[5].tests[2].params[0].i = rel_fd;
382*86d7f5d3SJohn Marino tests[5].tests[2].params[1].cp = relative_file;
383*86d7f5d3SJohn Marino tests[5].tests[2].params[2].i = AT_FDCWD;
384*86d7f5d3SJohn Marino tests[5].tests[2].params[3].cp = newlink;
385*86d7f5d3SJohn Marino tests[5].tests[2].params[4].i = 123; // invalid flag
386*86d7f5d3SJohn Marino tests[5].tests[3].result = ENOTDIR;
387*86d7f5d3SJohn Marino tests[5].tests[3].params[0].i = notd_fd;
388*86d7f5d3SJohn Marino tests[5].tests[3].params[1].cp = relative_file;
389*86d7f5d3SJohn Marino tests[5].tests[3].params[2].i = AT_FDCWD;
390*86d7f5d3SJohn Marino tests[5].tests[3].params[3].cp = newlink;
391*86d7f5d3SJohn Marino tests[5].tests[3].params[4].i = 0;
392*86d7f5d3SJohn Marino tests[5].tests[4].result = 0;
393*86d7f5d3SJohn Marino tests[5].tests[4].params[0].i = rel_fd;
394*86d7f5d3SJohn Marino tests[5].tests[4].params[1].cp = file;
395*86d7f5d3SJohn Marino tests[5].tests[4].params[2].i = rel_fd;
396*86d7f5d3SJohn Marino tests[5].tests[4].params[3].cp = newlink;
397*86d7f5d3SJohn Marino tests[5].tests[4].params[4].i = 0;
398*86d7f5d3SJohn Marino tests[5].tests[5].result = 0;
399*86d7f5d3SJohn Marino tests[5].tests[5].params[0].i = AT_FDCWD;
400*86d7f5d3SJohn Marino tests[5].tests[5].params[1].cp = symlinkf;
401*86d7f5d3SJohn Marino tests[5].tests[5].params[2].i = rel_fd;
402*86d7f5d3SJohn Marino tests[5].tests[5].params[3].cp = newlink2;
403*86d7f5d3SJohn Marino tests[5].tests[5].params[4].i = 0;
404*86d7f5d3SJohn Marino tests[5].tests[6].result = 0;
405*86d7f5d3SJohn Marino tests[5].tests[6].params[0].i = AT_FDCWD;
406*86d7f5d3SJohn Marino tests[5].tests[6].params[1].cp = symlinkf;
407*86d7f5d3SJohn Marino tests[5].tests[6].params[2].i = rel_fd;
408*86d7f5d3SJohn Marino tests[5].tests[6].params[3].cp = newlink3;
409*86d7f5d3SJohn Marino tests[5].tests[6].params[4].i = AT_SYMLINK_FOLLOW;
410*86d7f5d3SJohn Marino
411*86d7f5d3SJohn Marino // mkdirat
412*86d7f5d3SJohn Marino tests[6].syscall = SYS_mkdirat;
413*86d7f5d3SJohn Marino tests[6].num_of_cases = 3;
414*86d7f5d3SJohn Marino tests[6].name = "mkdirat";
415*86d7f5d3SJohn Marino tests[6].tests[0].result = EBADF;
416*86d7f5d3SJohn Marino tests[6].tests[0].params[0].i = 106; // invalid fd
417*86d7f5d3SJohn Marino tests[6].tests[0].params[1].cp = relative_file;
418*86d7f5d3SJohn Marino tests[6].tests[0].params[2].m = 33190;
419*86d7f5d3SJohn Marino tests[6].tests[1].result = ENOTDIR;
420*86d7f5d3SJohn Marino tests[6].tests[1].params[0].i = notd_fd;
421*86d7f5d3SJohn Marino tests[6].tests[1].params[1].cp = relative_file;
422*86d7f5d3SJohn Marino tests[6].tests[1].params[2].m = 33190;
423*86d7f5d3SJohn Marino tests[6].tests[2].result = 0;
424*86d7f5d3SJohn Marino tests[6].tests[2].params[0].i = rel_fd;
425*86d7f5d3SJohn Marino tests[6].tests[2].params[1].cp = newdir;
426*86d7f5d3SJohn Marino tests[6].tests[2].params[2].m = 33190;
427*86d7f5d3SJohn Marino
428*86d7f5d3SJohn Marino // mkfifoat
429*86d7f5d3SJohn Marino tests[7].syscall = SYS_mkfifoat;
430*86d7f5d3SJohn Marino tests[7].num_of_cases = 3;
431*86d7f5d3SJohn Marino tests[7].name = "mkfifoat";
432*86d7f5d3SJohn Marino tests[7].tests[0].result = EBADF;
433*86d7f5d3SJohn Marino tests[7].tests[0].params[0].i = 107; // invalid fd
434*86d7f5d3SJohn Marino tests[7].tests[0].params[1].cp = relative_file;
435*86d7f5d3SJohn Marino tests[7].tests[0].params[2].m = 33190;
436*86d7f5d3SJohn Marino tests[7].tests[1].result = ENOTDIR;
437*86d7f5d3SJohn Marino tests[7].tests[1].params[0].i = notd_fd;
438*86d7f5d3SJohn Marino tests[7].tests[1].params[1].cp = relative_file;
439*86d7f5d3SJohn Marino tests[7].tests[1].params[2].m = 33190;
440*86d7f5d3SJohn Marino tests[7].tests[2].result = 0;
441*86d7f5d3SJohn Marino tests[7].tests[2].params[0].i = rel_fd;
442*86d7f5d3SJohn Marino tests[7].tests[2].params[1].cp = fifo;
443*86d7f5d3SJohn Marino tests[7].tests[2].params[2].m = 33190;
444*86d7f5d3SJohn Marino
445*86d7f5d3SJohn Marino // mknodat
446*86d7f5d3SJohn Marino tests[8].syscall = SYS_mknodat;
447*86d7f5d3SJohn Marino tests[8].num_of_cases = 3;
448*86d7f5d3SJohn Marino tests[8].name = "mknodat";
449*86d7f5d3SJohn Marino tests[8].tests[0].result = EBADF;
450*86d7f5d3SJohn Marino tests[8].tests[0].params[0].i = 108; // invalid fd
451*86d7f5d3SJohn Marino tests[8].tests[0].params[1].cp = relative_file;
452*86d7f5d3SJohn Marino tests[8].tests[0].params[2].m = 0666 | S_IFCHR;
453*86d7f5d3SJohn Marino tests[8].tests[0].params[3].d = 15;
454*86d7f5d3SJohn Marino tests[8].tests[1].result = ENOTDIR;
455*86d7f5d3SJohn Marino tests[8].tests[1].params[0].i = notd_fd;
456*86d7f5d3SJohn Marino tests[8].tests[1].params[1].cp = relative_file;
457*86d7f5d3SJohn Marino tests[8].tests[1].params[2].m = 0666 | S_IFCHR;
458*86d7f5d3SJohn Marino tests[8].tests[1].params[3].d = 15;
459*86d7f5d3SJohn Marino tests[8].tests[2].result = 0;
460*86d7f5d3SJohn Marino tests[8].tests[2].params[0].i = rel_fd;
461*86d7f5d3SJohn Marino tests[8].tests[2].params[1].cp = nod;
462*86d7f5d3SJohn Marino tests[8].tests[2].params[2].m = 0666 | S_IFCHR;
463*86d7f5d3SJohn Marino tests[8].tests[2].params[3].d = 2570;
464*86d7f5d3SJohn Marino
465*86d7f5d3SJohn Marino // openat
466*86d7f5d3SJohn Marino tests[9].syscall = SYS_openat;
467*86d7f5d3SJohn Marino tests[9].num_of_cases = 5;
468*86d7f5d3SJohn Marino tests[9].name = "openat";
469*86d7f5d3SJohn Marino tests[9].tests[0].result = EBADF;
470*86d7f5d3SJohn Marino tests[9].tests[0].params[0].i = 106; // invalid fd
471*86d7f5d3SJohn Marino tests[9].tests[0].params[1].cp = relative_file;
472*86d7f5d3SJohn Marino tests[9].tests[0].params[2].i = O_RDONLY;
473*86d7f5d3SJohn Marino tests[9].tests[0].params[3].i = 0666;
474*86d7f5d3SJohn Marino tests[9].tests[1].result = ENOTDIR;
475*86d7f5d3SJohn Marino tests[9].tests[1].params[0].i = notd_fd;
476*86d7f5d3SJohn Marino tests[9].tests[1].params[1].cp = relative_file;
477*86d7f5d3SJohn Marino tests[9].tests[1].params[2].i = O_RDONLY;
478*86d7f5d3SJohn Marino tests[9].tests[1].params[3].i = 0666;
479*86d7f5d3SJohn Marino tests[9].tests[2].result = 7; // hardcoded fd
480*86d7f5d3SJohn Marino tests[9].tests[2].params[0].i = rel_fd;
481*86d7f5d3SJohn Marino tests[9].tests[2].params[1].cp = file;
482*86d7f5d3SJohn Marino tests[9].tests[2].params[2].i = O_RDONLY;
483*86d7f5d3SJohn Marino tests[9].tests[2].params[3].i = 0400;
484*86d7f5d3SJohn Marino tests[9].tests[3].result = 8; // hardcoded fd
485*86d7f5d3SJohn Marino tests[9].tests[3].params[0].i = notd_fd;
486*86d7f5d3SJohn Marino tests[9].tests[3].params[1].cp = absolute_file;
487*86d7f5d3SJohn Marino tests[9].tests[3].params[2].i = O_RDONLY;
488*86d7f5d3SJohn Marino tests[9].tests[3].params[3].i = 0400;
489*86d7f5d3SJohn Marino tests[9].tests[4].result = 9; // hardcoded fd
490*86d7f5d3SJohn Marino tests[9].tests[4].params[0].i = rel_fd;
491*86d7f5d3SJohn Marino tests[9].tests[4].params[1].cp = newfile;
492*86d7f5d3SJohn Marino tests[9].tests[4].params[2].i = O_RDONLY | O_CREAT;
493*86d7f5d3SJohn Marino tests[9].tests[4].params[3].i = 0666;
494*86d7f5d3SJohn Marino
495*86d7f5d3SJohn Marino // readlinkat
496*86d7f5d3SJohn Marino tests[10].syscall = SYS_readlinkat;
497*86d7f5d3SJohn Marino tests[10].num_of_cases = 3;
498*86d7f5d3SJohn Marino tests[10].name = "readlinkat";
499*86d7f5d3SJohn Marino tests[10].tests[0].result = EBADF;
500*86d7f5d3SJohn Marino tests[10].tests[0].params[0].i = 106; // invalid fd
501*86d7f5d3SJohn Marino tests[10].tests[0].params[1].cp = relative_file;
502*86d7f5d3SJohn Marino tests[10].tests[0].params[2].vp = cbuf;
503*86d7f5d3SJohn Marino tests[10].tests[0].params[3].i = PATH_MAX;
504*86d7f5d3SJohn Marino tests[10].tests[1].result = ENOTDIR;
505*86d7f5d3SJohn Marino tests[10].tests[1].params[0].i = notd_fd;
506*86d7f5d3SJohn Marino tests[10].tests[1].params[1].cp = relative_file;
507*86d7f5d3SJohn Marino tests[10].tests[1].params[2].vp = cbuf;
508*86d7f5d3SJohn Marino tests[10].tests[1].params[3].i = PATH_MAX;
509*86d7f5d3SJohn Marino tests[10].tests[2].result = strlen(absolute_file);
510*86d7f5d3SJohn Marino tests[10].tests[2].params[0].i = AT_FDCWD;
511*86d7f5d3SJohn Marino tests[10].tests[2].params[1].cp = symlinkf;
512*86d7f5d3SJohn Marino tests[10].tests[2].params[2].vp = cbuf;
513*86d7f5d3SJohn Marino tests[10].tests[2].params[3].i = PATH_MAX;
514*86d7f5d3SJohn Marino
515*86d7f5d3SJohn Marino // renameat
516*86d7f5d3SJohn Marino tests[11].syscall = SYS_renameat;
517*86d7f5d3SJohn Marino tests[11].num_of_cases = 5;
518*86d7f5d3SJohn Marino tests[11].name = "renameat";
519*86d7f5d3SJohn Marino tests[11].tests[0].result = EBADF;
520*86d7f5d3SJohn Marino tests[11].tests[0].params[0].i = 106; // invalid fd
521*86d7f5d3SJohn Marino tests[11].tests[0].params[1].cp = file;
522*86d7f5d3SJohn Marino tests[11].tests[0].params[2].i = rel_fd;
523*86d7f5d3SJohn Marino tests[11].tests[0].params[3].cp = file;
524*86d7f5d3SJohn Marino tests[11].tests[1].result = EBADF;
525*86d7f5d3SJohn Marino tests[11].tests[1].params[0].i = rel_fd;
526*86d7f5d3SJohn Marino tests[11].tests[1].params[1].cp = file;
527*86d7f5d3SJohn Marino tests[11].tests[1].params[2].i = 106; // invalid fd
528*86d7f5d3SJohn Marino tests[11].tests[1].params[3].cp = file;
529*86d7f5d3SJohn Marino tests[11].tests[2].result = ENOTDIR;
530*86d7f5d3SJohn Marino tests[11].tests[2].params[0].i = notd_fd;
531*86d7f5d3SJohn Marino tests[11].tests[2].params[1].cp = relative_file;
532*86d7f5d3SJohn Marino tests[11].tests[2].params[2].i = rel_fd;
533*86d7f5d3SJohn Marino tests[11].tests[2].params[3].cp = file;
534*86d7f5d3SJohn Marino tests[11].tests[3].result = ENOTDIR;
535*86d7f5d3SJohn Marino tests[11].tests[3].params[0].i = rel_fd;
536*86d7f5d3SJohn Marino tests[11].tests[3].params[1].cp = file;
537*86d7f5d3SJohn Marino tests[11].tests[3].params[2].i = notd_fd;
538*86d7f5d3SJohn Marino tests[11].tests[3].params[3].cp = relative_file;
539*86d7f5d3SJohn Marino tests[11].tests[4].result = 0;
540*86d7f5d3SJohn Marino tests[11].tests[4].params[0].i = rel_fd;
541*86d7f5d3SJohn Marino tests[11].tests[4].params[1].cp = newfile;
542*86d7f5d3SJohn Marino tests[11].tests[4].params[2].i = AT_FDCWD;
543*86d7f5d3SJohn Marino tests[11].tests[4].params[3].cp = newfile;
544*86d7f5d3SJohn Marino
545*86d7f5d3SJohn Marino // symlinkat
546*86d7f5d3SJohn Marino tests[12].syscall = SYS_symlinkat;
547*86d7f5d3SJohn Marino tests[12].num_of_cases = 3;
548*86d7f5d3SJohn Marino tests[12].name = "symlinkat";
549*86d7f5d3SJohn Marino tests[12].tests[0].result = EBADF;
550*86d7f5d3SJohn Marino tests[12].tests[0].params[0].cp = file;
551*86d7f5d3SJohn Marino tests[12].tests[0].params[1].i = 106; // invalid fd
552*86d7f5d3SJohn Marino tests[12].tests[0].params[2].cp = file;
553*86d7f5d3SJohn Marino tests[12].tests[1].result = ENOTDIR;
554*86d7f5d3SJohn Marino tests[12].tests[1].params[0].cp = file;
555*86d7f5d3SJohn Marino tests[12].tests[1].params[1].i = notd_fd;
556*86d7f5d3SJohn Marino tests[12].tests[1].params[2].cp = relative_file;
557*86d7f5d3SJohn Marino tests[12].tests[2].result = 0;
558*86d7f5d3SJohn Marino tests[12].tests[2].params[0].cp = absolute_file;
559*86d7f5d3SJohn Marino tests[12].tests[2].params[1].i = rel_fd;
560*86d7f5d3SJohn Marino tests[12].tests[2].params[2].cp = newslink;
561*86d7f5d3SJohn Marino
562*86d7f5d3SJohn Marino
563*86d7f5d3SJohn Marino // unlinkat
564*86d7f5d3SJohn Marino tests[13].syscall = SYS_unlinkat;
565*86d7f5d3SJohn Marino tests[13].num_of_cases = 7;
566*86d7f5d3SJohn Marino tests[13].name = "unlinkat";
567*86d7f5d3SJohn Marino tests[13].tests[0].result = EBADF;
568*86d7f5d3SJohn Marino tests[13].tests[0].params[0].i = 106; // invalid fd
569*86d7f5d3SJohn Marino tests[13].tests[0].params[1].cp = relative_file;
570*86d7f5d3SJohn Marino tests[13].tests[0].params[2].i = 0;
571*86d7f5d3SJohn Marino tests[13].tests[1].result = ENOTDIR;
572*86d7f5d3SJohn Marino tests[13].tests[1].params[0].i = notd_fd;
573*86d7f5d3SJohn Marino tests[13].tests[1].params[1].cp = relative_file;
574*86d7f5d3SJohn Marino tests[13].tests[1].params[2].i = 0;
575*86d7f5d3SJohn Marino tests[13].tests[2].result = EINVAL;
576*86d7f5d3SJohn Marino tests[13].tests[2].params[0].i = rel_fd;
577*86d7f5d3SJohn Marino tests[13].tests[2].params[1].cp = file;
578*86d7f5d3SJohn Marino tests[13].tests[2].params[2].i = 123; // invalid flag
579*86d7f5d3SJohn Marino tests[13].tests[3].result = ENOTDIR;
580*86d7f5d3SJohn Marino tests[13].tests[3].params[0].i = rel_fd;
581*86d7f5d3SJohn Marino tests[13].tests[3].params[1].cp = not_dir_path;
582*86d7f5d3SJohn Marino tests[13].tests[3].params[2].i = AT_REMOVEDIR;
583*86d7f5d3SJohn Marino tests[13].tests[4].result = ENOTEMPTY;
584*86d7f5d3SJohn Marino tests[13].tests[4].params[0].i = AT_FDCWD;
585*86d7f5d3SJohn Marino tests[13].tests[4].params[1].cp = relative_path;
586*86d7f5d3SJohn Marino tests[13].tests[4].params[2].i = AT_REMOVEDIR;
587*86d7f5d3SJohn Marino tests[13].tests[5].result = 0;
588*86d7f5d3SJohn Marino tests[13].tests[5].params[0].i = rel_fd;
589*86d7f5d3SJohn Marino tests[13].tests[5].params[1].cp = newdir;
590*86d7f5d3SJohn Marino tests[13].tests[5].params[2].i = AT_REMOVEDIR;
591*86d7f5d3SJohn Marino tests[13].tests[6].result = 0;
592*86d7f5d3SJohn Marino tests[13].tests[6].params[0].i = AT_FDCWD;
593*86d7f5d3SJohn Marino tests[13].tests[6].params[1].cp = newfile;
594*86d7f5d3SJohn Marino tests[13].tests[6].params[2].i = 0;
595*86d7f5d3SJohn Marino
596*86d7f5d3SJohn Marino
597*86d7f5d3SJohn Marino // fexecve
598*86d7f5d3SJohn Marino tests[14].syscall = SYS_fexecve;
599*86d7f5d3SJohn Marino tests[14].num_of_cases = 2;
600*86d7f5d3SJohn Marino tests[14].name = "fexecve";
601*86d7f5d3SJohn Marino tests[14].tests[0].result = EBADF;
602*86d7f5d3SJohn Marino tests[14].tests[0].params[0].i = 106; // invalid fd
603*86d7f5d3SJohn Marino tests[14].tests[0].params[1].cpp = pargv;
604*86d7f5d3SJohn Marino tests[14].tests[0].params[2].cpp = NULL;
605*86d7f5d3SJohn Marino // This is EXPECTED to execve /bin/date, so dont expect OK output
606*86d7f5d3SJohn Marino tests[14].tests[1].result = 0;
607*86d7f5d3SJohn Marino tests[14].tests[1].params[0].i = exec_fd;
608*86d7f5d3SJohn Marino tests[14].tests[1].params[1].cpp = pargv;
609*86d7f5d3SJohn Marino tests[14].tests[1].params[2].cpp = NULL;
610*86d7f5d3SJohn Marino }
611*86d7f5d3SJohn Marino
612*86d7f5d3SJohn Marino void
cleanup()613*86d7f5d3SJohn Marino cleanup()
614*86d7f5d3SJohn Marino {
615*86d7f5d3SJohn Marino int error;
616*86d7f5d3SJohn Marino
617*86d7f5d3SJohn Marino close(notd_fd);
618*86d7f5d3SJohn Marino close(rel_fd);
619*86d7f5d3SJohn Marino close(abs_fd);
620*86d7f5d3SJohn Marino
621*86d7f5d3SJohn Marino if (!file_exist) {
622*86d7f5d3SJohn Marino error = unlink("tmp/foo");
623*86d7f5d3SJohn Marino if (error) {
624*86d7f5d3SJohn Marino perror("unlink");
625*86d7f5d3SJohn Marino exit(0);
626*86d7f5d3SJohn Marino }
627*86d7f5d3SJohn Marino }
628*86d7f5d3SJohn Marino if (!dir_exist) {
629*86d7f5d3SJohn Marino error = rmdir(absolute_path);
630*86d7f5d3SJohn Marino if (error) {
631*86d7f5d3SJohn Marino perror("rmdir");
632*86d7f5d3SJohn Marino exit(0);
633*86d7f5d3SJohn Marino }
634*86d7f5d3SJohn Marino }
635*86d7f5d3SJohn Marino if (link_exist) {
636*86d7f5d3SJohn Marino error = unlink(symlinkf);
637*86d7f5d3SJohn Marino if (error) {
638*86d7f5d3SJohn Marino perror("unlink");
639*86d7f5d3SJohn Marino exit(0);
640*86d7f5d3SJohn Marino }
641*86d7f5d3SJohn Marino }
642*86d7f5d3SJohn Marino }
643*86d7f5d3SJohn Marino
644*86d7f5d3SJohn Marino void
setup_once()645*86d7f5d3SJohn Marino setup_once()
646*86d7f5d3SJohn Marino {
647*86d7f5d3SJohn Marino }
648*86d7f5d3SJohn Marino
649*86d7f5d3SJohn Marino int
main(int argc,char * argv[])650*86d7f5d3SJohn Marino main(int argc, char *argv[])
651*86d7f5d3SJohn Marino {
652*86d7f5d3SJohn Marino int i,j;
653*86d7f5d3SJohn Marino int error;
654*86d7f5d3SJohn Marino
655*86d7f5d3SJohn Marino setup();
656*86d7f5d3SJohn Marino
657*86d7f5d3SJohn Marino for (i = 0; i < NUM_OF_TESTS; i++) {
658*86d7f5d3SJohn Marino printf("\nTest: %s\n", tests[i].name);
659*86d7f5d3SJohn Marino for (j = 0; j < tests[i].num_of_cases; j++) {
660*86d7f5d3SJohn Marino error = syscall(tests[i].syscall,
661*86d7f5d3SJohn Marino tests[i].tests[j].params[0],
662*86d7f5d3SJohn Marino tests[i].tests[j].params[1],
663*86d7f5d3SJohn Marino tests[i].tests[j].params[2],
664*86d7f5d3SJohn Marino tests[i].tests[j].params[3],
665*86d7f5d3SJohn Marino tests[i].tests[j].params[4]);
666*86d7f5d3SJohn Marino if (error == 0) {
667*86d7f5d3SJohn Marino if (tests[i].tests[j].result == 0)
668*86d7f5d3SJohn Marino printf("#%i ... OK\n", j);
669*86d7f5d3SJohn Marino else {
670*86d7f5d3SJohn Marino printf("#%i ... BAD: ", j);
671*86d7f5d3SJohn Marino printf("expected %i, but got %i\n", tests[i].tests[j].result, error);
672*86d7f5d3SJohn Marino }
673*86d7f5d3SJohn Marino } else {
674*86d7f5d3SJohn Marino if (tests[i].tests[j].result == errno)
675*86d7f5d3SJohn Marino printf("#%i ... OK\n", j);
676*86d7f5d3SJohn Marino else {
677*86d7f5d3SJohn Marino if (error != tests[i].tests[j].result) {
678*86d7f5d3SJohn Marino printf("#%i ... BAD: ", j);
679*86d7f5d3SJohn Marino printf("expected %i, but got %i\n", tests[i].tests[j].result, error);
680*86d7f5d3SJohn Marino } else
681*86d7f5d3SJohn Marino printf("#%i ... OK\n", j);
682*86d7f5d3SJohn Marino }
683*86d7f5d3SJohn Marino }
684*86d7f5d3SJohn Marino
685*86d7f5d3SJohn Marino
686*86d7f5d3SJohn Marino }
687*86d7f5d3SJohn Marino }
688*86d7f5d3SJohn Marino
689*86d7f5d3SJohn Marino // cleanup();
690*86d7f5d3SJohn Marino
691*86d7f5d3SJohn Marino
692*86d7f5d3SJohn Marino return (0);
693*86d7f5d3SJohn Marino }
694