summaryrefslogtreecommitdiff
path: root/tests/common
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-01-14 18:07:43 +0100
committerDavid Sterba <dsterba@suse.cz>2015-01-14 18:34:18 +0100
commit522e13d6d92f0083c8739f1137faa40aa98d7b03 (patch)
tree97424fc0add33add97eeec4cba434cd615362957 /tests/common
parente6bc739148adf8cd8edd18de7c1e36aad31a6ac6 (diff)
btrfs-progs: tests, add support for running commands under root
Most of the checks run fine without root, but some of them may need to do a mount test or access the data. Add the support to selectively run commands under root, hardcoded to sudo for now. Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/common b/tests/common
index 80a53816..84a4b9d3 100644
--- a/tests/common
+++ b/tests/common
@@ -47,3 +47,18 @@ check_all_images()
rm $i.restored
done
}
+
+# some tests need to mount the recovered image and do verifications call
+# 'setup_root_helper' and then check for have_root_helper == 1 if the test
+# needs to fail otherwise; using sudo by default for now
+sudo=
+have_root_helper=0
+export sudo
+export have_root_helper
+setup_root_helper()
+{
+ if [ $UID != 0 ]; then
+ sudo=sudo
+ fi
+ have_root_helper=1
+}