Skip to content

Commit

Permalink
refs #97, on posix backend hard links tests are now validated against…
Browse files Browse the repository at this point in the history
… lstat result to support results from btrfs
  • Loading branch information
gulrak committed Feb 13, 2021
1 parent 88f9c36 commit 57f3186
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2019,6 +2019,15 @@ TEST_CASE("30.10.15.14 file_size", "[filesystem][operations][fs.op.file_size]")
ec.clear();
}

#ifndef GHC_OS_WINDOWS
static uintmax_t getHardlinkCount(const fs::path& p)
{
struct stat st = {};
auto rc = ::lstat(p.c_str(), &st);
return rc == 0 ? st.st_nlink : ~0;
}
#endif

TEST_CASE("30.10.15.15 hard_link_count", "[filesystem][operations][fs.op.hard_link_count]")
{
#ifndef GHC_OS_WEB
Expand All @@ -2034,9 +2043,9 @@ TEST_CASE("30.10.15.15 hard_link_count", "[filesystem][operations][fs.op.hard_li
// unix/bsd/linux typically implements "."/".." as hardlinks
// so an empty dir has 2 (from parent and the ".") and
// adding a subdirectory adds one due to its ".."
CHECK(fs::hard_link_count(t.path()) == 2);
CHECK(fs::hard_link_count(t.path()) == getHardlinkCount(t.path()));
fs::create_directory("dir");
CHECK(fs::hard_link_count(t.path()) == 3);
CHECK(fs::hard_link_count(t.path()) == getHardlinkCount(t.path()));
#endif
generateFile("foo");
CHECK(fs::hard_link_count(t.path() / "foo") == 1);
Expand Down

0 comments on commit 57f3186

Please sign in to comment.