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];
21 static char testfile_r[1024];
22 static char testfile2_r[1024];
23 static char testdir_r[1024];
24 static char testdir2_r[1024];
25 static char subfile_r[1024];
27 static char testname[256];
28 static char testdata[] =
"abcdefghijklmnopqrstuvwxyz";
29 static char testdata2[] =
"1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
30 static const char *testdir_files[] = {
"f1",
"f2", NULL};
31 static long seekdir_offsets[4];
32 static char zerodata[4096];
33 static int testdatalen =
sizeof(testdata) - 1;
34 static int testdata2len =
sizeof(testdata2) - 1;
35 static unsigned int testnum = 1;
36 static unsigned int select_test = 0;
37 static unsigned int skip_test = 0;
39 #define MAX_ENTRIES 1024 41 static void test_perror(
const char *func,
const char *msg)
43 fprintf(stderr,
"%s %s() - %s: %s\n", testname, func, msg,
47 static void test_error(
const char *func,
const char *msg, ...)
48 __attribute__ ((format (printf, 2, 3)));
50 static
void __start_test(const
char *fmt, ...)
51 __attribute__ ((format (printf, 1, 2)));
53 static
void test_error(const
char *func, const
char *msg, ...)
56 fprintf(stderr,
"%s %s() - ", testname, func);
58 vfprintf(stderr, msg, ap);
60 fprintf(stderr,
"\n");
63 static void success(
void)
65 fprintf(stderr,
"%s OK\n", testname);
68 static void __start_test(
const char *fmt, ...)
72 n = sprintf(testname,
"%3i [", testnum++);
74 n += vsprintf(testname + n, fmt, ap);
76 sprintf(testname + n,
"]");
79 #define start_test(msg, args...) { \ 80 if ((select_test && testnum != select_test) || \ 81 (testnum == skip_test)) { \ 85 __start_test(msg, ##args); \ 88 #define PERROR(msg) test_perror(__FUNCTION__, msg) 89 #define ERROR(msg, args...) test_error(__FUNCTION__, msg, ##args) 91 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 93 static int check_size(
const char *path,
int len)
96 int res = stat(path, &stbuf);
101 if (stbuf.st_size != len) {
102 ERROR(
"length %u instead of %u", (
int) stbuf.st_size,
109 static int fcheck_size(
int fd,
int len)
112 int res = fstat(fd, &stbuf);
117 if (stbuf.st_size != len) {
118 ERROR(
"length %u instead of %u", (
int) stbuf.st_size,
125 static int check_type(
const char *path, mode_t type)
128 int res = lstat(path, &stbuf);
133 if ((stbuf.st_mode & S_IFMT) != type) {
134 ERROR(
"type 0%o instead of 0%o", stbuf.st_mode & S_IFMT, type);
140 static int fcheck_type(
int fd, mode_t type)
143 int res = fstat(fd, &stbuf);
148 if ((stbuf.st_mode & S_IFMT) != type) {
149 ERROR(
"type 0%o instead of 0%o", stbuf.st_mode & S_IFMT, type);
155 static int check_mode(
const char *path, mode_t mode)
158 int res = lstat(path, &stbuf);
163 if ((stbuf.st_mode & 07777) != mode) {
164 ERROR(
"mode 0%o instead of 0%o", stbuf.st_mode & 07777, mode);
170 static int fcheck_mode(
int fd, mode_t mode)
173 int res = fstat(fd, &stbuf);
178 if ((stbuf.st_mode & 07777) != mode) {
179 ERROR(
"mode 0%o instead of 0%o", stbuf.st_mode & 07777, mode);
185 static int check_times(
const char *path, time_t atime, time_t mtime)
189 int res = lstat(path, &stbuf);
194 if (stbuf.st_atime != atime) {
195 ERROR(
"atime %li instead of %li", stbuf.st_atime, atime);
198 if (stbuf.st_mtime != mtime) {
199 ERROR(
"mtime %li instead of %li", stbuf.st_mtime, mtime);
209 static int fcheck_times(
int fd, time_t atime, time_t mtime)
213 int res = fstat(fd, &stbuf);
218 if (stbuf.st_atime != atime) {
219 ERROR(
"atime %li instead of %li", stbuf.st_atime, atime);
222 if (stbuf.st_mtime != mtime) {
223 ERROR(
"mtime %li instead of %li", stbuf.st_mtime, mtime);
233 static int check_nlink(
const char *path, nlink_t nlink)
236 int res = lstat(path, &stbuf);
241 if (stbuf.st_nlink != nlink) {
242 ERROR(
"nlink %li instead of %li", (
long) stbuf.st_nlink,
249 static int fcheck_nlink(
int fd, nlink_t nlink)
252 int res = fstat(fd, &stbuf);
257 if (stbuf.st_nlink != nlink) {
258 ERROR(
"nlink %li instead of %li", (
long) stbuf.st_nlink,
265 static int check_nonexist(
const char *path)
268 int res = lstat(path, &stbuf);
270 ERROR(
"file should not exist");
273 if (errno != ENOENT) {
274 ERROR(
"file should not exist: %s", strerror(errno));
280 static int check_buffer(
const char *buf,
const char *data,
unsigned len)
282 if (memcmp(buf, data, len) != 0) {
283 ERROR(
"data mismatch");
289 static int check_data(
const char *path,
const char *data,
int offset,
294 int fd = open(path, O_RDONLY);
299 if (lseek(fd, offset, SEEK_SET) == (off_t) -1) {
305 int rdlen = len <
sizeof(buf) ? len :
sizeof(buf);
306 res = read(fd, buf, rdlen);
313 ERROR(
"short read: %u instead of %u", res, rdlen);
317 if (check_buffer(buf, data, rdlen) != 0) {
332 static int fcheck_data(
int fd,
const char *data,
int offset,
337 if (lseek(fd, offset, SEEK_SET) == (off_t) -1) {
342 int rdlen = len <
sizeof(buf) ? len :
sizeof(buf);
343 res = read(fd, buf, rdlen);
349 ERROR(
"short read: %u instead of %u", res, rdlen);
352 if (check_buffer(buf, data, rdlen) != 0) {
361 static int check_dir_contents(
const char *path,
const char **contents)
366 int found[MAX_ENTRIES];
367 const char *cont[MAX_ENTRIES];
370 for (i = 0; contents[i]; i++) {
371 assert(i < MAX_ENTRIES - 3);
373 cont[i] = contents[i];
386 memset(found, 0,
sizeof(found));
399 for (i = 0; cont[i] != NULL; i++) {
400 assert(i < MAX_ENTRIES);
401 if (strcmp(cont[i], de->d_name) == 0) {
403 ERROR(
"duplicate entry <%s>",
412 ERROR(
"unexpected entry <%s>", de->d_name);
416 for (i = 0; cont[i] != NULL; i++) {
418 ERROR(
"missing entry <%s>", cont[i]);
433 static int create_file(
const char *path,
const char *data,
int len)
439 fd = creat(path, 0644);
445 res = write(fd, data, len);
452 ERROR(
"write is short: %u instead of %u", res, len);
462 res = check_type(path, S_IFREG);
465 res = check_mode(path, 0644);
468 res = check_nlink(path, 1);
471 res = check_size(path, len);
476 res = check_data(path, data, 0, len);
484 static int cleanup_dir(
const char *path,
const char **dir_files,
int quiet)
489 for (i = 0; dir_files[i]; i++) {
492 sprintf(fpath,
"%s/%s", path, dir_files[i]);
494 if (res == -1 && !quiet) {
505 static int create_dir(
const char *path,
const char **dir_files)
511 res = mkdir(path, 0755);
516 res = check_type(path, S_IFDIR);
519 res = check_mode(path, 0755);
523 for (i = 0; dir_files[i]; i++) {
525 sprintf(fpath,
"%s/%s", path, dir_files[i]);
526 res = create_file(fpath,
"", 0);
528 cleanup_dir(path, dir_files, 1);
532 res = check_dir_contents(path, dir_files);
534 cleanup_dir(path, dir_files, 1);
541 static int test_truncate(
int len)
543 const char *data = testdata;
544 int datalen = testdatalen;
547 start_test(
"truncate(%u)", (
int) len);
548 res = create_file(testfile, data, datalen);
552 res = truncate(testfile, len);
557 res = check_size(testfile, len);
562 if (len <= datalen) {
563 res = check_data(testfile, data, 0, len);
567 res = check_data(testfile, data, 0, datalen);
570 res = check_data(testfile, zerodata, datalen,
576 res = unlink(testfile);
581 res = check_nonexist(testfile);
589 static int test_ftruncate(
int len,
int mode)
591 const char *data = testdata;
592 int datalen = testdatalen;
596 start_test(
"ftruncate(%u) mode: 0%03o", len, mode);
597 res = create_file(testfile, data, datalen);
601 fd = open(testfile, O_WRONLY);
607 res = fchmod(fd, mode);
613 res = check_mode(testfile, mode);
618 res = ftruncate(fd, len);
625 res = check_size(testfile, len);
630 if (len <= datalen) {
631 res = check_data(testfile, data, 0, len);
635 res = check_data(testfile, data, 0, datalen);
638 res = check_data(testfile, zerodata, datalen,
644 res = unlink(testfile);
649 res = check_nonexist(testfile);
657 static int test_seekdir(
void)
664 start_test(
"seekdir");
665 res = create_dir(testdir, testdir_files);
669 dp = opendir(testdir);
676 for (i = 0; i < ARRAY_SIZE(seekdir_offsets); i++) {
677 seekdir_offsets[i] = telldir(dp);
694 for (i--; i >= 0; i--) {
695 seekdir(dp, seekdir_offsets[i]);
698 ERROR(
"Unexpected end of directory after seekdir()");
704 res = cleanup_dir(testdir, testdir_files, 0);
710 cleanup_dir(testdir, testdir_files, 1);
714 static int test_utime(
void)
717 time_t atime = 987631200;
718 time_t mtime = 123116400;
722 res = create_file(testfile, NULL, 0);
728 res = utime(testfile, &utm);
733 res = check_times(testfile, atime, mtime);
737 res = unlink(testfile);
742 res = check_nonexist(testfile);
750 static int test_create(
void)
752 const char *data = testdata;
753 int datalen = testdatalen;
758 start_test(
"create");
760 fd = creat(testfile, 0644);
765 res = write(fd, data, datalen);
771 if (res != datalen) {
772 ERROR(
"write is short: %u instead of %u", res, datalen);
781 res = check_type(testfile, S_IFREG);
784 err += check_mode(testfile, 0644);
785 err += check_nlink(testfile, 1);
786 err += check_size(testfile, datalen);
787 err += check_data(testfile, data, 0, datalen);
788 res = unlink(testfile);
793 res = check_nonexist(testfile);
803 static int test_create_unlink(
void)
805 const char *data = testdata;
806 int datalen = testdatalen;
811 start_test(
"create+unlink");
813 fd = open(testfile, O_CREAT | O_RDWR | O_TRUNC, 0644);
818 res = unlink(testfile);
824 res = check_nonexist(testfile);
827 res = write(fd, data, datalen);
833 if (res != datalen) {
834 ERROR(
"write is short: %u instead of %u", res, datalen);
838 err += fcheck_type(fd, S_IFREG);
839 err += fcheck_mode(fd, 0644);
840 err += fcheck_nlink(fd, 0);
841 err += fcheck_size(fd, datalen);
842 err += fcheck_data(fd, data, 0, datalen);
856 static int test_mknod(
void)
863 res = mknod(testfile, 0644, 0);
868 res = check_type(testfile, S_IFREG);
871 err += check_mode(testfile, 0644);
872 err += check_nlink(testfile, 1);
873 err += check_size(testfile, 0);
874 res = unlink(testfile);
879 res = check_nonexist(testfile);
890 #define test_open(exist, flags, mode) do_test_open(exist, flags, #flags, mode) 892 static int do_test_open(
int exist,
int flags,
const char *flags_str,
int mode)
895 const char *data = testdata;
896 int datalen = testdatalen;
897 unsigned currlen = 0;
903 start_test(
"open(%s, %s, 0%03o)", exist ?
"+" :
"-", flags_str, mode);
906 res = create_file(testfile_r, testdata2, testdata2len);
910 currlen = testdata2len;
913 fd = open(testfile, flags, mode);
914 if ((flags & O_CREAT) && (flags & O_EXCL) && exist) {
916 ERROR(
"open should have failed");
919 }
else if (errno == EEXIST)
922 if (!(flags & O_CREAT) && !exist) {
924 ERROR(
"open should have failed");
927 }
else if (errno == ENOENT)
938 err += check_type(testfile, S_IFREG);
940 err += check_mode(testfile, 0644);
942 err += check_mode(testfile, mode);
943 err += check_nlink(testfile, 1);
944 err += check_size(testfile, currlen);
945 if (exist && !(flags & O_TRUNC) && (mode & 0400))
946 err += check_data(testfile, testdata2, 0, testdata2len);
948 res = write(fd, data, datalen);
949 if ((flags & O_ACCMODE) != O_RDONLY) {
953 }
else if (res != datalen) {
954 ERROR(
"write is short: %u instead of %u", res, datalen);
957 if (datalen > (
int) currlen)
960 err += check_size(testfile, currlen);
963 err += check_data(testfile, data, 0, datalen);
964 if (exist && !(flags & O_TRUNC) &&
965 testdata2len > datalen)
966 err += check_data(testfile,
969 testdata2len - datalen);
974 ERROR(
"write should have failed");
976 }
else if (errno != EBADF) {
981 off = lseek(fd, SEEK_SET, 0);
982 if (off == (off_t) -1) {
985 }
else if (off != 0) {
986 ERROR(
"offset should have returned 0");
989 res = read(fd, buf,
sizeof(buf));
990 if ((flags & O_ACCMODE) != O_WRONLY) {
996 currlen <
sizeof(buf) ? currlen :
sizeof(buf);
997 if (res != readsize) {
998 ERROR(
"read is short: %i instead of %u",
1002 if ((flags & O_ACCMODE) != O_RDONLY) {
1003 err += check_buffer(buf, data, datalen);
1004 if (exist && !(flags & O_TRUNC) &&
1005 testdata2len > datalen)
1006 err += check_buffer(buf + datalen,
1007 testdata2 + datalen,
1008 testdata2len - datalen);
1010 err += check_buffer(buf, testdata2,
1016 ERROR(
"read should have failed");
1018 }
else if (errno != EBADF) {
1029 res = unlink(testfile);
1034 res = check_nonexist(testfile);
1037 res = check_nonexist(testfile_r);
1048 #define test_open_acc(flags, mode, err) \ 1049 do_test_open_acc(flags, #flags, mode, err) 1051 static int do_test_open_acc(
int flags,
const char *flags_str,
int mode,
int err)
1053 const char *data = testdata;
1054 int datalen = testdatalen;
1058 start_test(
"open_acc(%s) mode: 0%03o message: '%s'", flags_str, mode,
1061 res = create_file(testfile, data, datalen);
1065 res = chmod(testfile, mode);
1071 res = check_mode(testfile, mode);
1075 fd = open(testfile, flags);
1083 ERROR(
"open should have failed");
1093 static int test_symlink(
void)
1096 const char *data = testdata;
1097 int datalen = testdatalen;
1098 int linklen = strlen(testfile);
1102 start_test(
"symlink");
1103 res = create_file(testfile, data, datalen);
1108 res = symlink(testfile, testfile2);
1113 res = check_type(testfile2, S_IFLNK);
1116 err += check_mode(testfile2, 0777);
1117 err += check_nlink(testfile2, 1);
1118 res = readlink(testfile2, buf,
sizeof(buf));
1123 if (res != linklen) {
1124 ERROR(
"short readlink: %u instead of %u", res, linklen);
1127 if (memcmp(buf, testfile, linklen) != 0) {
1128 ERROR(
"link mismatch");
1131 err += check_size(testfile2, datalen);
1132 err += check_data(testfile2, data, 0, datalen);
1133 res = unlink(testfile2);
1138 res = check_nonexist(testfile2);
1148 static int test_link(
void)
1150 const char *data = testdata;
1151 int datalen = testdatalen;
1156 res = create_file(testfile, data, datalen);
1161 res = link(testfile, testfile2);
1166 res = check_type(testfile2, S_IFREG);
1169 err += check_mode(testfile2, 0644);
1170 err += check_nlink(testfile2, 2);
1171 err += check_size(testfile2, datalen);
1172 err += check_data(testfile2, data, 0, datalen);
1173 res = unlink(testfile);
1178 res = check_nonexist(testfile);
1182 err += check_nlink(testfile2, 1);
1183 res = unlink(testfile2);
1188 res = check_nonexist(testfile2);
1198 static int test_link2(
void)
1200 const char *data = testdata;
1201 int datalen = testdatalen;
1205 start_test(
"link-unlink-link");
1206 res = create_file(testfile, data, datalen);
1211 res = link(testfile, testfile2);
1216 res = unlink(testfile);
1221 res = check_nonexist(testfile);
1224 res = link(testfile2, testfile);
1228 res = check_type(testfile, S_IFREG);
1231 err += check_mode(testfile, 0644);
1232 err += check_nlink(testfile, 2);
1233 err += check_size(testfile, datalen);
1234 err += check_data(testfile, data, 0, datalen);
1236 res = unlink(testfile2);
1241 err += check_nlink(testfile, 1);
1242 res = unlink(testfile);
1247 res = check_nonexist(testfile);
1257 static int test_rename_file(
void)
1259 const char *data = testdata;
1260 int datalen = testdatalen;
1264 start_test(
"rename file");
1265 res = create_file(testfile, data, datalen);
1270 res = rename(testfile, testfile2);
1275 res = check_nonexist(testfile);
1278 res = check_type(testfile2, S_IFREG);
1281 err += check_mode(testfile2, 0644);
1282 err += check_nlink(testfile2, 1);
1283 err += check_size(testfile2, datalen);
1284 err += check_data(testfile2, data, 0, datalen);
1285 res = unlink(testfile2);
1290 res = check_nonexist(testfile2);
1300 static int test_rename_dir(
void)
1305 start_test(
"rename dir");
1306 res = create_dir(testdir, testdir_files);
1311 res = rename(testdir, testdir2);
1314 cleanup_dir(testdir, testdir_files, 1);
1317 res = check_nonexist(testdir);
1319 cleanup_dir(testdir, testdir_files, 1);
1322 res = check_type(testdir2, S_IFDIR);
1324 cleanup_dir(testdir2, testdir_files, 1);
1327 err += check_mode(testdir2, 0755);
1328 err += check_dir_contents(testdir2, testdir_files);
1329 err += cleanup_dir(testdir2, testdir_files, 0);
1330 res = rmdir(testdir2);
1335 res = check_nonexist(testdir2);
1345 static int test_rename_dir_loop(
void)
1347 #define PATH(p) (snprintf(path, sizeof path, "%s/%s", testdir, p), path) 1348 #define PATH2(p) (snprintf(path2, sizeof path2, "%s/%s", testdir, p), path2) 1350 char path[1024], path2[1024];
1354 start_test(
"rename dir loop");
1356 res = create_dir(testdir, testdir_files);
1360 res = mkdir(PATH(
"a"), 0755);
1366 res = rename(PATH(
"a"), PATH2(
"a"));
1373 res = rename(PATH(
"a"), PATH2(
"a/b"));
1374 if (res == 0 || errno != EINVAL) {
1379 res = mkdir(PATH(
"a/b"), 0755);
1385 res = mkdir(PATH(
"a/b/c"), 0755);
1392 res = rename(PATH(
"a"), PATH2(
"a/b/c"));
1393 if (res == 0 || errno != EINVAL) {
1399 res = rename(PATH(
"a"), PATH2(
"a/b/c/a"));
1400 if (res == 0 || errno != EINVAL) {
1406 res = rename(PATH(
"a/b/c"), PATH2(
"a"));
1407 if (res == 0 || errno != ENOTEMPTY) {
1412 res = open(PATH(
"a/foo"), O_CREAT, 0644);
1419 res = rename(PATH(
"a/foo"), PATH2(
"a/bar"));
1425 res = rename(PATH(
"a/bar"), PATH2(
"a/foo"));
1431 res = rename(PATH(
"a/foo"), PATH2(
"a/b/bar"));
1437 res = rename(PATH(
"a/b/bar"), PATH2(
"a/foo"));
1443 res = rename(PATH(
"a/foo"), PATH2(
"a/b/c/bar"));
1449 res = rename(PATH(
"a/b/c/bar"), PATH2(
"a/foo"));
1455 res = open(PATH(
"a/bar"), O_CREAT, 0644);
1462 res = rename(PATH(
"a/foo"), PATH2(
"a/bar"));
1468 unlink(PATH(
"a/bar"));
1470 res = rename(PATH(
"a/b"), PATH2(
"a/d"));
1476 res = rename(PATH(
"a/d"), PATH2(
"a/b"));
1482 res = mkdir(PATH(
"a/d"), 0755);
1488 res = rename(PATH(
"a/b"), PATH2(
"a/d"));
1494 res = rename(PATH(
"a/d"), PATH2(
"a/b"));
1500 res = mkdir(PATH(
"a/d"), 0755);
1506 res = mkdir(PATH(
"a/d/e"), 0755);
1513 res = rename(PATH(
"a/b"), PATH2(
"a/d"));
1514 if (res == 0 || errno != ENOTEMPTY) {
1519 rmdir(PATH(
"a/d/e"));
1522 rmdir(PATH(
"a/b/c"));
1526 err += cleanup_dir(testdir, testdir_files, 0);
1527 res = rmdir(testdir);
1532 res = check_nonexist(testdir);
1542 unlink(PATH(
"a/bar"));
1544 rmdir(PATH(
"a/d/e"));
1547 rmdir(PATH(
"a/b/c"));
1551 cleanup_dir(testdir, testdir_files, 1);
1561 static int test_mkfifo(
void)
1566 start_test(
"mkfifo");
1568 res = mkfifo(testfile, 0644);
1573 res = check_type(testfile, S_IFIFO);
1576 err += check_mode(testfile, 0644);
1577 err += check_nlink(testfile, 1);
1578 res = unlink(testfile);
1583 res = check_nonexist(testfile);
1594 static int test_mkdir(
void)
1598 const char *dir_contents[] = {NULL};
1600 start_test(
"mkdir");
1602 res = mkdir(testdir, 0755);
1607 res = check_type(testdir, S_IFDIR);
1610 err += check_mode(testdir, 0755);
1614 err += check_dir_contents(testdir, dir_contents);
1615 res = rmdir(testdir);
1620 res = check_nonexist(testdir);
1630 #define test_create_ro_dir(flags) \ 1631 do_test_create_ro_dir(flags, #flags) 1633 static int do_test_create_ro_dir(
int flags,
const char *flags_str)
1639 start_test(
"open(%s) in read-only directory", flags_str);
1641 res = mkdir(testdir, 0555);
1646 fd = open(subfile, flags, 0644);
1650 ERROR(
"open should have failed");
1653 res = check_nonexist(subfile);
1658 res = rmdir(testdir);
1663 res = check_nonexist(testdir);
1673 int main(
int argc,
char *argv[])
1675 const char *basepath;
1676 const char *realpath;
1682 if (argc < 2 || argc > 4) {
1683 fprintf(stderr,
"usage: %s testdir [:realdir] [[-]test#]\n", argv[0]);
1687 realpath = basepath;
1688 for (a = 2; a < argc; a++) {
1690 char *arg = argv[a];
1691 if (arg[0] ==
':') {
1694 if (arg[0] ==
'-') {
1696 skip_test = strtoul(arg, &endptr, 10);
1698 select_test = strtoul(arg, &endptr, 10);
1700 if (arg[0] ==
'\0' || *endptr !=
'\0') {
1701 fprintf(stderr,
"invalid number: '%s'\n", arg);
1706 assert(strlen(basepath) < 512);
1707 assert(strlen(realpath) < 512);
1708 if (basepath[0] !=
'/') {
1709 fprintf(stderr,
"testdir must be an absolute path\n");
1713 sprintf(testfile,
"%s/testfile", basepath);
1714 sprintf(testfile2,
"%s/testfile2", basepath);
1715 sprintf(testdir,
"%s/testdir", basepath);
1716 sprintf(testdir2,
"%s/testdir2", basepath);
1717 sprintf(subfile,
"%s/subfile", testdir2);
1719 sprintf(testfile_r,
"%s/testfile", realpath);
1720 sprintf(testfile2_r,
"%s/testfile2", realpath);
1721 sprintf(testdir_r,
"%s/testdir", realpath);
1722 sprintf(testdir2_r,
"%s/testdir2", realpath);
1723 sprintf(subfile_r,
"%s/subfile", testdir2_r);
1725 is_root = (geteuid() == 0);
1727 err += test_create();
1728 err += test_create_unlink();
1729 err += test_symlink();
1731 err += test_link2();
1733 err += test_mknod();
1734 err += test_mkfifo();
1736 err += test_mkdir();
1737 err += test_rename_file();
1738 err += test_rename_dir();
1739 err += test_rename_dir_loop();
1740 err += test_seekdir();
1741 err += test_utime();
1742 err += test_truncate(0);
1743 err += test_truncate(testdatalen / 2);
1744 err += test_truncate(testdatalen);
1745 err += test_truncate(testdatalen + 100);
1746 err += test_ftruncate(0, 0600);
1747 err += test_ftruncate(testdatalen / 2, 0600);
1748 err += test_ftruncate(testdatalen, 0600);
1749 err += test_ftruncate(testdatalen + 100, 0600);
1750 err += test_ftruncate(0, 0400);
1751 err += test_ftruncate(0, 0200);
1752 err += test_ftruncate(0, 0000);
1753 err += test_open(0, O_RDONLY, 0);
1754 err += test_open(1, O_RDONLY, 0);
1755 err += test_open(1, O_RDWR, 0);
1756 err += test_open(1, O_WRONLY, 0);
1757 err += test_open(0, O_RDWR | O_CREAT, 0600);
1758 err += test_open(1, O_RDWR | O_CREAT, 0600);
1759 err += test_open(0, O_RDWR | O_CREAT | O_TRUNC, 0600);
1760 err += test_open(1, O_RDWR | O_CREAT | O_TRUNC, 0600);
1761 err += test_open(0, O_RDONLY | O_CREAT, 0600);
1762 err += test_open(0, O_RDONLY | O_CREAT, 0400);
1763 err += test_open(0, O_RDONLY | O_CREAT, 0200);
1764 err += test_open(0, O_RDONLY | O_CREAT, 0000);
1765 err += test_open(0, O_WRONLY | O_CREAT, 0600);
1766 err += test_open(0, O_WRONLY | O_CREAT, 0400);
1767 err += test_open(0, O_WRONLY | O_CREAT, 0200);
1768 err += test_open(0, O_WRONLY | O_CREAT, 0000);
1769 err += test_open(0, O_RDWR | O_CREAT, 0400);
1770 err += test_open(0, O_RDWR | O_CREAT, 0200);
1771 err += test_open(0, O_RDWR | O_CREAT, 0000);
1772 err += test_open(0, O_RDWR | O_CREAT | O_EXCL, 0600);
1773 err += test_open(1, O_RDWR | O_CREAT | O_EXCL, 0600);
1774 err += test_open(0, O_RDWR | O_CREAT | O_EXCL, 0000);
1775 err += test_open(1, O_RDWR | O_CREAT | O_EXCL, 0000);
1776 err += test_open_acc(O_RDONLY, 0600, 0);
1777 err += test_open_acc(O_WRONLY, 0600, 0);
1778 err += test_open_acc(O_RDWR, 0600, 0);
1779 err += test_open_acc(O_RDONLY, 0400, 0);
1780 err += test_open_acc(O_WRONLY, 0200, 0);
1782 err += test_open_acc(O_RDONLY | O_TRUNC, 0400, EACCES);
1783 err += test_open_acc(O_WRONLY, 0400, EACCES);
1784 err += test_open_acc(O_RDWR, 0400, EACCES);
1785 err += test_open_acc(O_RDONLY, 0200, EACCES);
1786 err += test_open_acc(O_RDWR, 0200, EACCES);
1787 err += test_open_acc(O_RDONLY, 0000, EACCES);
1788 err += test_open_acc(O_WRONLY, 0000, EACCES);
1789 err += test_open_acc(O_RDWR, 0000, EACCES);
1791 err += test_create_ro_dir(O_CREAT);
1792 err += test_create_ro_dir(O_CREAT | O_EXCL);
1793 err += test_create_ro_dir(O_CREAT | O_WRONLY);
1794 err += test_create_ro_dir(O_CREAT | O_TRUNC);
1802 fprintf(stderr,
"%i tests failed\n", -err);