libtest: Allow skipping single checks without user xattrs
authorSimon McVittie <smcv@collabora.com>
Tue, 29 Aug 2017 16:02:18 +0000 (17:02 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 29 Aug 2017 19:08:59 +0000 (19:08 +0000)
Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #1120
Approved by: cgwalters

tests/libtest.sh

index 4db8b730ea6d054237aca316e8ac71a103515f61..73e88891e0e8c7840d63c38cdfd9c9f261a514bd 100755 (executable)
@@ -511,6 +511,17 @@ os_repository_new_commit ()
     cd ${test_tmpdir}
 }
 
+# Usage: if ! skip_one_without_user_xattrs; then ... more tests ...; fi
+skip_one_without_user_xattrs () {
+    touch test-xattrs
+    if ! setfattr -n user.testvalue -v somevalue test-xattrs; then
+        echo "ok # SKIP - this test requires xattr support"
+        return 0
+    else
+        return 1
+    fi
+}
+
 skip_without_user_xattrs () {
     touch test-xattrs
     setfattr -n user.testvalue -v somevalue test-xattrs || \