From b998993162eaa52275c40da110919b6bd58acf89 Mon Sep 17 00:00:00 2001 From: gdr Date: Sun, 21 Dec 1997 20:14:21 +0000 Subject: [PATCH] added trivial test for fts routines --- lib/libc/tests/gen/ftstest.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/libc/tests/gen/ftstest.c diff --git a/lib/libc/tests/gen/ftstest.c b/lib/libc/tests/gen/ftstest.c new file mode 100644 index 0000000..01caf73 --- /dev/null +++ b/lib/libc/tests/gen/ftstest.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include + +int main (int argc, char **argv) { + + FTS *ftsp; + FTSENT *entp; + int options; + + if (argc < 2) { + printf("usage: %s dirname\n", argv[0]); + exit(1); + } + options = FTS_NOCHDIR | FTS_NOSTAT; + ftsp = fts_open(&argv[1], options, NULL); + if (ftsp == NULL) { + printf("fts_open failed\n"); + exit(1); + } + + while ((entp = fts_read(ftsp)) != NULL) { + assert(entp->fts_name != NULL); + printf("%s\n", entp->fts_name); + } + if (errno) { + perror("fts_read return code"); + } + + options = fts_close(ftsp); + printf("fts_close returned %d\n", options); + return 0; +}