Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Posix / fts.cpp
blob795bc11a39e60b719eca0b1f33f095915572b0d9
1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
2 //
3 // UNSUPPORTED: darwin, target={{.*(linux|solaris).*}}
5 #include <sys/param.h>
6 #include <sys/types.h>
8 #include <sys/stat.h>
10 #include <assert.h>
11 #include <fts.h>
12 #include <stdio.h>
13 #include <stdlib.h>
15 int main() {
16 char *const paths[] = {(char *)"/etc", 0};
17 FTS *ftsp = fts_open(paths, FTS_LOGICAL, NULL);
18 assert(ftsp);
20 FTSENT *chp = fts_children(ftsp, 0);
21 assert(chp);
23 size_t n = 0;
24 for (FTSENT *p = fts_read(ftsp); p; p = fts_read(ftsp)) {
25 /* Skip recursively subdirectories */
26 if (p->fts_info == FTS_D && p->fts_level != FTS_ROOTLEVEL) /* pre-order */
27 fts_set(ftsp, p, FTS_SKIP);
28 else if (p->fts_info == FTS_DP) /* post-order */
29 continue;
30 else if (p->fts_info == FTS_F) /* regular file */
31 n++;
34 int rv = fts_close(ftsp);
35 assert(!rv);
37 printf("Number of files in /etc: '%zu'\n", n);
39 return EXIT_SUCCESS;
41 // CHECK: Number of files in /etc: '{{.*}}'