From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH 5/5] nptl/tst-abstime: Use libsupport
Date: Thu, 9 May 2019 14:26:32 -0300 [thread overview]
Message-ID: <dab94e74-038a-247a-fefe-d3e6b978593a@linaro.org> (raw)
In-Reply-To: <c710db8ecd52bca5af632c1645e2a7cfd939fdb1.1556830454.git-series.mac@mcrowe.com>
On 02/05/2019 17:54, Mike Crowe wrote:
> * nptl/tst-abstime.c: Use libsupport.
LGTM, I will push it for you.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> ChangeLog | 4 +++-
> nptl/tst-abstime.c | 70 ++++++++++++-----------------------------------
> 2 files changed, 22 insertions(+), 52 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 3b73b4a..12736f5 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,9 @@
> 2019-05-02 Mike Crowe <mac@mcrowe.com>
>
> + * nptl/tst-abstime.c: Use libsupport.
> +
> +2019-05-02 Mike Crowe <mac@mcrowe.com>
> +
> * nptl/tst-rwlock6.c: Use libsupport. This also happens to fix a
> small bug where only tv.tv_usec was checked which could cause an
> erroneous pass if pthread_rwlock_timedrdlock incorrectly took more
> diff --git a/nptl/tst-abstime.c b/nptl/tst-abstime.c
> index 71610f8..56fb8a5 100644
> --- a/nptl/tst-abstime.c
> +++ b/nptl/tst-abstime.c
> @@ -20,6 +20,8 @@
> #include <pthread.h>
> #include <semaphore.h>
> #include <stdio.h>
> +#include <support/check.h>
> +#include <support/xthread.h>
>
> static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
> static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER;
> @@ -31,67 +33,31 @@ static sem_t sem;
> static void *
> th (void *arg)
> {
> - long int res = 0;
> - int r;
> struct timespec t = { -2, 0 };
>
> - r = pthread_mutex_timedlock (&m1, &t);
> - if (r != ETIMEDOUT)
> - {
> - puts ("pthread_mutex_timedlock did not return ETIMEDOUT");
> - res = 1;
> - }
> - r = pthread_rwlock_timedrdlock (&rw1, &t);
> - if (r != ETIMEDOUT)
> - {
> - puts ("pthread_rwlock_timedrdlock did not return ETIMEDOUT");
> - res = 1;
> - }
> - r = pthread_rwlock_timedwrlock (&rw2, &t);
> - if (r != ETIMEDOUT)
> - {
> - puts ("pthread_rwlock_timedwrlock did not return ETIMEDOUT");
> - res = 1;
> - }
> - return (void *) res;
> + TEST_COMPARE (pthread_mutex_timedlock (&m1, &t), ETIMEDOUT);
> + TEST_COMPARE (pthread_rwlock_timedrdlock (&rw1, &t), ETIMEDOUT);
> + TEST_COMPARE (pthread_rwlock_timedwrlock (&rw2, &t), ETIMEDOUT);
> + return NULL;
> }
>
> static int
> do_test (void)
> {
> - int res = 0;
> - int r;
> struct timespec t = { -2, 0 };
> - pthread_t pth;
>
> sem_init (&sem, 0, 0);
> - r = sem_timedwait (&sem, &t);
> - if (r != -1 || errno != ETIMEDOUT)
> - {
> - puts ("sem_timedwait did not fail with ETIMEDOUT");
> - res = 1;
> - }
> -
> - pthread_mutex_lock (&m1);
> - pthread_rwlock_wrlock (&rw1);
> - pthread_rwlock_rdlock (&rw2);
> - pthread_mutex_lock (&m2);
> - if (pthread_create (&pth, 0, th, 0) != 0)
> - {
> - puts ("cannot create thread");
> - return 1;
> - }
> - r = pthread_cond_timedwait (&c, &m2, &t);
> - if (r != ETIMEDOUT)
> - {
> - puts ("pthread_cond_timedwait did not return ETIMEDOUT");
> - res = 1;
> - }
> - void *thres;
> - pthread_join (pth, &thres);
> - return res | (thres != NULL);
> + TEST_COMPARE (sem_timedwait (&sem, &t), -1);
> + TEST_COMPARE (errno, ETIMEDOUT);
> +
> + xpthread_mutex_lock (&m1);
> + xpthread_rwlock_wrlock (&rw1);
> + xpthread_rwlock_rdlock (&rw2);
> + xpthread_mutex_lock (&m2);
> + pthread_t pth = xpthread_create (0, th, 0);
> + TEST_COMPARE (pthread_cond_timedwait (&c, &m2, &t), ETIMEDOUT);
> + xpthread_join (pth);
> + return 0;
> }
>
> -
> -#define TEST_FUNCTION do_test ()
> -#include "../test-skeleton.c"
> +#include <support/test-driver.c>
>
next prev parent reply other threads:[~2019-05-09 17:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-02 20:54 [PATCH 0/5] Add new helper functions+macros to libsupport and use them in some nptl tests Mike Crowe
2019-05-02 20:54 ` [PATCH 1/5] support: Add xclock_gettime Mike Crowe
2019-05-08 13:46 ` Florian Weimer
2019-05-08 14:22 ` Mike Crowe
2019-05-08 15:00 ` Florian Weimer
2019-05-08 16:17 ` Mike Crowe
2019-05-08 15:11 ` Adhemerval Zanella
2019-05-02 20:54 ` [PATCH 2/5] nptl: Convert tst-cond11.c to use libsupport Mike Crowe
2019-05-09 16:39 ` Adhemerval Zanella
2019-05-09 17:08 ` Florian Weimer
2019-05-09 17:16 ` Adhemerval Zanella
2019-05-09 23:03 ` Joseph Myers
2019-05-10 9:42 ` Adhemerval Zanella
2019-05-10 12:20 ` Adhemerval Zanella
2019-05-10 12:22 ` Florian Weimer
2019-05-02 20:54 ` [PATCH 3/5] nptl: Use recent additions to libsupport in tst-sem5 Mike Crowe
2019-05-09 16:55 ` Adhemerval Zanella
2019-05-02 20:54 ` [PATCH 4/5] nptl: Convert some rwlock tests to use libsupport Mike Crowe
2019-05-09 17:25 ` Adhemerval Zanella
2019-05-02 20:54 ` [PATCH 5/5] nptl/tst-abstime: Use libsupport Mike Crowe
2019-05-09 17:26 ` Adhemerval Zanella [this message]
2019-05-03 20:38 ` [PATCH 0/5] Add new helper functions+macros to libsupport and use them in some nptl tests Mike Crowe
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dab94e74-038a-247a-fefe-d3e6b978593a@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).