Page MenuHomeFreeBSD

D56016.id174081.diff
No OneTemporary

D56016.id174081.diff

diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile
--- a/lib/libc/tests/gen/Makefile
+++ b/lib/libc/tests/gen/Makefile
@@ -32,6 +32,8 @@
ATF_TESTS_C+= sigsetops_test
ATF_TESTS_C+= wordexp_test
+ATF_TESTS_C+= fts_symlink_test
+
# TODO: t_closefrom, t_fmtcheck, t_randomid,
# TODO: t_siginfo (fixes require further inspection)
# TODO: t_sethostname_test (consistently screws up the hostname)
diff --git a/lib/libc/tests/gen/fts_symlink_test.c b/lib/libc/tests/gen/fts_symlink_test.c
new file mode 100644
--- /dev/null
+++ b/lib/libc/tests/gen/fts_symlink_test.c
@@ -0,0 +1,60 @@
+#include <atf-c.h>
+#include <atf-c.h>
+#include <fts.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+// #include "fts_test.h"
+
+/* Test to check if fts_open can count symlinks
+ * correctly
+ * */
+ATF_TC(fts_follow_symlink);
+
+
+ATF_TC_HEAD(fts_follow_symlink, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "fts_open with FTS_LOGICAL follows symlink");
+}
+
+ATF_TC_BODY(fts_follow_symlink, tc)
+{
+ char *tmpdir = "tmp_fts_symlink_test";
+ FTS *fts;
+ FTSENT *ent;
+ char *args[] = { (char *)tmpdir, NULL };
+ int found_link = 0;
+
+ // We're creating a dir, a file, and a symlink to it
+ ATF_REQUIRE(mkdir(tmpdir, 0755) == 0);
+ ATF_REQUIRE(close(open("tmp_fts_symlink_test/target", O_CREAT | O_RDONLY, 0644)) == 0);
+ ATF_REQUIRE(symlink("target", "tmp_fts_symlink_test/link") == 0);
+
+ fts = fts_open(args, FTS_LOGICAL, NULL);
+ ATF_REQUIRE(fts != NULL);
+
+ while ((ent = fts_read(fts)) != NULL)
+ {
+ if (strcmp(ent->fts_name, "link")) {
+ ATF_CHECK(ent->fts_info != FTS_SL);
+ found_link = 1;
+ }
+ }
+
+ ATF_CHECK(found_link == 1);
+ fts_close(fts);
+
+ unlink("tmp_fts_symlink_test/link");
+ unlink("tmp_fts_symlink_test/target");
+ rmdir(tmpdir);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, fts_follow_symlink);
+ return atf_no_error();
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Aug 28, 11:36 AM (1 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37451891
Default Alt Text
D56016.id174081.diff (1 KB)

Event Timeline