Skip to content

Commit 3e9e735

Browse files
committed
Skip the body of extendedAttributesSupport when running on tmpfs
Extended attributes in the user namespace aren't supported on tmpfs, on Linux.
1 parent 128898d commit 3e9e735

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Tests/SWBUtilTests/FSProxyTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,16 @@ import SWBTestSupport
547547
@Test(.skipHostOS(.windows))
548548
func extendedAttributesSupport() throws {
549549
try withTemporaryDirectory { (tmpDir: Path) in
550+
// Many filesystems on other platforms (e.g. various non-ext4 temporary filesystems on Linux) don't support xattrs and will return ENOTSUP.
551+
// In particular, tmpfs doesn't support xattrs on Linux unless `CONFIG_TMPFS_XATTR` is enabled in the kernel config.
552+
if try ProcessInfo.processInfo.hostOperatingSystem() == .linux {
553+
do {
554+
try localFS.setExtendedAttribute(tmpDir, key: "user.test", value: [])
555+
} catch let error as SWBUtil.POSIXError where error.code == ENOTSUP {
556+
return
557+
}
558+
}
559+
550560
let testDataPath = tmpDir.join("test-data.txt")
551561
try localFS.write(testDataPath, contents: ByteString("best-data"))
552562

0 commit comments

Comments
 (0)