All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] Make floating point tests Android-compatible
@ 2018-02-21 19:48 Erick Reyes
  2018-03-23 20:57 ` Erick Reyes
  2018-03-27 14:08 ` Cyril Hrubis
  0 siblings, 2 replies; 5+ messages in thread
From: Erick Reyes @ 2018-02-21 19:48 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Erick Reyes <erickreyes@google.com>
---
 testcases/misc/math/float/main.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/testcases/misc/math/float/main.c
b/testcases/misc/math/float/main.c
index d71ca18e6..64d1475e4 100644
--- a/testcases/misc/math/float/main.c
+++ b/testcases/misc/math/float/main.c
@@ -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:
-- 
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>

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] Make floating point tests Android-compatible
  2018-02-21 19:48 [LTP] [PATCH] Make floating point tests Android-compatible Erick Reyes
@ 2018-03-23 20:57 ` Erick Reyes
  2018-03-26 11:18   ` Cyril Hrubis
  2018-03-27 14:08 ` Cyril Hrubis
  1 sibling, 1 reply; 5+ messages in thread
From: Erick Reyes @ 2018-03-23 20:57 UTC (permalink / raw)
  To: ltp

Hi,

Any chance this can be reviewed? This would add support for 4 tests on
Android.

Thanks

On Wed, Feb 21, 2018 at 11:48 AM, Erick Reyes <erickreyes@google.com> wrote:

> 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.
>
> Signed-off-by: Erick Reyes <erickreyes@google.com>
> ---
>  testcases/misc/math/float/main.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/misc/math/float/main.c b/testcases/misc/math/float/
> main.c
> index d71ca18e6..64d1475e4 100644
> --- a/testcases/misc/math/float/main.c
> +++ b/testcases/misc/math/float/main.c
> @@ -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:
> --
> 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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] Make floating point tests Android-compatible
  2018-03-23 20:57 ` Erick Reyes
@ 2018-03-26 11:18   ` Cyril Hrubis
  0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2018-03-26 11:18 UTC (permalink / raw)
  To: ltp

Hi!
> Any chance this can be reviewed? This would add support for 4 tests on
> Android.

I will have a look at it soon.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] Make floating point tests Android-compatible
  2018-02-21 19:48 [LTP] [PATCH] Make floating point tests Android-compatible Erick Reyes
  2018-03-23 20:57 ` Erick Reyes
@ 2018-03-27 14:08 ` Cyril Hrubis
  2018-04-03  1:41   ` Erick Reyes
  1 sibling, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2018-03-27 14:08 UTC (permalink / raw)
  To: ltp

Hi!
> 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.

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?

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] Make floating point tests Android-compatible
  2018-03-27 14:08 ` Cyril Hrubis
@ 2018-04-03  1:41   ` Erick Reyes
  0 siblings, 0 replies; 5+ messages in thread
From: Erick Reyes @ 2018-04-03  1:41 UTC (permalink / raw)
  To: ltp

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

On Tue, Mar 27, 2018 at 7:08 AM, Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > 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.
>
> 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?
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180402/1d7055d4/attachment.html>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-03  1:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21 19:48 [LTP] [PATCH] Make floating point tests Android-compatible Erick Reyes
2018-03-23 20:57 ` Erick Reyes
2018-03-26 11:18   ` Cyril Hrubis
2018-03-27 14:08 ` Cyril Hrubis
2018-04-03  1:41   ` Erick Reyes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.