test-pthread: Check for correct return value from sem_trywait()

At some point `sem_trywait()` changed from returning an error code on
failure to returning -1 and setting the errno. Update test-pthread to
expect this behavior.
This commit is contained in:
Tim Ledbetter 2023-05-13 13:06:50 +01:00 committed by Andreas Kling
parent dab991284f
commit d04968fee4
Notes: sideshowbarker 2024-07-18 01:43:16 +09:00

View file

@ -107,7 +107,8 @@ static ErrorOr<void> test_semaphore_as_lock()
VERIFY(v.size() == threads_count * num_times);
VERIFY(sem_trywait(&semaphore) == 0);
VERIFY(sem_trywait(&semaphore) == EAGAIN);
VERIFY(sem_trywait(&semaphore) == -1);
VERIFY(errno == EAGAIN);
return {};
}
@ -136,7 +137,8 @@ static ErrorOr<void> test_semaphore_as_event()
[[maybe_unused]] auto r1 = reader->join();
[[maybe_unused]] auto r2 = writer->join();
VERIFY(sem_trywait(&semaphore) == EAGAIN);
VERIFY(sem_trywait(&semaphore) == -1);
VERIFY(errno == EAGAIN);
return {};
}
@ -181,7 +183,8 @@ static ErrorOr<void> test_semaphore_nonbinary()
for (size_t i = 0; i < num; i++) {
VERIFY(sem_trywait(&semaphore) == 0);
}
VERIFY(sem_trywait(&semaphore) == EAGAIN);
VERIFY(sem_trywait(&semaphore) == -1);
VERIFY(errno == EAGAIN);
return {};
}