[PATCH mptcp-next 1/9] selftests: mptcp: join: allow running -cCi

Matthieu Baerts posted 9 patches 4 years ago
Maintainers: Matthieu Baerts <matthieu.baerts@tessares.net>, Jakub Kicinski <kuba@kernel.org>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Shuah Khan <shuah@kernel.org>, "David S. Miller" <davem@davemloft.net>
There is a newer version of this series
[PATCH mptcp-next 1/9] selftests: mptcp: join: allow running -cCi
Posted by Matthieu Baerts 4 years ago
Without this patch, no tests would be ran when launching:

  mptcp_join.sh -cCi

In any order or a combination with 2 of these letters.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 66ac990415e6..9bbb95837f73 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2242,7 +2242,7 @@ for arg in "$@"; do
 	fi
 
 	# exception for the capture/checksum/ip_mptcp options, the rest means: a part of the tests
-	if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ] && [ "${arg}" != "-i" ]; then
+	if ! [[ "${arg}" =~ ^"-"[cCi]+$ ]]; then
 		do_all_tests=0
 	fi
 done
-- 
2.34.1


Re: [PATCH mptcp-next 1/9] selftests: mptcp: join: allow running -cCi
Posted by Paolo Abeni 3 years, 12 months ago
On Wed, 2022-02-09 at 22:25 +0100, Matthieu Baerts wrote:
> Without this patch, no tests would be ran when launching:
> 
>   mptcp_join.sh -cCi
> 
> In any order or a combination with 2 of these letters.
> 
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> ---
>  tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 66ac990415e6..9bbb95837f73 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -2242,7 +2242,7 @@ for arg in "$@"; do
>  	fi
>  
>  	# exception for the capture/checksum/ip_mptcp options, the rest means: a part of the tests
> -	if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ] && [ "${arg}" != "-i" ]; then
> +	if ! [[ "${arg}" =~ ^"-"[cCi]+$ ]]; then
>  		do_all_tests=0
>  	fi
>  done

At this point I think it would be better consolidate argument parsing
with getopts, and dropping the above regexp.

While parsing the test group selectors, we could build the list of 
groups to be executed (possibly a string contaning all the function to
be invoked), and run them after argument parsing - or run all if such
list (string) is empty

/P


Re: [PATCH mptcp-next 1/9] selftests: mptcp: join: allow running -cCi
Posted by Matthieu Baerts 3 years, 12 months ago
Hi Paolo,

On 10/02/2022 15:53, Paolo Abeni wrote:
> On Wed, 2022-02-09 at 22:25 +0100, Matthieu Baerts wrote:
>> Without this patch, no tests would be ran when launching:
>>
>>   mptcp_join.sh -cCi
>>
>> In any order or a combination with 2 of these letters.
>>
>> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
>> ---
>>  tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
>> index 66ac990415e6..9bbb95837f73 100755
>> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
>> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
>> @@ -2242,7 +2242,7 @@ for arg in "$@"; do
>>  	fi
>>  
>>  	# exception for the capture/checksum/ip_mptcp options, the rest means: a part of the tests
>> -	if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ] && [ "${arg}" != "-i" ]; then
>> +	if ! [[ "${arg}" =~ ^"-"[cCi]+$ ]]; then
>>  		do_all_tests=0
>>  	fi
>>  done
> 
> At this point I think it would be better consolidate argument parsing
> with getopts, and dropping the above regexp.
> 
> While parsing the test group selectors, we could build the list of 
> groups to be executed (possibly a string contaning all the function to
> be invoked), and run them after argument parsing - or run all if such
> list (string) is empty

I just applied the patches in our tree and saw this message after, sorry
about that.

Indeed, good idea, that would be the proper way to handle options!
It would also be good not to do anything if the -h option is given with
others.

I will try to remember about this idea next time I modify this part! I
can also remove this commit from our tree if you prefer.

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

Re: [PATCH mptcp-next 1/9] selftests: mptcp: join: allow running -cCi
Posted by Paolo Abeni 3 years, 12 months ago
On Fri, 2022-02-11 at 18:30 +0100, Matthieu Baerts wrote:
> Hi Paolo,
> 
> On 10/02/2022 15:53, Paolo Abeni wrote:
> > On Wed, 2022-02-09 at 22:25 +0100, Matthieu Baerts wrote:
> > > Without this patch, no tests would be ran when launching:
> > > 
> > >   mptcp_join.sh -cCi
> > > 
> > > In any order or a combination with 2 of these letters.
> > > 
> > > Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> > > ---
> > >  tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> > > index 66ac990415e6..9bbb95837f73 100755
> > > --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> > > +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> > > @@ -2242,7 +2242,7 @@ for arg in "$@"; do
> > >  	fi
> > >  
> > >  	# exception for the capture/checksum/ip_mptcp options, the rest means: a part of the tests
> > > -	if [ "${arg}" != "-c" ] && [ "${arg}" != "-C" ] && [ "${arg}" != "-i" ]; then
> > > +	if ! [[ "${arg}" =~ ^"-"[cCi]+$ ]]; then
> > >  		do_all_tests=0
> > >  	fi
> > >  done
> > 
> > At this point I think it would be better consolidate argument parsing
> > with getopts, and dropping the above regexp.
> > 
> > While parsing the test group selectors, we could build the list of 
> > groups to be executed (possibly a string contaning all the function to
> > be invoked), and run them after argument parsing - or run all if such
> > list (string) is empty
> 
> I just applied the patches in our tree and saw this message after, sorry
> about that.
> 
> Indeed, good idea, that would be the proper way to handle options!
> It would also be good not to do anything if the -h option is given with
> others.
> 
> I will try to remember about this idea next time I modify this part! I
> can also remove this commit from our tree if you prefer.

I think we can simply squash the suggested change into this commit

WDYT?

Cheers,

/P