Generates a textual failure message when a death test finds more than one thread running, or cannot determine the number of threads, prior to executing the given statement. It is the responsibility of the caller not to pass a thread_count of 1.
| 7835 | // to executing the given statement. It is the responsibility of the |
| 7836 | // caller not to pass a thread_count of 1. |
| 7837 | static std::string DeathTestThreadWarning(size_t thread_count) { |
| 7838 | Message msg; |
| 7839 | msg << "Death tests use fork(), which is unsafe particularly" |
| 7840 | << " in a threaded context. For this test, " << GTEST_NAME_ << " "; |
| 7841 | if (thread_count == 0) { |
| 7842 | msg << "couldn't detect the number of threads."; |
| 7843 | } else { |
| 7844 | msg << "detected " << thread_count << " threads."; |
| 7845 | } |
| 7846 | msg << " See " |
| 7847 | "https://github.com/google/googletest/blob/master/googletest/docs/" |
| 7848 | "advanced.md#death-tests-and-threads" |
| 7849 | << " for more explanation and suggested solutions, especially if" |
| 7850 | << " this is the last message you see before your test times out."; |
| 7851 | return msg.GetString(); |
| 7852 | } |
| 7853 | # endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA |
| 7854 | |
| 7855 | // Flag characters for reporting a death test that did not die. |