Brian Silverman | f5f8d8e | 2015-12-06 18:39:12 -0500 | [diff] [blame] | 1 | #ifndef AOS_TESTING_TEST_LOGGING_H_ |
| 2 | #define AOS_TESTING_TEST_LOGGING_H_ |
| 3 | |
Austin Schuh | 82c0c82 | 2019-05-27 19:55:20 -0700 | [diff] [blame] | 4 | #include "aos/time/time.h" |
| 5 | |
Brian Silverman | f5f8d8e | 2015-12-06 18:39:12 -0500 | [diff] [blame] | 6 | namespace aos { |
| 7 | namespace testing { |
| 8 | |
| 9 | // Enables the logging framework for use during a gtest test. |
| 10 | // It will print out all WARNING and above messages all of the time. It will |
| 11 | // also print out all log messages when a test fails. |
| 12 | // This function only needs to be called once in each process (after gtest is |
| 13 | // initialized), however it can be called more than that. |
| 14 | void EnableTestLogging(); |
| 15 | |
| 16 | // Redirect the messages enabled by EnableTestLogging() function to a file. |
| 17 | // By default the messages are printed to standard output. |
| 18 | void SetLogFileName(const char* filename); |
| 19 | |
| 20 | // Force the messages to be printed as they are handled by the logging |
| 21 | // framework. This can be useful for tests that hang where no messages would |
| 22 | // otherwise be printed. This is also useful for tests that do pass, but where |
| 23 | // we want to use graphing tools to verify what's happening. |
| 24 | void ForcePrintLogsDuringTests(); |
| 25 | |
Austin Schuh | 82c0c82 | 2019-05-27 19:55:20 -0700 | [diff] [blame] | 26 | // Sets the current mock logging time to monotonic_now. This only applies to |
| 27 | // the current thread. |
| 28 | void MockTime(::aos::monotonic_clock::time_point monotonic_now); |
| 29 | // Clears the mock logging time for the current thread and goes back to using |
| 30 | // monotonic_clock::now(). |
| 31 | void UnMockTime(); |
| 32 | |
Brian Silverman | f5f8d8e | 2015-12-06 18:39:12 -0500 | [diff] [blame] | 33 | } // namespace testing |
| 34 | } // namespace aos |
| 35 | |
| 36 | #endif // AOS_TESTING_TEST_LOGGING_H_ |