Call SetShmBase() in init_rs
The ShmEventLoop rust test was using /dev/shm/aos and breaking out of
the sandbox. Fix that.
Change-Id: I14db8b500a03a66fef41399c4cea334ff79b217f
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/testing/tmpdir.cc b/aos/testing/tmpdir.cc
index 15e3c13..7287603 100644
--- a/aos/testing/tmpdir.cc
+++ b/aos/testing/tmpdir.cc
@@ -3,16 +3,24 @@
#include <cstdlib>
#include <string>
+#include "aos/ipc_lib/shm_base.h"
+
namespace aos {
namespace testing {
-std::string TestTmpDir() {
+namespace {
+std::string TestTmpDirOr(std::string fallback) {
const char *tmp_dir = std::getenv("TEST_TMPDIR");
if (tmp_dir != nullptr) {
return tmp_dir;
}
- return "/tmp";
+ return fallback;
}
+} // namespace
+
+std::string TestTmpDir() { return TestTmpDirOr("/tmp"); }
+
+void SetTestShmBase() { SetShmBase(TestTmpDirOr(FLAGS_shm_base)); }
} // namespace testing
} // namespace aos