MCPcopy Create free account
hub / github.com/apache/brpc / TEST

Function TEST

test/bthread_mutex_unittest.cpp:47–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47TEST(MutexTest, sanity) {
48 bthread_mutex_t m;
49 ASSERT_EQ(0, bthread_mutex_init(&m, NULL));
50 ASSERT_EQ(0u, *get_butex(m));
51 ASSERT_EQ(0, bthread_mutex_lock(&m));
52 ASSERT_EQ(1u, *get_butex(m));
53 bthread_t th1;
54 ASSERT_EQ(0, bthread_start_urgent(&th1, NULL, locker, &m));
55 usleep(5000); // wait for locker to run.
56 ASSERT_EQ(257u, *get_butex(m)); // contention
57 ASSERT_EQ(0, bthread_mutex_unlock(&m));
58 ASSERT_EQ(0, bthread_join(th1, NULL));
59 ASSERT_EQ(0u, *get_butex(m));
60 ASSERT_EQ(0, bthread_mutex_destroy(&m));
61}
62
63TEST(MutexTest, used_in_pthread) {
64 bthread_mutex_t m;

Callers

nothing calls this directly

Calls 15

bthread_mutex_initFunction · 0.85
get_butexFunction · 0.85
bthread_mutex_lockFunction · 0.85
bthread_start_urgentFunction · 0.85
bthread_mutex_unlockFunction · 0.85
bthread_joinFunction · 0.85
bthread_mutex_destroyFunction · 0.85
bthread_cond_initFunction · 0.85
bthread_cond_timedwaitFunction · 0.85
bthread_setconcurrencyFunction · 0.85
bthread_usleepFunction · 0.85
pthread_mutex_initFunction · 0.85

Tested by

no test coverage detected