Error in test "30.10.15.15 hard_link_count"
phprus opened this issue · 3 comments
Describe the bug
hard_link_count test logic is wrong on BTRFS.
The links counter is always equal to 1 (https://unix.stackexchange.com/a/618726).
Error:
40: /home/.../3rdparty/ghc-filesystem/src/test/filesystem_test.cpp:2037: FAILED:
40: CHECK( fs::hard_link_count(t.path()) == 2 )
40: with expansion:
40: 1 == 2
40:
40: /home/.../3rdparty/ghc-filesystem/src/test/filesystem_test.cpp:2039: FAILED:
40: CHECK( fs::hard_link_count(t.path()) == 3 )
40: with expansion:
40: 1 == 3
To Reproduce
Run test on BTRFS.
Btrfs is are default file system on SUSE 12+ and Fedora 33+.
Possible workaround:
Replace CHECK(fs::hard_link_count(t.path()) == 2)
to CHECK(fs::hard_link_count(t.path()) == 2 || fs::hard_link_count(t.path()) == 1);
and
CHECK(fs::hard_link_count(t.path()) == 3)
to CHECK(fs::hard_link_count(t.path()) == 3 || fs::hard_link_count(t.path()) == 1);
Nice find. Ich think I prefer to use an lstat
helper in filesystem_test for Linux to compare to its result, to keep the test from accepting 1 when the fs is not BTRFS. I'll look into it later today after work.