diff mbox

[1/2] btrfs-progs: tests, add support for running commands under root

Message ID 1421256302-8503-1-git-send-email-dsterba@suse.cz (mailing list archive)
State Accepted
Headers show

Commit Message

David Sterba Jan. 14, 2015, 5:25 p.m. UTC
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(+)

Comments

Qu Wenruo Jan. 15, 2015, 12:33 a.m. UTC | #1
-------- Original Message --------
Subject: [PATCH 1/2] btrfs-progs: tests, add support for running 
commands under root
From: David Sterba <dsterba@suse.cz>
To: <linux-btrfs@vger.kernel.org>
Date: 2015?01?15? 01:25
> 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.
I'm a little worried about using sudo in such test.
If the test is ran by a script, test will be stuck waiting for input and 
timeout after a long time.

I prefer NOT RUN just like xfstests.

Thanks
Qu
>
> 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
> +}

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba Jan. 19, 2015, 6:07 p.m. UTC | #2
> > 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.
> I'm a little worried about using sudo in such test.

Opposed to running the whole testsuite as root? Most tests are fine to
be run under the user privileges.

> If the test is ran by a script, test will be stuck waiting for input and 
> timeout after a long time.

Good point, I'll add --non-interactive that will abort in that case.

> I prefer NOT RUN just like xfstests.

But xfstests do not run if there's a missing implementation or
incomplete testing setup, ie. something that cannot be fixed by other
means.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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