| 639 | |
| 640 | #ifdef BRPC_BTHREAD_TRACER |
| 641 | void 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 | |
| 670 | void repeated_sleep_trace() { |
| 671 | bool ok = false; |
no test coverage detected