This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 5/6] nptl: Convert some rwlock tests to use libsupport
- From: Florian Weimer <fweimer at redhat dot com>
- To: Mike Crowe <mac at mcrowe dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 05 Apr 2019 13:05:55 +0200
- Subject: Re: [PATCH 5/6] nptl: Convert some rwlock tests to use libsupport
- References: <cover.13c2d68f411f9010956e8e52edfbe168964e1e5c.1553797867.git-series.mac@mcrowe.com> <cover.13c2d68f411f9010956e8e52edfbe168964e1e5c.1553797867.git-series.mac@mcrowe.com> <286b598d77c33052867a27e071409e8c0e3ce8cf.1553797867.git-series.mac@mcrowe.com>
* Mike Crowe:
> if (pthread_rwlock_wrlock (&r) != 0)
> if (pthread_barrier_init (&b, NULL, 2) != 0)
We have xpthread_rwlock_wrlock and xpthread_barrier_init, which will
perform the error checking for you. Similarly for a few more functions.
> if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
> - {
> - puts ("clock_gettime failed");
> - return 1;
> - }
> + FAIL_RET ("clock_gettime failed");
Perhaps it's time to introduce xclock_gettime?
> int e = pthread_rwlock_timedrdlock (&r, &ts);
> if (e == 0)
> - {
> - puts ("first rwlock_timedrdlock did not fail");
> - result = 1;
> - }
> + FAIL_PRINT ("first rwlock_timedrdlock did not fail");
> else if (e != EINVAL)
> - {
> - puts ("first rwlock_timedrdlock did not return EINVAL");
> - result = 1;
> - }
> + FAIL_PRINT ("first rwlock_timedrdlock did not return EINVAL");
You could use
TEST_COMPARE (pthread_rwlock_timedrdlock (&r, &ts), EINVAL);
instead.
Thanks,
Florian