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

Function spin_and_log_trace

test/bthread_unittest.cpp:641–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639
640#ifdef BRPC_BTHREAD_TRACER
641void spin_and_log_trace() {
642 bool ok = false;
643 for (int i = 0; i < 10; ++i) {
644 start = false;
645 stop = false;
646 bthread_t th;
647 ASSERT_EQ(0, bthread_start_urgent(&th, NULL, spin_and_log, (void*)1));
648 while (!start) {
649 usleep(10 * 1000);
650 }
651
652 std::string st1 = bthread::stack_trace(th);
653 LOG(INFO) << "spin_and_log stack trace:\n" << st1;
654 ok = st1.find("spin_and_log") != std::string::npos;
655
656 stop = true;
657 ASSERT_EQ(0, bthread_join(th, NULL));
658
659 std::string st2 = bthread::stack_trace(th);
660 LOG(INFO) << "ended bthread stack trace:\n" << st2;
661 ASSERT_NE(std::string::npos, st2.find("not exist now"));
662
663 if (ok) {
664 break;
665 }
666 }
667 ASSERT_TRUE(ok);
668}
669
670void repeated_sleep_trace() {
671 bool ok = false;

Callers 1

TEST_FFunction · 0.85

Calls 4

bthread_start_urgentFunction · 0.85
stack_traceFunction · 0.85
bthread_joinFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected