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

Function TEST

test/bthread_id_unittest.cpp:60–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60TEST(BthreadIdTest, join_after_destroy) {
61 bthread_id_t id1;
62 int x = 0xdead;
63 ASSERT_EQ(0, bthread_id_create_ranged(&id1, &x, NULL, 2));
64 bthread_id_t id2 = { id1.value + 1 };
65 ASSERT_EQ(get_version(id1), bthread::id_value(id1));
66 ASSERT_EQ(get_version(id1), bthread::id_value(id2));
67 pthread_t th[8];
68 SignalArg args[ARRAY_SIZE(th)];
69 for (size_t i = 0; i < ARRAY_SIZE(th); ++i) {
70 args[i].sleep_us_before_fight = 0;
71 args[i].sleep_us_before_signal = 0;
72 args[i].id = (i == 0 ? id1 : id2);
73 ASSERT_EQ(0, pthread_create(&th[i], NULL, signaller, &args[i]));
74 }
75 void* ret[ARRAY_SIZE(th)];
76 size_t non_null_ret = 0;
77 for (size_t i = 0; i < ARRAY_SIZE(th); ++i) {
78 ASSERT_EQ(0, pthread_join(th[i], &ret[i]));
79 non_null_ret += (ret[i] != NULL);
80 }
81 ASSERT_EQ(1UL, non_null_ret);
82 ASSERT_EQ(0, bthread_id_join(id1));
83 ASSERT_EQ(0, bthread_id_join(id2));
84 ASSERT_EQ(0xdead + 1, x);
85 ASSERT_EQ(get_version(id1) + 5, bthread::id_value(id1));
86 ASSERT_EQ(get_version(id1) + 5, bthread::id_value(id2));
87}
88
89TEST(BthreadIdTest, join_before_destroy) {
90 bthread_id_t id1;

Callers

nothing calls this directly

Calls 15

bthread_id_create_rangedFunction · 0.85
id_valueFunction · 0.85
bthread_id_joinFunction · 0.85
bthread_id_createFunction · 0.85
bthread_id_trylockFunction · 0.85
bthread_id_unlockFunction · 0.85
bthread_usleepFunction · 0.85
bthread_start_urgentFunction · 0.85
bthread_stopFunction · 0.85
bthread_joinFunction · 0.85
bthread_id_list_initFunction · 0.85

Tested by

no test coverage detected