Skip to contentSkip to conversation

Question about the usage of tst_brk()

LTP Xiao Yang 3 participants 6 messages Nov 7, 2018 Library code

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

Hi Jan, Cyril

From old library(i.e. test.h), it seems that only TFAIL, TBROK and TCONF are supported by tst_brkm().

From new library, are only TFAIL, TBROK and TCONF are supported by tst_brk() as well?
I am not sure if tst_brk()should support TWARN.

Best Regards,
Xiao Yang

author
#1 lore raw

Hi,

If only TFAIL, TBROK and TCONF should be supported by tst_brk() in new library, i will add check to mark TWARN and TPASS as invalid.

Best Regards,
Xiao Yang

Quoted 14 lines · Xiao Yang

Hi Jan, Cyril

From old library(i.e. test.h), it seems that only TFAIL, TBROK and TCONF
are supported by tst_brkm().

From new library, are only TFAIL, TBROK and TCONF are supported by
tst_brk() as well?
I am not sure if tst_brk()should support TWARN.

Best Regards,
Xiao Yang

#2 lore raw

Hi!

Quoted 2 lines

If only TFAIL, TBROK and TCONF should be supported by tst_brk() in new library, i will add check to mark TWARN and TPASS as invalid.

First of all I think that tst_brk() will only work with TBROK and TCONF at the moment, see the check_child_status() function, we do handle only TBROK and TCONF in the switch there, anything else will cause the test library to exit with invalid exit value. Well the tst_brk(TPASS, ...) will work by accident since we have to handle zero exit value there as well.

However how the code is now the tst_brk(TPASS, ...) in new library will not account the passed result in the result counters, so it would be a good idea to check what value has been passed to the tst_brk() and allow only TBROK and TCONF there.

If we wanted to enable TPASS and TFAIL we would have to first define sane semantic for it. I guess that something as "exit currect test process and increment result counters" would be reasonable, this could be done with:

lib/tst_test.c +9 -1
index 661fbbfce..b76871b38 100644
@@ -311,7 +311,15 @@ void tst_vbrk_(const char *file, const int lineno, int ttype,
        if (getpid() == lib_pid)
                do_exit(TTYPE_RESULT(ttype));
 
-       exit(TTYPE_RESULT(ttype));
+       switch (TTYPE_RESULT(ttype)) {
+       case TPASS:
+       case TFAIL:
+               update_results(TTYPE_RESULT(ttype));
+               exit(0);
+       break;
+       default:
+               exit(TTYPE_RESULT(ttype));
+       }
 }
 

(beware untested)

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

----- Original Message -----

Quoted 12 lines

Hi!

Quoted 3 lines

If only TFAIL, TBROK and TCONF should be supported by tst_brk() in new library,
i will add check to mark TWARN and TPASS as invalid.

First of all I think that tst_brk() will only work with TBROK and TCONF at the
moment, see the check_child_status() function, we do handle only TBROK and TCONF in the switch there, anything else will cause the test library to exit with invalid exit value. Well the tst_brk(TPASS, ...) will work by accident since we have to handle zero exit value there as well.

Quoted 5 lines

However how the code is now the tst_brk(TPASS, ...) in new library will not account the passed result in the result counters, so it would be a good idea to
check what value has been passed to the tst_brk() and allow only TBROK and TCONF there.

tst_brk is macro in newlib, so maybe we can catch this at compile-time?

Quoted 4 lines

If we wanted to enable TPASS and TFAIL we would have to first define sane semantic for it. I guess that something as "exit currect test process and increment result counters" would be reasonable, this could be done with:

tst_brk() always suggested to me that this is somehow unusual termination of test - something's not right with environment or test itself.

Our docs say "Printf-like function to report error and exit the test", so my preference would to not use it for "good" outcomes.

Regards,
Jan

#4 lore raw

Hi!

Quoted 1 line

tst_brk is macro in newlib, so maybe we can catch this at compile-time?

Interesting idea, will you look into that?

Quoted 9 lines
Quoted 3 lines

If we wanted to enable TPASS and TFAIL we would have to first define sane semantic for it. I guess that something as "exit currect test process and increment result counters" would be reasonable, this could be done with:

tst_brk() always suggested to me that this is somehow unusual termination of test - something's not right with environment or test itself.

Our docs say "Printf-like function to report error and exit the test", so my preference would to not use it for "good" outcomes.

Well yes, the name suggests that.

Maybe we just need a few more reporting functions, I was thinking of adding tst_chk() that would print PASS/FAIL based on expression passed as first argument, since it seems that several people wanted to have something like this.

Signature · 2 lines
Cyril Hrubis
[email protected]
#5 lore raw

----- Original Message -----

Quoted 4 lines

Hi!

Quoted 1 line

tst_brk is macro in newlib, so maybe we can catch this at compile-time?

Interesting idea, will you look into that?

Yes, I can.

Quoted 22 lines
Quoted 10 lines
Quoted 4 lines

If we wanted to enable TPASS and TFAIL we would have to first define sane semantic for it. I guess that something as "exit currect test process and increment result counters" would be reasonable, this could be done with:

tst_brk() always suggested to me that this is somehow unusual termination of test - something's not right with environment or test itself.

Our docs say "Printf-like function to report error and exit the test", so my preference would to not use it for "good" outcomes.

Well yes, the name suggests that.

Maybe we just need a few more reporting functions, I was thinking of adding tst_chk() that would print PASS/FAIL based on expression passed as first argument, since it seems that several people wanted to have something like this.

--
Cyril Hrubis
[email protected]