All of lore.kernel.org
 help / color / mirror / Atom feed
From: Erick Reyes <erickreyes@google.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] Make floating point tests Android-compatible
Date: Fri, 23 Mar 2018 13:57:15 -0700	[thread overview]
Message-ID: <CAFt2AZVFWwZt1JD0kZ-5s0SGkAbwo_igiDKJzkus-0sjQk_ARw@mail.gmail.com> (raw)
In-Reply-To: <CAFt2AZUhp9tuWOVd-t-ij-eG-21+DEqeXE5XCwK=tQ8DmOnAgg@mail.gmail.com>

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>

  reply	other threads:[~2018-03-23 20:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-21 19:48 [LTP] [PATCH] Make floating point tests Android-compatible Erick Reyes
2018-03-23 20:57 ` Erick Reyes [this message]
2018-03-26 11:18   ` Cyril Hrubis
2018-03-27 14:08 ` Cyril Hrubis
2018-04-03  1:41   ` Erick Reyes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFt2AZVFWwZt1JD0kZ-5s0SGkAbwo_igiDKJzkus-0sjQk_ARw@mail.gmail.com \
    --to=erickreyes@google.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.