sfx2/qa/cppunit/test_misc.cxx | 66 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-)
New commits: commit 1a714f6a80807427c59c370a36f895a0dc4dd7cb Author: Tor Lillqvist <[email protected]> AuthorDate: Thu Jan 15 01:33:32 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Jan 15 20:49:31 2026 +0100 Don't check some POSIX things on file systems known to be weird On a Mac volume mounted in a Linux virtual machine under Parallels Desktop, hard-linking works (from the Linux VM). Looking at it in the host macOS the linked files also show up as linked, with identical inode number and a link count of 2. But in the Linux VM, the hard-linked files each have a link count of 1, and different inode numbers. (Still, they *are* the same file. If you write to one, it shows up in the other, too, etc.) I am not saying it necessarily makes sense to build core on such a file system. Quite likely it makes more sense to just create a native Linux file system on a Parallels virtual hard drive (that is a file on a Mac volume). But it is fun to experiment with stuff like this. Yes, if it turns out that we need to get the name of the file system type some folder or file is on in other places, too, the code for that should be put in some shared place. Change-Id: I315eb2ed0fd0803da3070645119b2bd3019cc9a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197305 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sfx2/qa/cppunit/test_misc.cxx b/sfx2/qa/cppunit/test_misc.cxx index 7c41f990bff9..74e07ba210df 100644 --- a/sfx2/qa/cppunit/test_misc.cxx +++ b/sfx2/qa/cppunit/test_misc.cxx @@ -15,6 +15,13 @@ #endif #include <memory> +#ifdef LINUX +#include <fstream> +#include <sstream> +#include <string> +#include <limits.h> +#endif + #include <com/sun/star/beans/Pair.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/IllegalTypeException.hpp> @@ -533,6 +540,53 @@ CPPUNIT_TEST_FIXTURE(MiscTest, testNoThumbnail) #endif } +#ifdef LINUX + +std::string get_filesystem_type(const char* path) +{ + char resolved[PATH_MAX]; + if (!realpath(path, resolved)) + return ""; + + std::ifstream file("/proc/self/mountinfo"); + std::string line; + + std::string bestMatch; + std::string fsType; + + while (std::getline(file, line)) { + std::istringstream iss(line); + std::string token; + + // Skip first fields until mount point + for (int i = 0; i < 4; ++i) + iss >> token; + + std::string mountPoint; + iss >> mountPoint; + + // Find separator "-" + while (iss >> token && token != "-") + ; + + if (!(iss >> token)) + continue; + + std::string type = token; + + if (std::string(resolved).starts_with(mountPoint) && + mountPoint.length() > bestMatch.length()) { + bestMatch = mountPoint; + fsType = type; + } + } + + return fsType; +} + +#endif + + CPPUNIT_TEST_FIXTURE(MiscTest, testHardLinks) { #ifndef _WIN32 @@ -556,8 +610,18 @@ CPPUNIT_TEST_FIXTURE(MiscTest, testHardLinks) // coverity[fs_check_call] - this is legitimate in the context of this test nRet = stat(aOld.getStr(), &buf); CPPUNIT_ASSERT_EQUAL(0, nRet); + // This failed: hard link count was 1, the hard link broke on store. - CPPUNIT_ASSERT(buf.st_nlink > 1); + bool doCheckNlink(true); + +#ifdef LINUX + // Some file system types are know to have quite non-POSIX semantics. + std::string fsType = get_filesystem_type(aOld.getStr()); + if (fsType == "fuse.prl_fsd") + doCheckNlink = false; +#endif + + CPPUNIT_ASSERT(!doCheckNlink || buf.st_nlink > 1); // Test that symlinks are preserved as well. nRet = remove(aNew.getStr());
