diff mbox series

[7/8] btrfs-progs: test: Add helper function to check if test user exists

Message ID 452bdc64251360e5e31209d19ea84921152f4517.1543294426.git.misono.tomohiro@jp.fujitsu.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: sub: Relax the privileges of "subvolume list/show" | expand

Commit Message

Misono Tomohiro Nov. 27, 2018, 5:24 a.m. UTC
Add helper function to check that if user 'nobody' exists or not.
Note that 'nobody' should not have root privileges as it will be used
to test the behavior of non-privileged user.

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
---
 tests/common | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/tests/common b/tests/common
index 1575ae38..16693ca7 100644
--- a/tests/common
+++ b/tests/common
@@ -314,6 +314,16 @@  check_global_prereq()
 	fi
 }
 
+check_testuser()
+{
+	id -u nobody > /dev/null 2>&1
+	if [ $? -ne 0 ]; then
+		_not_run "Need to add user \"nobody\""
+	fi
+	# Note that nobody should not have root privileges
+	# otherwise test may not run as expected
+}
+
 check_image()
 {
 	local image