All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] tst_test.sh: Print help ASAP
@ 2021-11-23 18:07 Petr Vorel
  2021-11-23 18:26 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Vorel @ 2021-11-23 18:07 UTC (permalink / raw)
  To: ltp; +Cc: Xiao Yang

There is no need to run setup before printing help.

Before this change root was required for network tests also for -h:

    $ PATH="$lb:$PATH" nfs01 -h
    nfs01 1 TCONF: Must be super/root for this test!

And with root setup was run:

	# PATH="$lb:$PATH" nfs07.sh -h
	nfs07 1 TINFO: initialize 'lhost' 'ltp_ns_veth2' interface
	nfs07 1 TINFO: add local addr 10.0.0.2/24
	nfs07 1 TINFO: add local addr fd00:1:1:1::2/64
	nfs07 1 TINFO: initialize 'rhost' 'ltp_ns_veth1' interface
	nfs07 1 TINFO: add remote addr 10.0.0.1/24
	nfs07 1 TINFO: add remote addr fd00:1:1:1::1/64
	nfs07 1 TINFO: Network config (local -- remote):
	nfs07 1 TINFO: ltp_ns_veth2 -- ltp_ns_veth1
	nfs07 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24
	nfs07 1 TINFO: fd00:1:1:1::2/64 -- fd00:1:1:1::1/64
	-t x    Socket type, tcp or udp, default is udp
	-v x    NFS version, default is '3'
	-n x    Create x files and x directories, default is 5000
	-h      Prints this help
	-i n    Execute test n times

Now help is simply printed:

    $ PATH="$lb:$PATH" nfs01 -h
    -t x    Socket type, tcp or udp, default is udp
    -v x    NFS version, default is '3'
    -6      IPv6 tests
    -h      Prints this help
    -i n    Execute test n times

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_test.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 2556b28f5..3cf94adac 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -606,7 +606,6 @@ tst_run()
 
 	while getopts ":hi:$TST_OPTS" _tst_name $TST_ARGS; do
 		case $_tst_name in
-		'h') tst_usage; exit 0;;
 		'i') TST_ITERATIONS=$OPTARG;;
 		'?') tst_usage; exit 2;;
 		*) $TST_PARSE_ARGS "$_tst_name" "$OPTARG";;
@@ -789,4 +788,9 @@ if [ -z "$TST_NO_DEFAULT_RUN" ]; then
 			tst_brk TBROK "Unexpected positional arguments '$@'"
 		fi
 	fi
+
+	if [ "$TST_PRINT_HELP" = 1 ]; then
+		tst_usage
+		exit 0
+	fi
 fi
-- 
2.33.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [PATCH 1/1] tst_test.sh: Print help ASAP
  2021-11-23 18:07 [LTP] [PATCH 1/1] tst_test.sh: Print help ASAP Petr Vorel
@ 2021-11-23 18:26 ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2021-11-23 18:26 UTC (permalink / raw)
  To: ltp; +Cc: Xiao Yang

Hi,

[ Cc Alexey ]

> There is no need to run setup before printing help.

This is wrong approach (=> reject status), it should be fixed in tst_net.sh,
which should probably run netns initialization:
[ -n "$TST_USE_NETNS" -a "$TST_INIT_NETNS" != "no" ] && init_ltp_netspace

as part of the setup function (tst_net_setup).

Because 1) running help immediately breaks redefining help in nfs07.sh [1]:

. nfs_lib.sh

TST_USAGE="show_usage"

(yes, having help for tst_net.sh, nfs_lib.sh and for some of the tests
which use it is maybe complicated flow, but it should work).

2) code works as expected for tests which use just tst_test.sh (or other
libraries which does *not* use tst_net.sh).

Sorry for the noise.

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/20211123151537.14913-3-mdoucha@suse.cz/T/#u

> Before this change root was required for network tests also for -h:

>     $ PATH="$lb:$PATH" nfs01 -h
>     nfs01 1 TCONF: Must be super/root for this test!

> And with root setup was run:

> 	# PATH="$lb:$PATH" nfs07.sh -h
> 	nfs07 1 TINFO: initialize 'lhost' 'ltp_ns_veth2' interface
> 	nfs07 1 TINFO: add local addr 10.0.0.2/24
> 	nfs07 1 TINFO: add local addr fd00:1:1:1::2/64
> 	nfs07 1 TINFO: initialize 'rhost' 'ltp_ns_veth1' interface
> 	nfs07 1 TINFO: add remote addr 10.0.0.1/24
> 	nfs07 1 TINFO: add remote addr fd00:1:1:1::1/64
> 	nfs07 1 TINFO: Network config (local -- remote):
> 	nfs07 1 TINFO: ltp_ns_veth2 -- ltp_ns_veth1
> 	nfs07 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24
> 	nfs07 1 TINFO: fd00:1:1:1::2/64 -- fd00:1:1:1::1/64
> 	-t x    Socket type, tcp or udp, default is udp
> 	-v x    NFS version, default is '3'
> 	-n x    Create x files and x directories, default is 5000
> 	-h      Prints this help
> 	-i n    Execute test n times

> Now help is simply printed:

>     $ PATH="$lb:$PATH" nfs01 -h
>     -t x    Socket type, tcp or udp, default is udp
>     -v x    NFS version, default is '3'
>     -6      IPv6 tests
>     -h      Prints this help
>     -i n    Execute test n times

> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/lib/tst_test.sh | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index 2556b28f5..3cf94adac 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -606,7 +606,6 @@ tst_run()

>  	while getopts ":hi:$TST_OPTS" _tst_name $TST_ARGS; do
>  		case $_tst_name in
> -		'h') tst_usage; exit 0;;
>  		'i') TST_ITERATIONS=$OPTARG;;
>  		'?') tst_usage; exit 2;;
>  		*) $TST_PARSE_ARGS "$_tst_name" "$OPTARG";;
> @@ -789,4 +788,9 @@ if [ -z "$TST_NO_DEFAULT_RUN" ]; then
>  			tst_brk TBROK "Unexpected positional arguments '$@'"
>  		fi
>  	fi
> +
> +	if [ "$TST_PRINT_HELP" = 1 ]; then
> +		tst_usage
> +		exit 0
> +	fi
>  fi

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-23 18:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-23 18:07 [LTP] [PATCH 1/1] tst_test.sh: Print help ASAP Petr Vorel
2021-11-23 18:26 ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.