This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 5/6] nptl: Convert some rwlock tests to use libsupport


* 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]