mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 14:28:30 +00:00
Add *NSYNC unit test suite
This change also fixes the clock_nanosleep() api and polyfills futexes on Windows, Mac, and NetBSD using exponential backoff.
This commit is contained in:
parent
3421b9a580
commit
9849b4c7ba
51 changed files with 5505 additions and 1060 deletions
|
@ -48,12 +48,6 @@ TEST(nanosleep, testNoSignalIsDelivered) {
|
|||
ASSERT_SYS(0, 0, nanosleep(&ts, 0));
|
||||
}
|
||||
|
||||
TEST(clock_nanosleep, testNoSignalIsDelivered) {
|
||||
struct timespec ts = {0, 1};
|
||||
ASSERT_SYS(0, 0, clock_nanosleep(CLOCK_REALTIME, 0, &ts, &ts));
|
||||
ASSERT_SYS(0, 0, clock_nanosleep(CLOCK_REALTIME, 0, &ts, 0));
|
||||
}
|
||||
|
||||
TEST(nanosleep, testInterrupt_remIsUpdated) {
|
||||
struct sigaction sa = {
|
||||
.sa_handler = OnAlrm,
|
||||
|
@ -68,3 +62,24 @@ TEST(nanosleep, testInterrupt_remIsUpdated) {
|
|||
ASSERT_GT(ts.tv_sec, 400);
|
||||
ASSERT_NE(0, ts.tv_nsec);
|
||||
}
|
||||
|
||||
TEST(clock_nanosleep, testNoSignalIsDelivered) {
|
||||
struct timespec ts = {0, 1};
|
||||
ASSERT_EQ(0, clock_nanosleep(CLOCK_REALTIME, 0, &ts, &ts));
|
||||
ASSERT_EQ(0, clock_nanosleep(CLOCK_REALTIME, 0, &ts, 0));
|
||||
}
|
||||
|
||||
TEST(clock_nanosleep, testInterrupt_remIsUpdated) {
|
||||
struct sigaction sa = {
|
||||
.sa_handler = OnAlrm,
|
||||
.sa_flags = SA_RESETHAND,
|
||||
};
|
||||
ASSERT_SYS(0, 0, sigaction(SIGALRM, &sa, 0));
|
||||
struct itimerval it = {{0, 0}, {0, 10000}}; // 10ms singleshot
|
||||
ASSERT_SYS(0, 0, setitimer(ITIMER_REAL, &it, 0));
|
||||
struct timespec ts = {500, 0};
|
||||
ASSERT_EQ(EINTR, clock_nanosleep(CLOCK_REALTIME, 0, &ts, &ts));
|
||||
ASSERT_LT(ts.tv_sec, 500);
|
||||
ASSERT_GT(ts.tv_sec, 400);
|
||||
ASSERT_NE(0, ts.tv_nsec);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue