| 41 | } |
| 42 | |
| 43 | TEST(SemaphoreTest, sanity) { |
| 44 | bthread_sem_t sem; |
| 45 | ASSERT_EQ(0, bthread_sem_init(&sem, 1)); |
| 46 | ASSERT_EQ(0, bthread_sem_wait(&sem)); |
| 47 | ASSERT_EQ(0, bthread_sem_post(&sem)); |
| 48 | ASSERT_EQ(0, bthread_sem_wait(&sem)); |
| 49 | |
| 50 | bthread_t waiter_th; |
| 51 | bthread_t poster_th; |
| 52 | ASSERT_EQ(0, bthread_start_urgent(&waiter_th, NULL, sem_waiter, &sem)); |
| 53 | ASSERT_EQ(0, bthread_start_urgent(&poster_th, NULL, sem_poster, &sem)); |
| 54 | ASSERT_EQ(0, bthread_join(waiter_th, NULL)); |
| 55 | ASSERT_EQ(0, bthread_join(poster_th, NULL)); |
| 56 | |
| 57 | ASSERT_EQ(0, bthread_sem_destroy(&sem)); |
| 58 | } |
| 59 | |
| 60 | |
| 61 |
nothing calls this directly
no test coverage detected