Make floating point tests Android-compatible
PATCH 1/1 Make floating point tests Android-compatible
Android does not implement pthread_cancel. The function is replaced by a no-op in a compatibility header. In most cases, the only side effect is that threads cannot be interrupted and have to exit normally. However, floating point tests are calling pthread_cancel and waiting for a thread doing pthread_sigwait to be finished (Which will never happen).
This patch implements the same logic using pthread_kill with SIGUSR2 instead, allowing the tests to run under Android.
--- testcases/misc/math/float/main.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
(quoted diff) +0 -0
b/testcases/misc/math/float/main.c
index d71ca18e6..64d1475e4 100644
testcases/misc/math/float/main.c +19 -1
@@ -115,6 +115,18 @@ int main(int argc, char *argv[])/*int time=1; */ int i; +sigset_t signals_set; + +/* +* Use SIGUSR2 to terminate our signal handler +*/ +sigemptyset (&signals_set); +sigaddset (&signals_set,SIGUSR2 ); + + retval =pthread_sigmask (SIG_BLOCK , &signals_set,NULL ); +if (retval !=0 ) +sys_error ("main : pthread_sigmask FAILED" , __LINE__); +/* Generate test ID from invocation name */ if ((TCID =strrchr (argv[0 ],'/' )) !=NULL )TCID ++;
@@ -299,7 +311,7 @@ finished:SAFE_FREE (pcom); } -pthread_cancel (sig_hand); +pthread_kill (sig_hand,SIGUSR2 );pthread_join (sig_hand,NULL );SAFE_FREE (tabcom);SAFE_FREE (threads);
@@ -338,6 +350,7 @@ static void *handle_signals(void *arg)sigaddset (&signals_set,SIGQUIT );sigaddset (&signals_set,SIGTERM );sigaddset (&signals_set,SIGUSR1 ); +sigaddset (&signals_set,SIGUSR2 );sigaddset (&signals_set,SIGALRM );while (1 ) {if (debug)
@@ -348,6 +361,11 @@ static void *handle_signals(void *arg)tst_resm (TINFO ,"Signal handler caught signal %d" , sig);switch (sig) { +case SIGUSR2 : +if (debug) +tst_resm (TINFO ,"Signal handler received termination request, exiting" ); +pthread_exit (NULL ); +break ;case SIGALRM :case SIGUSR1 :case SIGINT :
Signature · 4 lines
2.16.1.291.g4437f3f132-goog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20180221/5b333606/attachment.html>
PATCH 1/1 Make floating point tests Android-compatible
Hi,
Any chance this can be reviewed? This would add support for 4 tests on Android.
Thanks
Quoted 68 lines · Erick Reyes
Android does not implement
pthread_cancel. The function is replaced by a no-op in a compatibility header. In most cases, the only side effect is that threads cannot be interrupted and have to exit normally. However, floating point tests are callingpthread_canceland waiting for a thread doingpthread_sigwaitto be finished (Which will never happen).This patch implements the same logic using
pthread_killwith SIGUSR2 instead, allowing the tests to run under Android.Signed-off-by Erick Reyes <[email protected]>--- testcases/misc/math/float/main.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)testcases/misc/math/float/ renamed from testcases/misc/math/float/main.c +0
-0
main.c
indexd71ca18e6..64d1475e4100644testcases/misc/math/float/main.c +19
-2@@ -115,6 +115,18 @@ int main(int argc, char *argv[])/*int time=1; */ int i; +sigset_t signals_set; + +/* +* Use SIGUSR2 to terminate our signal handler +*/ +sigemptyset (&signals_set); +sigaddset (&signals_set,SIGUSR2 ); + + retval =pthread_sigmask (SIG_BLOCK , &signals_set,NULL ); +if (retval !=0 ) +sys_error ("main : pthread_sigmask FAILED" , __LINE__); +/* Generate test ID from invocation name */ if ((TCID =strrchr (argv[0 ],'/' )) !=NULL )TCID ++;@@ -299,7 +311,7 @@ finished:SAFE_FREE (pcom); } -pthread_cancel (sig_hand); +pthread_kill (sig_hand,SIGUSR2 );pthread_join (sig_hand,NULL );SAFE_FREE (tabcom);SAFE_FREE (threads);@@ -338,6 +350,7 @@ static void *handle_signals(void *arg)sigaddset (&signals_set,SIGQUIT );sigaddset (&signals_set,SIGTERM );sigaddset (&signals_set,SIGUSR1 ); +sigaddset (&signals_set,SIGUSR2 );sigaddset (&signals_set,SIGALRM );while (1 ) {if (debug)@@ -348,6 +361,11 @@ static void *handle_signals(void *arg)tst_resm (TINFO ,"Signal handler caught signal %d" , sig);switch (sig) { +case SIGUSR2 : +if (debug) +tst_resm (TINFO ,"Signal handler received termination request, exiting" ); +pthread_exit (NULL ); +break ;case SIGALRM :case SIGUSR1 :case SIGINT : --
Quoted 3 lines
2.16.1.291.g4437f3f132-goog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180323/baac9241/attachment.html>
PATCH 1/1 Make floating point tests Android-compatible
Hi!
Quoted 2 lines
Any chance this can be reviewed? This would add support for 4 tests on Android.
I will have a look at it soon.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 Make floating point tests Android-compatible
In reply to Erick ReyesHi!
Quoted 8 lines
Android does not implement
pthread_cancel. The function is replaced by a no-op in a compatibility header. In most cases, the only side effect is that threads cannot be interrupted and have to exit normally. However, floating point tests are callingpthread_canceland waiting for a thread doingpthread_sigwaitto be finished (Which will never happen).This patch implements the same logic using
pthread_killwith SIGUSR2 instead, allowing the tests to run under Android.
First of all the patch is mangled, probaly by your email client, check its settings for attachements.
Secondly, looking at the patch, do we really have to join the signal handler thread at the end? Cannot we just delete the the pthreat_cancel() and pthread_join() for the sig_hand and be done with it?
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 Make floating point tests Android-compatible
Hi Cyril,
Thanks for the feedback. I went with your suggestion and submitted a new patch. Hopefully I did it right this time.
Thanks!
Erick
Quoted 13 lines · Cyril Hrubis
Hi!
Quoted 8 lines
Android does not implement
pthread_cancel. The function is replaced by a no-op in a compatibility header. In most cases, the only side effect is that threads cannot be interrupted and have to exit normally. However, floating point tests are callingpthread_canceland waiting for a thread doingpthread_sigwaitto be finished (Which will never happen).This patch implements the same logic using
pthread_killwith SIGUSR2 instead, allowing the tests to run under Android.First of all the patch is mangled, probaly by your email client, check its settings for attachements.
Quoted 9 lines
Secondly, looking at the patch, do we really have to join the signal handler thread at the end? Cannot we just delete the the
pthreat_cancel()andpthread_join()for thesig_handand be done with it?--
Cyril Hrubis
[email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180402/1d7055d4/attachment.html>