Austin Schuh | c243b42 | 2020-10-11 15:35:08 -0700 | [diff] [blame] | 1 | #include "aos/testing/tmpdir.h" |
| 2 | |
| 3 | #include <cstdlib> |
| 4 | #include <string> |
| 5 | |
Adam Snaider | c8b7e75 | 2023-09-14 14:27:53 -0700 | [diff] [blame^] | 6 | #include "aos/ipc_lib/shm_base.h" |
| 7 | |
Austin Schuh | c243b42 | 2020-10-11 15:35:08 -0700 | [diff] [blame] | 8 | namespace aos { |
| 9 | namespace testing { |
| 10 | |
Adam Snaider | c8b7e75 | 2023-09-14 14:27:53 -0700 | [diff] [blame^] | 11 | namespace { |
| 12 | std::string TestTmpDirOr(std::string fallback) { |
Austin Schuh | c243b42 | 2020-10-11 15:35:08 -0700 | [diff] [blame] | 13 | const char *tmp_dir = std::getenv("TEST_TMPDIR"); |
| 14 | if (tmp_dir != nullptr) { |
| 15 | return tmp_dir; |
| 16 | } |
Adam Snaider | c8b7e75 | 2023-09-14 14:27:53 -0700 | [diff] [blame^] | 17 | return fallback; |
Austin Schuh | c243b42 | 2020-10-11 15:35:08 -0700 | [diff] [blame] | 18 | } |
Adam Snaider | c8b7e75 | 2023-09-14 14:27:53 -0700 | [diff] [blame^] | 19 | } // namespace |
| 20 | |
| 21 | std::string TestTmpDir() { return TestTmpDirOr("/tmp"); } |
| 22 | |
| 23 | void SetTestShmBase() { SetShmBase(TestTmpDirOr(FLAGS_shm_base)); } |
Austin Schuh | c243b42 | 2020-10-11 15:35:08 -0700 | [diff] [blame] | 24 | |
| 25 | } // namespace testing |
| 26 | } // namespace aos |