diff options
author | Colin Walters <walters@verbum.org> | 2017-09-18 13:58:54 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-09-21 13:21:59 +0000 |
commit | 7a8511e0ca9c4e2441077ad0f2872c35a199eebe (patch) | |
tree | 1829b6f1a406cf2b1b56428e895a4a964f4ad4ca /tests/libtest.sh | |
parent | 74cf3594eed955847b7a16a7e8a775ba69a47617 (diff) | |
download | ostree-7a8511e0ca9c4e2441077ad0f2872c35a199eebe.tar.gz |
tests/libtest: Factor out user xattr detection
Make the equivalent of a `GOnce` or Rust `lazy_static!` detecting this and share
it between the two callers.
Prep for a future similar patch for strace fault injection.
Closes: #1186
Approved by: jlebon
Diffstat (limited to 'tests/libtest.sh')
-rwxr-xr-x | tests/libtest.sh | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/libtest.sh b/tests/libtest.sh index 1ae04a74..5017abea 100755 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -515,9 +515,21 @@ os_repository_new_commit () } # Usage: if ! skip_one_without_user_xattrs; then ... more tests ...; fi +_have_user_xattrs='' +have_user_xattrs() { + if test "${_have_user_xattrs}" = ''; then + touch test-xattrs + if setfattr -n user.testvalue -v somevalue test-xattrs 2>/dev/null; then + _have_user_xattrs=yes + else + _have_user_xattrs=no + fi + rm -f test-xattrs + fi + test ${_have_user_xattrs} = yes +} skip_one_without_user_xattrs () { - touch test-xattrs - if ! setfattr -n user.testvalue -v somevalue test-xattrs; then + if ! have_user_xattrs; then echo "ok # SKIP - this test requires xattr support" return 0 else @@ -526,9 +538,9 @@ skip_one_without_user_xattrs () { } skip_without_user_xattrs () { - touch test-xattrs - setfattr -n user.testvalue -v somevalue test-xattrs || \ + if ! have_user_xattrs; then skip "this test requires xattr support" + fi } skip_without_fuse () { |