Lines Matching refs:nftw
25 * test.c - Test functions for nftw()
28 #include "nftw.h"
40 * A call to int nftw(const char *path, int (*fn)(const char *, const
53 fprintf(temp, "TEST: nftw() succeeds\n");
57 if ((ret = nftw("./tmp/data/dirh", test_func1, MAX_FD, 0)) == -1) {
58 perror("ERROR: nftw failed");
102 * A call to int nftw(const char *path, int (*fn)(const char *, const
114 "TEST: nftw with FTW_PHYS does not follow symbolic links\n");
118 if ((ret = nftw("./tmp/data/dirl", test_func1, MAX_FD, FTW_PHYS))
120 perror("nftw");
132 "ERROR: Expected %d files to be visited. nftw() visited %d\n",
146 * A call to int nftw(const char *path, int (*fn)(const char *, const
157 fprintf(temp, "TEST: nftw without FTW_PHYS follows symbolic links\n");
162 if ((ret = nftw("./tmp/data/dirl", test_func3, MAX_FD, 0)) == -1) {
163 perror("nftw");
174 "ERROR: Expected %d files to be visited. nftw() visited %d\n",
183 * A call to int nftw(const char *path, int (*fn)(const char *, const
199 if ((ret_val = nftw(path, test_func4, MAX_FD, FTW_DEPTH)) == -1) {
200 perror("nftw");
219 * A call to int nftw(const char *path, int (*fn)(const char *, const
235 if ((ret_val = nftw(path, test_func4, MAX_FD, 0)) == -1) {
236 perror("nftw");
255 * A call to int nftw(const char *path, int (*fn)(const char *, const
275 "TEST: nftw with FTW_CHDIR changes to each dir before reporting files in it\n");
278 ret_val = nftw(path, test_func5, MAX_FD, FTW_CHDIR);
280 perror("nftw");
292 * A call to int nftw(const char *path, int (*fn)(const char *, const
303 fprintf(temp, "TEST: nftw passes pathname as first argument to fn()\n");
306 if ((ret = nftw("./tmp/data/dirg", test_func7, MAX_FD, 0)) == -1) {
307 perror("nftw");
320 * A call to int nftw(const char *path, int (*fn)(const char *, const
332 "TEST: nftw passes stat struct as second argument to fn()\n");
335 if ((ret = nftw("./tmp/data/dirg", test_func8, MAX_FD, 0)) == -1) {
336 perror("nftw");
349 * A call to int nftw(const char *path, int (*fn)(const char *, const
361 "TEST: nftw passes FTW_F as third arg to fn() for files\n");
364 if ((ret = nftw("./tmp/data/dirg", test_func9, MAX_FD, FTW_PHYS)) == -1) {
365 perror("nftw");
378 * A call to int nftw(const char *path, int (*fn)(const char *, const
390 "TEST: nftw passes FTW_D as third arg to fn() when file is directory\n");
393 if ((ret = nftw("./tmp/data/dirg", test_func10, MAX_FD,
395 perror("nftw");
408 * A call to int nftw(const char *path, int (*fn)(const char *, const
424 "TEST: nftw passes FTW_DP when file is directory and subdirs already visited\n");
427 if ((ret = nftw("./tmp/data/dirg", test_func11, MAX_FD, FTW_DEPTH |
429 perror("nftw");
442 * A call to int nftw(const char *path, int (*fn)(const char *, const
454 "TEST: nftw wth FTW_PHYS passes FTW_SL when file is symlink\n");
457 if ((ret = nftw("./tmp/data/dirg", test_func12, MAX_FD,
459 perror("nftw");
472 * A call to int nftw(const char *path, int (*fn)(const char *, const
493 fprintf(temp, "TEST: nftw with FTW_PHYS passes FTW_SLN when file");
497 if ((ret = nftw("./tmp/data/dirg", test_func13, MAX_FD,
499 perror("nftw");
512 * A call to int nftw(const char *path, int (*fn)(const char *, const
524 "TEST: nftw passes FTW_DNR when file is directory that cannot be read\n");
527 if ((ret = nftw("./tmp/data/d333", test_func14, MAX_FD, 0)) == -1) {
528 perror("nftw");
541 * A call to int nftw(const char *path, int (*fn)(const char *, const
553 "TEST: nftw(path, fn, depth, FTW_PHYS) passes FTW_NS when dir unsearchable\n");
557 nftw("./tmp/data/d666", test_func15, MAX_FD, FTW_PHYS)) == -1) {
558 perror("nftw");
571 * A call to int nftw(const char *path, int (*fn)(const char *, const
593 fprintf(temp, "TEST: nftw with absolute pathname %s\n", path);
596 if ((s2 = nftw(path, test_func16, MAX_FD, 0)) == -1) {
597 perror("nftw");
609 fprintf(temp, "TEST: nftw with relative pathname %s\n", path);
612 if ((s2 = nftw(path, test_func16, MAX_FD, 0)) == -1) {
613 perror("nftw");
626 * A call to int nftw(const char *path, int (*fn)(const char *, const
639 fprintf(temp, "TEST: nftw with FTW_PHYS passes FTW_SL for symlink\n");
643 nftw("./tmp/data/dirl", test_func17, MAX_FD, FTW_PHYS)) == -1) {
644 perror("nftw");
649 fprintf(temp, "ERROR: nftw() failed to find symbolic link\n");
658 "TEST: nftw without FTW_PHYS does not pass FTW_SL for symlink\n");
661 if ((ret = nftw("./tmp/data/dirl", test_func17, MAX_FD, 0)) == -1) {
662 perror("nftw");
667 fprintf(temp, "ERROR: nftw() found symbolic link\n");
675 * A call to int nftw(const char *path, int (*fn)(const char *, const
690 fprintf(temp, "TEST: nftw with FTW_PHYS does not pass FTW_SLN\n");
693 if ((ret = nftw("./tmp/data/dirg", test_func18, MAX_FD,
695 perror("nftw");
700 fprintf(temp, "ERROR: nftw() passed FTW_SLN\n");
708 fprintf(temp, "TEST: nftw without FTW_PHYS passes FTW_SLN\n");
711 if ((ret = nftw("./tmp/data/dirg", test_func18, MAX_FD, 0)) == -1) {
712 perror("nftw");
722 fprintf(temp, "ERROR: nftw passed FTW_SLN but did");
728 fprintf(temp, "ERROR: nftw() did not pass FTW_SLN\n");
736 * On a call to int nftw(const char *path, int (*fn)(const char *, const
753 ret_val = nftw("./tmp/data/d333", test_func19, MAX_FD, 0);
755 perror("nftw");
779 * A call to int nftw(const char *path, int (*fn)(const char *, const
805 if (nftw("./tmp/data/dirh", test_func20, 1, 0) == -1) {
806 perror("nftw");
819 "nftw did not close all file descriptors used in traversal\n",
834 * On a call to int nftw(const char *path, int (*fn)(const char *, const
876 ret_val = nftw(path, test_func21, 1, 0);
878 perror("nftw");
891 * A call to int nftw(const char *path, int (*fn)(const char *, const
924 ret_val = nftw(path, test_func22, MAX_FD, 0);
927 perror("nftw");
940 * A call to int nftw(const char *path, int (*fn)(const char *, const
954 "TEST: The function nftw should return with value set by fn\n");
958 nftw("./tmp/data/dirh", test_func23, MAX_FD, FTW_PHYS)) == -1) {
959 perror("nftw");
966 "ERROR: nftw did not return value returned by fn()\n");
972 "ERROR: nftw() did not return immediately on non-zero fn() return\n");
980 * ENAMETOOLONG in errno and return -1 on a call to int nftw(const char
987 test_ENAMETOOLONG_path("nftw", callback, -1);
992 * ENAMETOOLONG in errno and return -1 on a call to int nftw(const char
999 test_ENAMETOOLONG_name("nftw", callback, -1);
1004 * ENOENT in errno and return -1 on a call to int nftw(const char *path,
1012 fprintf(temp, "TEST: [ENOENT] && -1 returned by nftw\n");
1015 test_ENOENT_nofile("nftw", callback, -1);
1020 * ENOENT in errno and return -1 on a call to int nftw(const char *path,
1028 fprintf(temp, "TEST: The function nftw should return with a -1\n");
1031 test_ENOENT_empty("nftw", callback, -1);
1036 * ENOTDIR in errno and return -1 on a call to int nftw(const char
1044 fprintf(temp, "TEST: [ENOTDIR] && -1 returned by nftw\n");
1047 test_ENOTDIR("nftw", callback, -1);
1052 * EACCES in errno and return -1 on a call to int nftw(const char *path,
1066 fprintf(temp, "TEST: [EACCES] && -1 returned by nftw\n");
1069 test_ENOTDIR("nftw", callback, -1);
1074 * EACCES in errno and return -1 on a call to int nftw(const char *path,
1087 fprintf(temp, "TEST: [EACCES] && -1 returned by nftw\n");
1089 test_ENOTDIR("nftw", callback, -1);