diff mbox series

[v2] isofs.sh: Create group and user before check mount option

Message ID 20240828134551.6344-1-wegao@suse.com
State Changes Requested
Headers show
Series [v2] isofs.sh: Create group and user before check mount option | expand

Commit Message

Wei Gao Aug. 28, 2024, 1:45 p.m. UTC
Case will failed if default system has no group named "bin", such
as suse sle-micro, so this patch will create specific group for test
instead of fixed "bin" group.

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/fs/iso9660/isofs.sh | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

Comments

Petr Vorel Aug. 28, 2024, 11:02 p.m. UTC | #1
Hi Wei,

> Case will failed if default system has no group named "bin", such
> as suse sle-micro, so this patch will create specific group for test
> instead of fixed "bin" group.

I wonder if we should not add this group to SUT, there are more tests which
needs some group (IDcheck.sh has bin, daemon, nobody, ...), e.g. hugeshmat03.c,
cgroup_core0[12].c, access01.c use nobody. Maybe that is more common than bin
(and presented on the SUT).

FYI we even have a ticket, although I don't expect you would have time to
to work on something generic...
https://github.com/linux-test-project/ltp/issues/468

...
>  MAX_DEPTH=3
>  MAX_DIRS=4

> +test_group="abc"

... thus I'm not opposite to workaround like this. But it'd be better to name
the new user ltp_isofs or something really unique.

> +
> +setup()
> +{
> +	if ! getent group $test_group > /dev/null; then
> +		useradd -U $test_group
> +	fi
> +}
> +
> +cleanup()
> +{
> +	userdel -f $test_group
> +	groupdel -f $test_group

+1 for using userdel which is everywhere.
But maybe prefix it with ROD?
or use TST_NEEDS_CMDS to make sure both binaries are on SUT?

Kind regards,
Petr
> +}
> +
>  gen_fs_tree()
>  {
>  	local cur_path="$1"
> @@ -92,8 +109,8 @@ do_test()
>  			"loop,block=512,unhide" \
>  			"loop,block=1024,cruft" \
>  			"loop,block=2048,nocompress" \
> -			"loop,check=strict,map=off,gid=bin,uid=bin" \
> -			"loop,check=strict,map=acorn,gid=bin,uid=bin" \
> +			"loop,block=2048,nocompress" \ "loop,check=strict,map=off,gid=$test_group,uid=$test_group" \
> +			"loop,check=strict,map=acorn,gid=$test_group,uid=$test_group" \
>  			"loop,check=relaxed,map=normal" \
>  			"loop,block=512,unhide,session=2"
>  		do
diff mbox series

Patch

diff --git a/testcases/kernel/fs/iso9660/isofs.sh b/testcases/kernel/fs/iso9660/isofs.sh
index d1a362d97..812df1caa 100755
--- a/testcases/kernel/fs/iso9660/isofs.sh
+++ b/testcases/kernel/fs/iso9660/isofs.sh
@@ -13,10 +13,27 @@  TST_NEEDS_CMDS="mount umount"
 TST_NEEDS_TMPDIR=1
 TST_TESTFUNC=do_test
 TST_CNT=3
+TST_SETUP="setup"
+TST_CLEANUP="cleanup"
 
 MAX_DEPTH=3
 MAX_DIRS=4
 
+test_group="abc"
+
+setup()
+{
+	if ! getent group $test_group > /dev/null; then
+		useradd -U $test_group
+	fi
+}
+
+cleanup()
+{
+	userdel -f $test_group
+	groupdel -f $test_group
+}
+
 gen_fs_tree()
 {
 	local cur_path="$1"
@@ -92,8 +109,8 @@  do_test()
 			"loop,block=512,unhide" \
 			"loop,block=1024,cruft" \
 			"loop,block=2048,nocompress" \
-			"loop,check=strict,map=off,gid=bin,uid=bin" \
-			"loop,check=strict,map=acorn,gid=bin,uid=bin" \
+			"loop,block=2048,nocompress" \ "loop,check=strict,map=off,gid=$test_group,uid=$test_group" \
+			"loop,check=strict,map=acorn,gid=$test_group,uid=$test_group" \
 			"loop,check=relaxed,map=normal" \
 			"loop,block=512,unhide,session=2"
 		do