qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tests/tcg/multiarch/testthread.c: Add pthread_cancel test


From: Alex Bennée
Subject: Re: [PATCH] tests/tcg/multiarch/testthread.c: Add pthread_cancel test
Date: Tue, 12 Jan 2021 20:22:54 +0000
User-agent: mu4e 1.5.7; emacs 28.0.50

Taylor Simpson <tsimpson@quicinc.com> writes:

> ---
>  tests/tcg/multiarch/testthread.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/tests/tcg/multiarch/testthread.c 
> b/tests/tcg/multiarch/testthread.c
> index 810ba5d..b30b4b5 100644
> --- a/tests/tcg/multiarch/testthread.c
> +++ b/tests/tcg/multiarch/testthread.c
> @@ -50,8 +50,29 @@ void test_pthread(void)
>      printf("End of pthread test.\n");
>  }
>  
> +void *thread3_func(void *arg)
> +{
> +    usleep(3 * 1000);
> +    return 0;
> +}
> +
> +void test_cancel(void)
> +{
> +    pthread_t thread;
> +    void *res;
> +
> +    pthread_create(&thread, 0, thread3_func, NULL);
> +    pthread_cancel(thread);
> +    pthread_join(thread, &res);
> +    if (res != PTHREAD_CANCELED) {
> +        puts("ERROR: thread not cancelled");
> +        exit(EXIT_FAILURE);
> +    }

Aside from the signoff line which I need could you add something like:

      printf("End of pthread cancel test.\n");

just to aid debugging.

Thanks,


> +}
> +
>  int main(int argc, char **argv)
>  {
>      test_pthread();
> +    test_cancel();
>      return 0;
>  }


-- 
Alex Bennée



reply via email to

[Prev in Thread] Current Thread [Next in Thread]