[LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests

Cyril Hrubis chrubis@suse.cz
Mon Sep 12 12:03:58 CEST 2022


Hi!
> Although the warning is quite obvious:
> tst_device.c:101: TINFO: Not allowed to open /dev/loop-control. Are you root?: EACCES (13)
> tst_device.c:140: TINFO: No free devices found
> TBROK: Failed to acquire device
> 
> It's safer to expect root to get valid result.

Another option would actually be to make the TST_NEED_DEVICE flag imply
TST_NEEDS_ROOT flag, but I do not think that we have that for the C
library either.

Either way this is fine as well:

Reviwed-by: Cyril Hrubis <chrubis@suse.cz>

> Reviewed-by: Li Wang <liwang@redhat.com>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> The same as in v4
> 
>  lib/newlib_tests/shell/tst_format_device.sh      | 1 +
>  lib/newlib_tests/shell/tst_mount_device.sh       | 1 +
>  lib/newlib_tests/shell/tst_mount_device_tmpfs.sh | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/lib/newlib_tests/shell/tst_format_device.sh b/lib/newlib_tests/shell/tst_format_device.sh
> index 73a919086..dbe4ea9e7 100755
> --- a/lib/newlib_tests/shell/tst_format_device.sh
> +++ b/lib/newlib_tests/shell/tst_format_device.sh
> @@ -3,6 +3,7 @@
>  # Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
>  
>  TST_FORMAT_DEVICE=1
> +TST_NEEDS_ROOT=1
>  TST_TESTFUNC=test
>  TST_CNT=2
>  TST_DEV_FS_OPTS="-b 1024"
> diff --git a/lib/newlib_tests/shell/tst_mount_device.sh b/lib/newlib_tests/shell/tst_mount_device.sh
> index 561f878d2..70f80f84a 100755
> --- a/lib/newlib_tests/shell/tst_mount_device.sh
> +++ b/lib/newlib_tests/shell/tst_mount_device.sh
> @@ -3,6 +3,7 @@
>  # Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
>  
>  TST_MOUNT_DEVICE=1
> +TST_NEEDS_ROOT=1
>  TST_FS_TYPE=ext4
>  TST_TESTFUNC=test
>  TST_CNT=3
> diff --git a/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh b/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh
> index 36a78bc85..ed2ba8c50 100755
> --- a/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh
> +++ b/lib/newlib_tests/shell/tst_mount_device_tmpfs.sh
> @@ -3,6 +3,7 @@
>  # Copyright (c) 2022 Petr Vorel <pvorel@suse.cz>
>  
>  TST_MOUNT_DEVICE=1
> +TST_NEEDS_ROOT=1
>  TST_FS_TYPE=tmpfs
>  TST_TESTFUNC=test
>  
> -- 
> 2.37.3
> 

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list