linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: linux-btrfs@vger.kernel.org
Cc: quwenruo@cn.fujitsu.com, David Sterba <dsterba@suse.cz>
Subject: [PATCH 1/2] btrfs-progs: tests, add support for running commands under root
Date: Wed, 14 Jan 2015 18:25:02 +0100	[thread overview]
Message-ID: <1421256302-8503-1-git-send-email-dsterba@suse.cz> (raw)
In-Reply-To: <1419471135-10878-1-git-send-email-quwenruo@cn.fujitsu.com>

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>
---

 tests/common | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tests/common b/tests/common
index 80a538165949..84a4b9d335e2 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
+}
-- 
2.1.3


  parent reply	other threads:[~2015-01-14 17:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-25  1:32 [PATCH 0/5] New btrfsck test framework Qu Wenruo
2014-12-25  1:32 ` [PATCH 1/5] btrfs-progs: New btrfsck test infrastructure Qu Wenruo
2014-12-25  1:32 ` [PATCH 2/5] btrfs-progs: Move btrfs-image dump to corresponding dir Qu Wenruo
2014-12-25  1:32 ` [PATCH 3/5] btrfs-progs: Move bad root items test cases to its " Qu Wenruo
2014-12-25  1:32 ` [PATCH 4/5] btrfs-progs: Move leaf-corruption no extent data case and add verification script Qu Wenruo
2014-12-25  1:32 ` [PATCH 5/5] btrfs-progs: Move extent tree rebuild test to its dir Qu Wenruo
2015-01-14 17:25 ` David Sterba [this message]
2015-01-15  0:33   ` [PATCH 1/2] btrfs-progs: tests, add support for running commands under root Qu Wenruo
2015-01-19 18:07     ` David Sterba
2015-01-14 17:25 ` [PATCH 2/2] btrfs-progs: teests, use the root helper in 012 David Sterba
2015-01-14 17:43 ` [PATCH 0/5] New btrfsck test framework David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421256302-8503-1-git-send-email-dsterba@suse.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).