[RFC,6/9] testcases: wc: Add "unrecognized option" as TCONF

Message ID 20180423094639.14612-7-mylene.josserand@bootlin.com
State Accepted
Delegated to: Petr Vorel
Headers show
Series
  • testcases: small improvements with TCONF
Related show

Commit Message

Mylène Josserand April 23, 2018, 9:46 a.m.
In case we are using Busybox, for example, some options
may not available and leads to a test failure.
This commit adds "unrecognized option" parsing to return the
test as a TCONF and not FAIL anymore.

Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com>
---
 testcases/commands/wc/wc01.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Petr Vorel May 16, 2018, 10 a.m. | #1
Hi Mylène,
> In case we are using Busybox, for example, some options
> may not available and leads to a test failure.
> This commit adds "unrecognized option" parsing to return the
> test as a TCONF and not FAIL anymore.

> Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com>
> ---
>  testcases/commands/wc/wc01.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/testcases/commands/wc/wc01.sh b/testcases/commands/wc/wc01.sh
> index e72819c51..74d69e254 100755
> --- a/testcases/commands/wc/wc01.sh
> +++ b/testcases/commands/wc/wc01.sh
> @@ -40,7 +40,7 @@ wc_test()

>  	eval $wc_cmd > temp 2>&1
>  	if [ $? -ne 0 ]; then
> -		grep -q -E "unknown option|invalid option" temp
> +		grep -q -E "unknown option|invalid option|unrecognized option" temp
What exactly needs "unrecognized option".
I haven't found it in busybox sources neither in busybox git log.

>  		if [ $? -eq 0 ]; then
>  			tst_res TCONF "$wc_cmd not supported."
>  		else


Kind regards,
Petr
Mylène Josserand May 29, 2018, 4:32 p.m. | #2
Hello Petr,

On Wed, 16 May 2018 12:00:55 +0200
Petr Vorel <pvorel@suse.cz> wrote:

> Hi Mylène,
> > In case we are using Busybox, for example, some options
> > may not available and leads to a test failure.
> > This commit adds "unrecognized option" parsing to return the
> > test as a TCONF and not FAIL anymore.  
> 
> > Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com>
> > ---
> >  testcases/commands/wc/wc01.sh | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)  
> 
> > diff --git a/testcases/commands/wc/wc01.sh b/testcases/commands/wc/wc01.sh
> > index e72819c51..74d69e254 100755
> > --- a/testcases/commands/wc/wc01.sh
> > +++ b/testcases/commands/wc/wc01.sh
> > @@ -40,7 +40,7 @@ wc_test()  
> 
> >  	eval $wc_cmd > temp 2>&1
> >  	if [ $? -ne 0 ]; then
> > -		grep -q -E "unknown option|invalid option" temp
> > +		grep -q -E "unknown option|invalid option|unrecognized option" temp  
> What exactly needs "unrecognized option".
> I haven't found it in busybox sources neither in busybox git log.

Just in case, this is what I get with my busybox (v1.24.1):

# wc --max-line-length
wc: unrecognized option '--max-line-length'
BusyBox v1.24.1 (2018-02-10 17:35:25 CET) multi-call binary.

Usage: wc [-clwL] [FILE]...

I looked very quickly and it seems to be glibc with "getopt" function
that prints this error:
https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/getopt.c#l309

> 
> >  		if [ $? -eq 0 ]; then
> >  			tst_res TCONF "$wc_cmd not supported."
> >  		else  
> 
> 
> Kind regards,
> Petr

Best regards,
Petr Vorel June 4, 2018, 3:22 p.m. | #3
Hi Mylène,

> > I haven't found it in busybox sources neither in busybox git log.

> Just in case, this is what I get with my busybox (v1.24.1):

> # wc --max-line-length
> wc: unrecognized option '--max-line-length'
> BusyBox v1.24.1 (2018-02-10 17:35:25 CET) multi-call binary.

> Usage: wc [-clwL] [FILE]...

> I looked very quickly and it seems to be glibc with "getopt" function
> that prints this error:
> https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/getopt.c#l309

Thanks for debugging. Indeed, it really uses getopts() from libc, thus
libc dependent - busybox with musl has it with comma:
wc: unrecognized option: max-line-length

But all libraries common libc libraries (glibc, musl, uclibc-ng) has string "unrecognized
option" => make sense to add the patch.

Acked-by: Petr Vorel <pvorel@suse.cz>


Kind regards,
Petr
Petr Vorel June 4, 2018, 3:33 p.m. | #4
Hi Mylène,

> In case we are using Busybox, for example, some options
> may not available and leads to a test failure.
> This commit adds "unrecognized option" parsing to return the
> test as a TCONF and not FAIL anymore.
...
>  testcases/commands/wc/wc01.sh | 2 +-
...
> -		grep -q -E "unknown option|invalid option" temp
> +		grep -q -E "unknown option|invalid option|unrecognized option" temp

Pushed, thanks!


Kind regards,
Petr
Mylène Josserand June 5, 2018, 6:21 a.m. | #5
Hi Petr,

On Mon, 4 Jun 2018 17:22:21 +0200
Petr Vorel <pvorel@suse.cz> wrote:

> Hi Mylène,
> 
> > > I haven't found it in busybox sources neither in busybox git log.  
> 
> > Just in case, this is what I get with my busybox (v1.24.1):  
> 
> > # wc --max-line-length
> > wc: unrecognized option '--max-line-length'
> > BusyBox v1.24.1 (2018-02-10 17:35:25 CET) multi-call binary.  
> 
> > Usage: wc [-clwL] [FILE]...  
> 
> > I looked very quickly and it seems to be glibc with "getopt" function
> > that prints this error:
> > https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/getopt.c#l309  
> 
> Thanks for debugging. Indeed, it really uses getopts() from libc, thus
> libc dependent - busybox with musl has it with comma:
> wc: unrecognized option: max-line-length
> 
> But all libraries common libc libraries (glibc, musl, uclibc-ng) has string "unrecognized
> option" => make sense to add the patch.

Oh yes, I did not check other C library, great to know that
"unrecognized option" is common.

Thanks for the review and for the pushed!

Best regards,

Patch

diff --git a/testcases/commands/wc/wc01.sh b/testcases/commands/wc/wc01.sh
index e72819c51..74d69e254 100755
--- a/testcases/commands/wc/wc01.sh
+++ b/testcases/commands/wc/wc01.sh
@@ -40,7 +40,7 @@  wc_test()
 
 	eval $wc_cmd > temp 2>&1
 	if [ $? -ne 0 ]; then
-		grep -q -E "unknown option|invalid option" temp
+		grep -q -E "unknown option|invalid option|unrecognized option" temp
 		if [ $? -eq 0 ]; then
 			tst_res TCONF "$wc_cmd not supported."
 		else