realtime:async_handler_jk: return actual exit code
PATCH 1/6 realtime:async_handler_jk: return actual exit code
The original version always returned 0.
--- testcases/realtime/func/async_handler/async_handler_jk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
testcases/realtime/func/async_handler/async_handler_jk.c +4 -2
@@ -137,6 +137,7 @@ int main(int argc, char *argv[]) {int aes_id;// asynchronous event server id int user_id;// User thread - that fires the event +int result;long delta;struct thread *server;setup ();
@@ -155,10 +156,11 @@ int main(int argc, char *argv[])join_thread (user_id);join_threads (); delta = (end - start) /NS_PER_US ; + result = delta > pass_criteria ?1 :0 ;printf ("delta = %ld us\n" , delta);printf ("\nCriteria: latencies < %d\n" , (int )pass_criteria); -printf ("Result: %s\n" , delta > pass_criteria ?"FAIL" :"PASS" ); +printf ("Result: %s\n" , result ?"FAIL" :"PASS" ); -return 0 ; +return result; }
Signature · 1 line
2.32.0
PATCH 2/6 rt:pi-tests::sbrk_mutex: return actual exit code
The original version always returned 0.
--- testcases/realtime/func/pi-tests/sbrk_mutex.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
testcases/realtime/func/pi-tests/sbrk_mutex.c +8 -4
@@ -97,7 +97,8 @@ void *worker_thread(void *arg)int main (int argc,char *argv[]) { -int m, ret, robust; +int m, robust; +int ret =0 ;intptr_t t;pthread_mutexattr_t mutexattr;setup ();
@@ -123,7 +124,8 @@ int main(int argc, char *argv[])if (!(mutexes[m] =malloc (sizeof (pthread_mutex_t)))) {perror ("malloc failed\n" ); } -if ((ret =pthread_mutex_init (mutexes[m], &mutexattr))) { +if (pthread_mutex_init (mutexes[m], &mutexattr)) { + ret =1 ;perror ("pthread_mutex_init() failed\n" ); } }
@@ -140,11 +142,13 @@ int main(int argc, char *argv[])/* destroy all the mutexes */ for (m =0 ; m <NUM_MUTEXES ; m++) {if (mutexes[m]) { -if ((ret =pthread_mutex_destroy (mutexes[m]))) +if (pthread_mutex_destroy (mutexes[m])) { + ret =1 ;perror ("pthread_mutex_destroy() failed\n" ); + }free (mutexes[m]); } } -return 0 ; +return ret; }
Signature · 1 line
2.32.0
Re: [LTP] [PATCH v1 2/6] rt:pi-tests::sbrk_mutex: return actual exit code
Hi!
I'm looking on how the pi-tests are supposed to be executed and it seems that the return value does not seems to matter at all.
Each of these tests is executed by run_c_files.sh script that writes the output into a logfile then a python script is used to parse the logfile.
I think that if we want to fix the realtime tests we should simplify this mess first.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/6 rt:pi-tests:testpi-0: return actual exit code
In reply to Bogdan LezhepekovThe original version always returned 0.
--- testcases/realtime/func/pi-tests/testpi-0.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/realtime/func/pi-tests/testpi-0.c +3 -1
@@ -94,8 +94,10 @@ int main(int argc, char *argv[])printf ("LIBPTHREAD_VERSION: %s\n" , pathbuf);free (pathbuf); -if (sysconf (_SC_THREAD_PRIO_INHERIT) ==-1 ) +if (sysconf (_SC_THREAD_PRIO_INHERIT) ==-1 ) {printf ("No Prio inheritance support\n" ); +exit (1 ); + }printf ("Prio inheritance support present\n" );
Signature · 1 line
2.32.0
PATCH 4/6 rt:pi-tests:test-skeleton: fix wrong return value
In reply to Bogdan Lezhepekov--- testcases/realtime/func/pi-tests/test-skeleton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/realtime/func/pi-tests/test-skeleton.c +1 -1
@@ -88,7 +88,7 @@ static void timeout_handler(int sig)exit (1 ); }printf ("\nResult:PASS\n" ); -exit (1 ); +exit (0 ); }int main (int argc,char **argv)
Signature · 1 line
2.32.0
PATCH 5/6 rt:pi-tests:testpi-5: return exit code
In reply to Bogdan Lezhepekov--- testcases/realtime/func/pi-tests/testpi-5.c | 24 ++++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-)
testcases/realtime/func/pi-tests/testpi-5.c +16 -8
@@ -68,29 +68,37 @@ int do_test(int argc, char **argv) {pthread_mutexattr_t mutexattr;int retc, protocol; +unsigned int err =0 ;#if HAS_PRIORITY_INHERIT -if (pthread_mutexattr_init (&mutexattr) !=0 ) +if (pthread_mutexattr_init (&mutexattr) !=0 ) {printf ("Failed to init mutexattr\n" ); + err++; + }if (pthread_mutexattr_setprotocol (&mutexattr, -PTHREAD_PRIO_INHERIT ) !=0 ) +PTHREAD_PRIO_INHERIT ) !=0 ) {printf ("Can't set protocol prio inherit\n" ); - -if (pthread_mutexattr_getprotocol (&mutexattr, &protocol) !=0 ) + err++; + } + +if (pthread_mutexattr_getprotocol (&mutexattr, &protocol) !=0 ) {printf ("Can't get mutexattr protocol\n" ); -else + err++; + }else printf ("protocol in mutexattr is %d\n" , protocol); - + retc =pthread_mutex_init (&child_mutex, &mutexattr); -if (retc !=0 ) +if (retc !=0 ) {printf ("Failed to init mutex: %d\n" , retc); + err++; + }create_other_thread (child_thread,NULL );join_threads (); -return 0 ; +return err >0 ?1 :0 ;#else return 1 ;#endif
Signature · 1 line
2.32.0
Re: [LTP] [PATCH v1 5/6] rt:pi-tests:testpi-5: return exit code
Hi Bogdan,
Quoted 1 line
+++
b/testcases/realtime/func/pi-tests/testpi-5.c
...
testcases/realtime/func/pi-tests/testpi-5.c int do_test(int argc, char **argv) · line 101
Quoted 5 lines
testcases/realtime/func/pi-tests/testpi-5.c +1
-1create_other_thread (child_thread,NULL );join_threads (); -return 0 ; +return err >0 ?1 :0 ;
nit: "1: 0" => "1 : 0" (for better readability).
Whole patchset LGTM, thanks for improving realtime tests.
To whole patchset:
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Bogdan Lezhepekov via ltp
Reviewed-by Petr VorelRe: [LTP] [PATCH v1 5/6] rt:pi-tests:testpi-5: return exit code
Hi Petr,
Thanks for reviewing!
-Bogdan
________________________________
From: Petr Vorel <[email protected]>
Sent: Friday, September 24, 2021 12:53
To: Bogdan Lezhepekov <[email protected]>
Cc: [email protected] <[email protected]>; Cyril Hrubis <[email protected]>
Subject: Re: [LTP] [PATCH v1 5/6] rt:pi-tests:testpi-5: return exit code
Hi Bogdan,
Quoted 1 line
+++
b/testcases/realtime/func/pi-tests/testpi-5.c
...
testcases/realtime/func/pi-tests/testpi-5.c int do_test(int argc, char **argv) · line 101
Quoted 5 lines
create_other_thread(child_thread, NULL); join_threads();testcases/realtime/func/pi-tests/testpi-5.c +1
-1-return 0 ; +return err >0 ?1 :0 ;
nit: "1: 0" => "1 : 0" (for better readability).
Whole patchset LGTM, thanks for improving realtime tests.
To whole patchset:
Kind regards,
Petr
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 6/6 rt:pi-tests:testpi-6: return exit code
In reply to Bogdan Lezhepekov--- testcases/realtime/func/pi-tests/testpi-6.c | 22 ++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
testcases/realtime/func/pi-tests/testpi-6.c +15 -7
@@ -69,27 +69,35 @@ int do_test(int argc, char **argv) {pthread_mutexattr_t mutexattr;int retc, robust; +unsigned int err; -if (pthread_mutexattr_init (&mutexattr) !=0 ) +if (pthread_mutexattr_init (&mutexattr) !=0 ) {printf ("Failed to init mutexattr\n" ); + err++; + }if (pthread_mutexattr_setrobust (&mutexattr, -PTHREAD_MUTEX_ROBUST ) !=0 ) +PTHREAD_MUTEX_ROBUST ) !=0 ) {printf ("Can't set robust mutex\n" ); - -if (pthread_mutexattr_getrobust (&mutexattr, &robust) !=0 ) + err++; + } + +if (pthread_mutexattr_getrobust (&mutexattr, &robust) !=0 ) {printf ("Can't get mutexattr protocol\n" ); -else + err++; + }else printf ("robust in mutexattr is %d\n" , robust); retc =pthread_mutex_init (&child_mutex, &mutexattr); -if (retc !=0 ) +if (retc !=0 ) {printf ("Failed to init mutex: %d\n" , retc); + err++; + }create_other_thread (child_thread,NULL );join_threads (); -return 0 ; +return err >0 ?1 :0 ; }#include "test-skeleton.c"
Signature · 1 line
2.32.0