From: Collin Funk Date: Sat, 25 Oct 2025 03:58:02 +0000 (-0700) Subject: fts tests: Add a test for FTS_MOUNT. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de8695cf2ef597fa6ceed936d368db03e638ece2;p=thirdparty%2Fgnulib.git fts tests: Add a test for FTS_MOUNT. * modules/fts-tests (Files): Add tests/macros.h. * tests/test-fts.c: Include macros.h. (test_fts_mount): New function. (main): Call test_fts_mount. --- diff --git a/ChangeLog b/ChangeLog index 48bf95cd41..49351e86e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2025-11-02 Collin Funk + + fts tests: Add a test for FTS_MOUNT. + * modules/fts-tests (Files): Add tests/macros.h. + * tests/test-fts.c: Include macros.h. + (test_fts_mount): New function. + (main): Call test_fts_mount. + 2025-11-02 Lukáš Zaoral fts: Introduce the FTS_MOUNT flag. diff --git a/modules/fts-tests b/modules/fts-tests index 5feb3c3c6e..0ff8a8cdde 100644 --- a/modules/fts-tests +++ b/modules/fts-tests @@ -3,6 +3,7 @@ longrunning-test Files: tests/test-fts.c +tests/macros.h Depends-on: c99 diff --git a/tests/test-fts.c b/tests/test-fts.c index f50df573b5..31c9898b80 100644 --- a/tests/test-fts.c +++ b/tests/test-fts.c @@ -26,6 +26,8 @@ #include #include +#include "macros.h" + #define BASE "t-fts.tmp" static char base[] = BASE; /* Not const, since argv needs non-const. */ static char const base_d[] = BASE "/d"; @@ -86,6 +88,39 @@ remove_tree (void) perror_exit (base, 3); } +static void +test_fts_mount (void) +{ + FTSENT *ent; + char *const root[] = { "/", NULL }; + FTS *ftsp = fts_open (root, FTS_PHYSICAL | FTS_MOUNT | FTS_CWDFD, NULL); + dev_t root_dev; + + ASSERT (ftsp != NULL); + + /* Make sure each directory directly below the root directory has the same + device ID when we use FTS_MOUNT. */ + while ((ent = fts_read (ftsp))) + { + switch (ent->fts_info) + { + case FTS_D: + if (ent->fts_level == FTS_ROOTLEVEL) + root_dev = ent->fts_statp->st_dev; + else + { + ASSERT (ent->fts_statp->st_dev == root_dev); + ASSERT (fts_set (ftsp, ent, FTS_SKIP) == 0); + } + break; + default: + break; + } + } + + ASSERT (fts_close (ftsp) == 0); +} + int main (void) { @@ -168,5 +203,7 @@ main (void) fts_dealloc (); + test_fts_mount (); + return 0; }