11 #include <sys/types.h>
15 static char testfile
[1024];
16 static char testfile2
[1024];
17 static char testdir
[1024];
18 static char testdir2
[1024];
19 static char subfile
[1024];
20 static char testname
[256];
21 static char testdata
[] = "abcdefghijklmnopqrstuvwxyz";
22 static char testdata2
[] = "1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
23 static const char *testdir_files
[] = { "f1", "f2", NULL
};
24 static char zerodata
[4096];
25 static int testdatalen
= sizeof(testdata
) - 1;
26 static int testdata2len
= sizeof(testdata2
) - 1;
27 static unsigned int testnum
= 1;
28 static unsigned int select_test
= 0;
29 static unsigned int skip_test
= 0;
31 #define MAX_ENTRIES 1024
33 static void test_perror(const char *func
, const char *msg
)
35 fprintf(stderr
, "%s %s() - %s: %s\n", testname
, func
, msg
,
39 static void test_error(const char *func
, const char *msg
, ...)
40 __attribute__ ((format (printf
, 2, 3)));
42 static void __start_test(const char *fmt
, ...)
43 __attribute__ ((format (printf
, 1, 2)));
45 static void test_error(const char *func
, const char *msg
, ...)
48 fprintf(stderr
, "%s %s() - ", testname
, func
);
50 vfprintf(stderr
, msg
, ap
);
52 fprintf(stderr
, "\n");
55 static void success(void)
57 fprintf(stderr
, "%s OK\n", testname
);
60 static void __start_test(const char *fmt
, ...)
64 n
= sprintf(testname
, "%3i [", testnum
++);
66 n
+= vsprintf(testname
+ n
, fmt
, ap
);
68 sprintf(testname
+ n
, "]");
71 #define start_test(msg, args...) { \
72 if ((select_test && testnum != select_test) || \
73 (testnum == skip_test)) { \
77 __start_test(msg, ##args); \
80 #define PERROR(msg) test_perror(__FUNCTION__, msg)
81 #define ERROR(msg, args...) test_error(__FUNCTION__, msg, ##args)
83 static int check_size(const char *path
, int len
)
86 int res
= stat(path
, &stbuf
);
91 if (stbuf
.st_size
!= len
) {
92 ERROR("length %u instead of %u", (int) stbuf
.st_size
,
99 static int fcheck_size(int fd
, int len
)
102 int res
= fstat(fd
, &stbuf
);
107 if (stbuf
.st_size
!= len
) {
108 ERROR("length %u instead of %u", (int) stbuf
.st_size
,
115 static int check_type(const char *path
, mode_t type
)
118 int res
= lstat(path
, &stbuf
);
123 if ((stbuf
.st_mode
& S_IFMT
) != type
) {
124 ERROR("type 0%o instead of 0%o", stbuf
.st_mode
& S_IFMT
, type
);
130 static int fcheck_type(int fd
, mode_t type
)
133 int res
= fstat(fd
, &stbuf
);
138 if ((stbuf
.st_mode
& S_IFMT
) != type
) {
139 ERROR("type 0%o instead of 0%o", stbuf
.st_mode
& S_IFMT
, type
);
145 static int check_mode(const char *path
, mode_t mode
)
148 int res
= lstat(path
, &stbuf
);
153 if ((stbuf
.st_mode
& 07777) != mode
) {
154 ERROR("mode 0%o instead of 0%o", stbuf
.st_mode
& 07777, mode
);
160 static int fcheck_mode(int fd
, mode_t mode
)
163 int res
= fstat(fd
, &stbuf
);
168 if ((stbuf
.st_mode
& 07777) != mode
) {
169 ERROR("mode 0%o instead of 0%o", stbuf
.st_mode
& 07777, mode
);
175 static int check_times(const char *path
, time_t atime
, time_t mtime
)
179 int res
= lstat(path
, &stbuf
);
184 if (stbuf
.st_atime
!= atime
) {
185 ERROR("atime %li instead of %li", stbuf
.st_atime
, atime
);
188 if (stbuf
.st_mtime
!= mtime
) {
189 ERROR("mtime %li instead of %li", stbuf
.st_mtime
, mtime
);
199 static int fcheck_times(int fd
, time_t atime
, time_t mtime
)
203 int res
= fstat(fd
, &stbuf
);
208 if (stbuf
.st_atime
!= atime
) {
209 ERROR("atime %li instead of %li", stbuf
.st_atime
, atime
);
212 if (stbuf
.st_mtime
!= mtime
) {
213 ERROR("mtime %li instead of %li", stbuf
.st_mtime
, mtime
);
223 static int check_nlink(const char *path
, nlink_t nlink
)
226 int res
= lstat(path
, &stbuf
);
231 if (stbuf
.st_nlink
!= nlink
) {
232 ERROR("nlink %li instead of %li", (long) stbuf
.st_nlink
,
239 static int fcheck_nlink(int fd
, nlink_t nlink
)
242 int res
= fstat(fd
, &stbuf
);
247 if (stbuf
.st_nlink
!= nlink
) {
248 ERROR("nlink %li instead of %li", (long) stbuf
.st_nlink
,
255 static int check_nonexist(const char *path
)
258 int res
= lstat(path
, &stbuf
);
260 ERROR("file should not exist");
263 if (errno
!= ENOENT
) {
264 ERROR("file should not exist: %s", strerror(errno
));
270 static int check_buffer(const char *buf
, const char *data
, unsigned len
)
272 if (memcmp(buf
, data
, len
) != 0) {
273 ERROR("data mismatch");
279 static int check_data(const char *path
, const char *data
, int offset
,
284 int fd
= open(path
, O_RDONLY
);
289 if (lseek(fd
, offset
, SEEK_SET
) == (off_t
) -1) {
295 int rdlen
= len
< sizeof(buf
) ? len
: sizeof(buf
);
296 res
= read(fd
, buf
, rdlen
);
303 ERROR("short read: %u instead of %u", res
, rdlen
);
307 if (check_buffer(buf
, data
, rdlen
) != 0) {
322 static int fcheck_data(int fd
, const char *data
, int offset
,
327 if (lseek(fd
, offset
, SEEK_SET
) == (off_t
) -1) {
332 int rdlen
= len
< sizeof(buf
) ? len
: sizeof(buf
);
333 res
= read(fd
, buf
, rdlen
);
339 ERROR("short read: %u instead of %u", res
, rdlen
);
342 if (check_buffer(buf
, data
, rdlen
) != 0) {
351 static int check_dir_contents(const char *path
, const char **contents
)
356 int found
[MAX_ENTRIES
];
357 const char *cont
[MAX_ENTRIES
];
360 for (i
= 0; contents
[i
]; i
++) {
361 assert(i
< MAX_ENTRIES
- 3);
363 cont
[i
] = contents
[i
];
376 memset(found
, 0, sizeof(found
));
389 for (i
= 0; cont
[i
] != NULL
; i
++) {
390 assert(i
< MAX_ENTRIES
);
391 if (strcmp(cont
[i
], de
->d_name
) == 0) {
393 ERROR("duplicate entry <%s>",
402 ERROR("unexpected entry <%s>", de
->d_name
);
406 for (i
= 0; cont
[i
] != NULL
; i
++) {
408 ERROR("missing entry <%s>", cont
[i
]);
423 static int create_file(const char *path
, const char *data
, int len
)
429 fd
= creat(path
, 0644);
435 res
= write(fd
, data
, len
);
442 ERROR("write is short: %u instead of %u", res
, len
);
452 res
= check_type(path
, S_IFREG
);
455 res
= check_mode(path
, 0644);
458 res
= check_nlink(path
, 1);
461 res
= check_size(path
, len
);
466 res
= check_data(path
, data
, 0, len
);
474 static int cleanup_dir(const char *path
, const char **dir_files
, int quiet
)
479 for (i
= 0; dir_files
[i
]; i
++) {
482 sprintf(fpath
, "%s/%s", path
, dir_files
[i
]);
484 if (res
== -1 && !quiet
) {
495 static int create_dir(const char *path
, const char **dir_files
)
501 res
= mkdir(path
, 0755);
506 res
= check_type(path
, S_IFDIR
);
509 res
= check_mode(path
, 0755);
513 for (i
= 0; dir_files
[i
]; i
++) {
515 sprintf(fpath
, "%s/%s", path
, dir_files
[i
]);
516 res
= create_file(fpath
, "", 0);
518 cleanup_dir(path
, dir_files
, 1);
522 res
= check_dir_contents(path
, dir_files
);
524 cleanup_dir(path
, dir_files
, 1);
531 static int test_truncate(int len
)
533 const char *data
= testdata
;
534 int datalen
= testdatalen
;
537 start_test("truncate(%u)", (int) len
);
538 res
= create_file(testfile
, data
, datalen
);
542 res
= truncate(testfile
, len
);
547 res
= check_size(testfile
, len
);
552 if (len
<= datalen
) {
553 res
= check_data(testfile
, data
, 0, len
);
557 res
= check_data(testfile
, data
, 0, datalen
);
560 res
= check_data(testfile
, zerodata
, datalen
,
566 res
= unlink(testfile
);
571 res
= check_nonexist(testfile
);
579 static int test_ftruncate(int len
, int mode
)
581 const char *data
= testdata
;
582 int datalen
= testdatalen
;
586 start_test("ftruncate(%u) mode: 0%03o", len
, mode
);
587 res
= create_file(testfile
, data
, datalen
);
591 fd
= open(testfile
, O_WRONLY
);
597 res
= fchmod(fd
, mode
);
603 res
= check_mode(testfile
, mode
);
608 res
= ftruncate(fd
, len
);
615 res
= check_size(testfile
, len
);
620 if (len
<= datalen
) {
621 res
= check_data(testfile
, data
, 0, len
);
625 res
= check_data(testfile
, data
, 0, datalen
);
628 res
= check_data(testfile
, zerodata
, datalen
,
634 res
= unlink(testfile
);
639 res
= check_nonexist(testfile
);
647 static int test_utime(void)
650 time_t atime
= 987631200;
651 time_t mtime
= 123116400;
655 res
= create_file(testfile
, NULL
, 0);
661 res
= utime(testfile
, &utm
);
666 res
= check_times(testfile
, atime
, mtime
);
670 res
= unlink(testfile
);
675 res
= check_nonexist(testfile
);
683 static int test_create(void)
685 const char *data
= testdata
;
686 int datalen
= testdatalen
;
691 start_test("create");
693 fd
= creat(testfile
, 0644);
698 res
= write(fd
, data
, datalen
);
704 if (res
!= datalen
) {
705 ERROR("write is short: %u instead of %u", res
, datalen
);
714 res
= check_type(testfile
, S_IFREG
);
717 err
+= check_mode(testfile
, 0644);
718 err
+= check_nlink(testfile
, 1);
719 err
+= check_size(testfile
, datalen
);
720 err
+= check_data(testfile
, data
, 0, datalen
);
721 res
= unlink(testfile
);
726 res
= check_nonexist(testfile
);
736 static int test_create_unlink(void)
738 const char *data
= testdata
;
739 int datalen
= testdatalen
;
744 start_test("create+unlink");
746 fd
= open(testfile
, O_CREAT
| O_RDWR
| O_TRUNC
, 0644);
751 res
= unlink(testfile
);
757 res
= check_nonexist(testfile
);
760 res
= write(fd
, data
, datalen
);
766 if (res
!= datalen
) {
767 ERROR("write is short: %u instead of %u", res
, datalen
);
771 err
+= fcheck_type(fd
, S_IFREG
);
772 err
+= fcheck_mode(fd
, 0644);
773 err
+= fcheck_nlink(fd
, 0);
774 err
+= fcheck_size(fd
, datalen
);
775 err
+= fcheck_data(fd
, data
, 0, datalen
);
788 static int test_mknod(void)
795 res
= mknod(testfile
, 0644, 0);
800 res
= check_type(testfile
, S_IFREG
);
803 err
+= check_mode(testfile
, 0644);
804 err
+= check_nlink(testfile
, 1);
805 err
+= check_size(testfile
, 0);
806 res
= unlink(testfile
);
811 res
= check_nonexist(testfile
);
821 #define test_open(exist, flags, mode) do_test_open(exist, flags, #flags, mode)
823 static int do_test_open(int exist
, int flags
, const char *flags_str
, int mode
)
826 const char *data
= testdata
;
827 int datalen
= testdatalen
;
828 unsigned currlen
= 0;
834 start_test("open(%s, %s, 0%03o)", exist
? "+" : "-", flags_str
, mode
);
837 res
= create_file(testfile
, testdata2
, testdata2len
);
841 currlen
= testdata2len
;
844 fd
= open(testfile
, flags
, mode
);
845 if ((flags
& O_CREAT
) && (flags
& O_EXCL
) && exist
) {
847 ERROR("open should have failed");
850 } else if (errno
== EEXIST
)
853 if (!(flags
& O_CREAT
) && !exist
) {
855 ERROR("open should have failed");
858 } else if (errno
== ENOENT
)
869 err
+= check_type(testfile
, S_IFREG
);
871 err
+= check_mode(testfile
, 0644);
873 err
+= check_mode(testfile
, mode
);
874 err
+= check_nlink(testfile
, 1);
875 err
+= check_size(testfile
, currlen
);
876 if (exist
&& !(flags
& O_TRUNC
) && (mode
& 0400))
877 err
+= check_data(testfile
, testdata2
, 0, testdata2len
);
879 res
= write(fd
, data
, datalen
);
880 if ((flags
& O_ACCMODE
) != O_RDONLY
) {
884 } else if (res
!= datalen
) {
885 ERROR("write is short: %u instead of %u", res
, datalen
);
888 if (datalen
> (int) currlen
)
891 err
+= check_size(testfile
, currlen
);
894 err
+= check_data(testfile
, data
, 0, datalen
);
895 if (exist
&& !(flags
& O_TRUNC
) &&
896 testdata2len
> datalen
)
897 err
+= check_data(testfile
,
900 testdata2len
- datalen
);
905 ERROR("write should have failed");
907 } else if (errno
!= EBADF
) {
912 off
= lseek(fd
, SEEK_SET
, 0);
913 if (off
== (off_t
) -1) {
916 } else if (off
!= 0) {
917 ERROR("offset should have returned 0");
920 res
= read(fd
, buf
, sizeof(buf
));
921 if ((flags
& O_ACCMODE
) != O_WRONLY
) {
927 currlen
< sizeof(buf
) ? currlen
: sizeof(buf
);
928 if (res
!= readsize
) {
929 ERROR("read is short: %i instead of %u",
933 if ((flags
& O_ACCMODE
) != O_RDONLY
) {
934 err
+= check_buffer(buf
, data
, datalen
);
935 if (exist
&& !(flags
& O_TRUNC
) &&
936 testdata2len
> datalen
)
937 err
+= check_buffer(buf
+ datalen
,
939 testdata2len
- datalen
);
941 err
+= check_buffer(buf
, testdata2
,
947 ERROR("read should have failed");
949 } else if (errno
!= EBADF
) {
960 res
= unlink(testfile
);
965 res
= check_nonexist(testfile
);
976 #define test_open_acc(flags, mode, err) \
977 do_test_open_acc(flags, #flags, mode, err)
979 static int do_test_open_acc(int flags
, const char *flags_str
, int mode
, int err
)
981 const char *data
= testdata
;
982 int datalen
= testdatalen
;
986 start_test("open_acc(%s) mode: 0%03o error: '%s'", flags_str
, mode
,
989 res
= create_file(testfile
, data
, datalen
);
993 res
= chmod(testfile
, mode
);
999 res
= check_mode(testfile
, mode
);
1003 fd
= open(testfile
, flags
);
1011 ERROR("open should have failed");
1021 static int test_symlink(void)
1024 const char *data
= testdata
;
1025 int datalen
= testdatalen
;
1026 int linklen
= strlen(testfile
);
1030 start_test("symlink");
1031 res
= create_file(testfile
, data
, datalen
);
1036 res
= symlink(testfile
, testfile2
);
1041 res
= check_type(testfile2
, S_IFLNK
);
1044 err
+= check_mode(testfile2
, 0777);
1045 err
+= check_nlink(testfile2
, 1);
1046 res
= readlink(testfile2
, buf
, sizeof(buf
));
1051 if (res
!= linklen
) {
1052 ERROR("short readlink: %u instead of %u", res
, linklen
);
1055 if (memcmp(buf
, testfile
, linklen
) != 0) {
1056 ERROR("link mismatch");
1059 err
+= check_size(testfile2
, datalen
);
1060 err
+= check_data(testfile2
, data
, 0, datalen
);
1061 res
= unlink(testfile2
);
1066 res
= check_nonexist(testfile2
);
1076 static int test_link(void)
1078 const char *data
= testdata
;
1079 int datalen
= testdatalen
;
1084 res
= create_file(testfile
, data
, datalen
);
1089 res
= link(testfile
, testfile2
);
1094 res
= check_type(testfile2
, S_IFREG
);
1097 err
+= check_mode(testfile2
, 0644);
1098 err
+= check_nlink(testfile2
, 2);
1099 err
+= check_size(testfile2
, datalen
);
1100 err
+= check_data(testfile2
, data
, 0, datalen
);
1101 res
= unlink(testfile
);
1106 res
= check_nonexist(testfile
);
1110 err
+= check_nlink(testfile2
, 1);
1111 res
= unlink(testfile2
);
1116 res
= check_nonexist(testfile2
);
1126 static int test_link2(void)
1128 const char *data
= testdata
;
1129 int datalen
= testdatalen
;
1133 start_test("link-unlink-link");
1134 res
= create_file(testfile
, data
, datalen
);
1139 res
= link(testfile
, testfile2
);
1144 res
= unlink(testfile
);
1149 res
= check_nonexist(testfile
);
1152 res
= link(testfile2
, testfile
);
1156 res
= check_type(testfile
, S_IFREG
);
1159 err
+= check_mode(testfile
, 0644);
1160 err
+= check_nlink(testfile
, 2);
1161 err
+= check_size(testfile
, datalen
);
1162 err
+= check_data(testfile
, data
, 0, datalen
);
1164 res
= unlink(testfile2
);
1169 err
+= check_nlink(testfile
, 1);
1170 res
= unlink(testfile
);
1175 res
= check_nonexist(testfile
);
1185 static int test_rename_file(void)
1187 const char *data
= testdata
;
1188 int datalen
= testdatalen
;
1192 start_test("rename file");
1193 res
= create_file(testfile
, data
, datalen
);
1198 res
= rename(testfile
, testfile2
);
1203 res
= check_nonexist(testfile
);
1206 res
= check_type(testfile2
, S_IFREG
);
1209 err
+= check_mode(testfile2
, 0644);
1210 err
+= check_nlink(testfile2
, 1);
1211 err
+= check_size(testfile2
, datalen
);
1212 err
+= check_data(testfile2
, data
, 0, datalen
);
1213 res
= unlink(testfile2
);
1218 res
= check_nonexist(testfile2
);
1228 static int test_rename_dir(void)
1233 start_test("rename dir");
1234 res
= create_dir(testdir
, testdir_files
);
1239 res
= rename(testdir
, testdir2
);
1242 cleanup_dir(testdir
, testdir_files
, 1);
1245 res
= check_nonexist(testdir
);
1247 cleanup_dir(testdir
, testdir_files
, 1);
1250 res
= check_type(testdir2
, S_IFDIR
);
1252 cleanup_dir(testdir2
, testdir_files
, 1);
1255 err
+= check_mode(testdir2
, 0755);
1256 err
+= check_dir_contents(testdir2
, testdir_files
);
1257 err
+= cleanup_dir(testdir2
, testdir_files
, 0);
1258 res
= rmdir(testdir2
);
1263 res
= check_nonexist(testdir2
);
1273 static int test_mkfifo(void)
1278 start_test("mkfifo");
1280 res
= mkfifo(testfile
, 0644);
1285 res
= check_type(testfile
, S_IFIFO
);
1288 err
+= check_mode(testfile
, 0644);
1289 err
+= check_nlink(testfile
, 1);
1290 res
= unlink(testfile
);
1295 res
= check_nonexist(testfile
);
1305 static int test_mkdir(void)
1309 const char *dir_contents
[] = {NULL
};
1311 start_test("mkdir");
1313 res
= mkdir(testdir
, 0755);
1318 res
= check_type(testdir
, S_IFDIR
);
1321 err
+= check_mode(testdir
, 0755);
1322 err
+= check_nlink(testdir
, 2);
1323 err
+= check_dir_contents(testdir
, dir_contents
);
1324 res
= rmdir(testdir
);
1329 res
= check_nonexist(testdir
);
1339 #define test_create_ro_dir(flags) \
1340 do_test_create_ro_dir(flags, #flags)
1342 static int do_test_create_ro_dir(int flags
, const char *flags_str
)
1348 start_test("open(%s) in read-only directory", flags_str
);
1350 res
= mkdir(testdir
, 0555);
1355 fd
= open(subfile
, flags
, 0644);
1359 ERROR("open should have failed");
1362 res
= check_nonexist(subfile
);
1367 res
= rmdir(testdir
);
1372 res
= check_nonexist(testdir
);
1382 int main(int argc
, char *argv
[])
1384 const char *basepath
;
1388 if (argc
< 2 || argc
> 3) {
1389 fprintf(stderr
, "usage: %s testdir [test#]\n", argv
[0]);
1395 char *arg
= argv
[2];
1396 if (arg
[0] == '-') {
1398 skip_test
= strtoul(arg
, &endptr
, 10);
1400 select_test
= strtoul(argv
[2], &endptr
, 10);
1402 if (arg
[0] == '\0' || *endptr
!= '\0') {
1403 fprintf(stderr
, "invalid number: '%s'\n", arg
);
1407 assert(strlen(basepath
) < 512);
1408 if (basepath
[0] != '/') {
1409 fprintf(stderr
, "testdir must be an absolute path\n");
1413 sprintf(testfile
, "%s/testfile", basepath
);
1414 sprintf(testfile2
, "%s/testfile2", basepath
);
1415 sprintf(testdir
, "%s/testdir", basepath
);
1416 sprintf(testdir2
, "%s/testdir2", basepath
);
1417 sprintf(subfile
, "%s/subfile", testdir2
);
1418 err
+= test_create();
1419 err
+= test_create_unlink();
1420 err
+= test_mknod();
1421 err
+= test_symlink();
1423 err
+= test_link2();
1424 err
+= test_mkfifo();
1425 err
+= test_mkdir();
1426 err
+= test_rename_file();
1427 err
+= test_rename_dir();
1428 err
+= test_utime();
1429 err
+= test_truncate(0);
1430 err
+= test_truncate(testdatalen
/ 2);
1431 err
+= test_truncate(testdatalen
);
1432 err
+= test_truncate(testdatalen
+ 100);
1433 err
+= test_ftruncate(0, 0600);
1434 err
+= test_ftruncate(testdatalen
/ 2, 0600);
1435 err
+= test_ftruncate(testdatalen
, 0600);
1436 err
+= test_ftruncate(testdatalen
+ 100, 0600);
1437 err
+= test_ftruncate(0, 0400);
1438 err
+= test_ftruncate(0, 0200);
1439 err
+= test_ftruncate(0, 0000);
1440 err
+= test_open(0, O_RDONLY
, 0);
1441 err
+= test_open(1, O_RDONLY
, 0);
1442 err
+= test_open(1, O_RDWR
, 0);
1443 err
+= test_open(1, O_WRONLY
, 0);
1444 err
+= test_open(0, O_RDWR
| O_CREAT
, 0600);
1445 err
+= test_open(1, O_RDWR
| O_CREAT
, 0600);
1446 err
+= test_open(0, O_RDWR
| O_CREAT
| O_TRUNC
, 0600);
1447 err
+= test_open(1, O_RDWR
| O_CREAT
| O_TRUNC
, 0600);
1448 err
+= test_open(0, O_RDONLY
| O_CREAT
, 0600);
1449 err
+= test_open(0, O_RDONLY
| O_CREAT
, 0400);
1450 err
+= test_open(0, O_RDONLY
| O_CREAT
, 0200);
1451 err
+= test_open(0, O_RDONLY
| O_CREAT
, 0000);
1452 err
+= test_open(0, O_WRONLY
| O_CREAT
, 0600);
1453 err
+= test_open(0, O_WRONLY
| O_CREAT
, 0400);
1454 err
+= test_open(0, O_WRONLY
| O_CREAT
, 0200);
1455 err
+= test_open(0, O_WRONLY
| O_CREAT
, 0000);
1456 err
+= test_open(0, O_RDWR
| O_CREAT
, 0400);
1457 err
+= test_open(0, O_RDWR
| O_CREAT
, 0200);
1458 err
+= test_open(0, O_RDWR
| O_CREAT
, 0000);
1459 err
+= test_open(0, O_RDWR
| O_CREAT
| O_EXCL
, 0600);
1460 err
+= test_open(1, O_RDWR
| O_CREAT
| O_EXCL
, 0600);
1461 err
+= test_open(0, O_RDWR
| O_CREAT
| O_EXCL
, 0000);
1462 err
+= test_open(1, O_RDWR
| O_CREAT
| O_EXCL
, 0000);
1463 err
+= test_open_acc(O_RDONLY
, 0600, 0);
1464 err
+= test_open_acc(O_WRONLY
, 0600, 0);
1465 err
+= test_open_acc(O_RDWR
, 0600, 0);
1466 err
+= test_open_acc(O_RDONLY
, 0400, 0);
1467 err
+= test_open_acc(O_RDONLY
| O_TRUNC
, 0400, EACCES
);
1468 err
+= test_open_acc(O_WRONLY
, 0400, EACCES
);
1469 err
+= test_open_acc(O_RDWR
, 0400, EACCES
);
1470 err
+= test_open_acc(O_RDONLY
, 0200, EACCES
);
1471 err
+= test_open_acc(O_WRONLY
, 0200, 0);
1472 err
+= test_open_acc(O_RDWR
, 0200, EACCES
);
1473 err
+= test_open_acc(O_RDONLY
, 0000, EACCES
);
1474 err
+= test_open_acc(O_WRONLY
, 0000, EACCES
);
1475 err
+= test_open_acc(O_RDWR
, 0000, EACCES
);
1476 err
+= test_create_ro_dir(O_CREAT
);
1477 err
+= test_create_ro_dir(O_CREAT
| O_EXCL
);
1478 err
+= test_create_ro_dir(O_CREAT
| O_WRONLY
);
1479 err
+= test_create_ro_dir(O_CREAT
| O_TRUNC
);
1487 fprintf(stderr
, "%i tests failed\n", -err
);