[ostree] tests/basic-test.sh: enable repo-noperm test only for non-root user



commit 12bc9a336a734ff90c6e7f567bea6f92eff16aea
Author: Giuseppe Scrivano <gscrivan redhat com>
Date:   Thu Apr 2 14:09:33 2015 +0200

    tests/basic-test.sh: enable repo-noperm test only for non-root user
    
    Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>

 tests/basic-test.sh |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/tests/basic-test.sh b/tests/basic-test.sh
index 2c0455e..65e2229 100755
--- a/tests/basic-test.sh
+++ b/tests/basic-test.sh
@@ -369,13 +369,16 @@ cd test2-checkout
 touch should-not-be-fsynced
 $OSTREE commit -b test2 -s "Unfsynced commit" --fsync=false
 
-cd ${test_tmpdir}
-rm -f expected-fail error-message
-$OSTREE init --mode=archive-z2 --repo=repo-noperm
-chmod -w repo-noperm
-$OSTREE --repo=repo-noperm pull-local repo 2> error-message || touch expected-fail
-assert_has_file expected-fail
-assert_file_has_content error-message "Permission denied"
-chmod +w repo-noperm
-echo "ok unwritable repo was caught"
-
+# Run this test only as non-root user.  When run as root, the chmod
+# won't have any effect.
+if test "$(id -u)" != "0"; then
+    cd ${test_tmpdir}
+    rm -f expected-fail error-message
+    $OSTREE init --mode=archive-z2 --repo=repo-noperm
+    chmod -w repo-noperm
+    $OSTREE --repo=repo-noperm pull-local repo 2> error-message || touch expected-fail
+    assert_has_file expected-fail
+    assert_file_has_content error-message "Permission denied"
+    chmod +w repo-noperm
+    echo "ok unwritable repo was caught"
+fi


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]