[libcamera-devel,3/5] test: libtest: Return all non-zero init values

Message ID 20181221081311.3291-4-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • test: Define libtest
Related show

Commit Message

Kieran Bingham Dec. 21, 2018, 8:13 a.m. UTC
A skipped test is currently defined as returning 77. If this is returned
by the init stage, currently the execute call will continue on to the
run stage.

Correct this such that any non-zero return code from the init phase will
abort the test.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 test/libtest/test.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jacopo Mondi Dec. 21, 2018, 3:12 p.m. UTC | #1
Hi Kieran,

On Fri, Dec 21, 2018 at 08:13:09AM +0000, Kieran Bingham wrote:
> A skipped test is currently defined as returning 77. If this is returned
> by the init stage, currently the execute call will continue on to the
> run stage.
>
> Correct this such that any non-zero return code from the init phase will
> abort the test.
>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  test/libtest/test.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/test/libtest/test.cpp b/test/libtest/test.cpp
> index 1bb6ebcb9e8a..9d537ea08698 100644
> --- a/test/libtest/test.cpp
> +++ b/test/libtest/test.cpp
> @@ -20,7 +20,7 @@ int Test::execute()
>  	int ret;
>
>  	ret = init();
> -	if (ret < 0)
> +	if (ret)

To make this more explicit, what about ?
        if (ret != TEST_PASS)

Thanks
   j

>  		return ret;
>
>  	ret = run();
> --
> 2.17.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Kieran Bingham Dec. 21, 2018, 3:17 p.m. UTC | #2
Hi Jacopo

On 21/12/2018 15:12, jacopo mondi wrote:
> Hi Kieran,
> 
> On Fri, Dec 21, 2018 at 08:13:09AM +0000, Kieran Bingham wrote:
>> A skipped test is currently defined as returning 77. If this is returned
>> by the init stage, currently the execute call will continue on to the
>> run stage.
>>
>> Correct this such that any non-zero return code from the init phase will
>> abort the test.
>>
>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> ---
>>  test/libtest/test.cpp | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/test/libtest/test.cpp b/test/libtest/test.cpp
>> index 1bb6ebcb9e8a..9d537ea08698 100644
>> --- a/test/libtest/test.cpp
>> +++ b/test/libtest/test.cpp
>> @@ -20,7 +20,7 @@ int Test::execute()
>>  	int ret;
>>
>>  	ret = init();
>> -	if (ret < 0)
>> +	if (ret)
> 
> To make this more explicit, what about ?
>         if (ret != TEST_PASS)
> 

I thought about that, and it's actually what I had written first, but
that's essentially:

 if (ret != 0)

which is equally:

 if (ret)

which we use commonly throughout the code base...



> Thanks
>    j
> 
>>  		return ret;
>>
>>  	ret = run();
>> --
>> 2.17.1
>>
>> _______________________________________________
>> libcamera-devel mailing list
>> libcamera-devel@lists.libcamera.org
>> https://lists.libcamera.org/listinfo/libcamera-devel
Jacopo Mondi Dec. 21, 2018, 3:29 p.m. UTC | #3
Hi Kieran

On Fri, Dec 21, 2018 at 03:17:07PM +0000, Kieran Bingham wrote:
> Hi Jacopo
>
> On 21/12/2018 15:12, jacopo mondi wrote:
> > Hi Kieran,
> >
> > On Fri, Dec 21, 2018 at 08:13:09AM +0000, Kieran Bingham wrote:
> >> A skipped test is currently defined as returning 77. If this is returned
> >> by the init stage, currently the execute call will continue on to the
> >> run stage.
> >>
> >> Correct this such that any non-zero return code from the init phase will
> >> abort the test.
> >>
> >> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> >> ---
> >>  test/libtest/test.cpp | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/test/libtest/test.cpp b/test/libtest/test.cpp
> >> index 1bb6ebcb9e8a..9d537ea08698 100644
> >> --- a/test/libtest/test.cpp
> >> +++ b/test/libtest/test.cpp
> >> @@ -20,7 +20,7 @@ int Test::execute()
> >>  	int ret;
> >>
> >>  	ret = init();
> >> -	if (ret < 0)
> >> +	if (ret)
> >
> > To make this more explicit, what about ?
> >         if (ret != TEST_PASS)
> >
>
> I thought about that, and it's actually what I had written first, but
> that's essentially:
>
>  if (ret != 0)
>
> which is equally:
>
>  if (ret)
>
> which we use commonly throughout the code base...

I know the behaviour is the same, my point was to make the TEST_PASS flag
explicit (which makes clear the returning TEST_SKIP from init() is
fine). Up to you, this is very minor stuff.

>
>
>
> > Thanks
> >    j
> >
> >>  		return ret;
> >>
> >>  	ret = run();
> >> --
> >> 2.17.1
> >>
> >> _______________________________________________
> >> libcamera-devel mailing list
> >> libcamera-devel@lists.libcamera.org
> >> https://lists.libcamera.org/listinfo/libcamera-devel
>
> --
> Regards
> --
> Kieran

Patch

diff --git a/test/libtest/test.cpp b/test/libtest/test.cpp
index 1bb6ebcb9e8a..9d537ea08698 100644
--- a/test/libtest/test.cpp
+++ b/test/libtest/test.cpp
@@ -20,7 +20,7 @@  int Test::execute()
 	int ret;
 
 	ret = init();
-	if (ret < 0)
+	if (ret)
 		return ret;
 
 	ret = run();