diff --git a/msgq/event.cc b/msgq/event.cc index be782e3b..31fda326 100644 --- a/msgq/event.cc +++ b/msgq/event.cc @@ -21,7 +21,11 @@ void event_state_shm_mmap(std::string endpoint, std::string identifier, char **shm_mem, std::string *shm_path) { const char* op_prefix = std::getenv("OPENPILOT_PREFIX"); - std::string full_path = "/dev/shm/"; + #ifdef __APPLE__ + std::string full_path = "/tmp/"; + #else + std::string full_path = "/dev/shm/"; + #endif if (op_prefix) { full_path += std::string(op_prefix) + "/"; } diff --git a/msgq/msgq.cc b/msgq/msgq.cc index 5ce25a3b..76542b6e 100644 --- a/msgq/msgq.cc +++ b/msgq/msgq.cc @@ -87,7 +87,11 @@ int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size){ assert(size < 0xFFFFFFFF); // Buffer must be smaller than 2^32 bytes std::signal(SIGUSR2, sigusr2_handler); - std::string full_path = "/dev/shm/"; + #ifdef __APPLE__ + std::string full_path = "/tmp/"; + #else + std::string full_path = "/dev/shm/"; + #endif const char* prefix = std::getenv("OPENPILOT_PREFIX"); if (prefix) { full_path += std::string(prefix) + "/"; diff --git a/msgq/msgq_tests.cc b/msgq/msgq_tests.cc index 02f17917..2a1f328f 100644 --- a/msgq/msgq_tests.cc +++ b/msgq/msgq_tests.cc @@ -43,7 +43,11 @@ TEST_CASE("msgq_msg_init_data") TEST_CASE("msgq_init_subscriber") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif msgq_queue_t q; msgq_new_queue(&q, "test_queue", 1024); REQUIRE(*q.num_readers == 0); @@ -63,7 +67,11 @@ TEST_CASE("msgq_init_subscriber") TEST_CASE("msgq_msg_send first message") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif msgq_queue_t q; msgq_new_queue(&q, "test_queue", 1024); msgq_init_publisher(&q); @@ -100,7 +108,11 @@ TEST_CASE("msgq_msg_send first message") TEST_CASE("msgq_msg_send test wraparound") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif msgq_queue_t q; msgq_new_queue(&q, "test_queue", 1024); msgq_init_publisher(&q); @@ -132,7 +144,11 @@ TEST_CASE("msgq_msg_send test wraparound") TEST_CASE("msgq_msg_recv test wraparound") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif msgq_queue_t q_pub, q_sub; msgq_new_queue(&q_pub, "test_queue", 1024); msgq_new_queue(&q_sub, "test_queue", 1024); @@ -178,7 +194,11 @@ TEST_CASE("msgq_msg_recv test wraparound") TEST_CASE("msgq_msg_send test invalidation") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif msgq_queue_t q_pub, q_sub; msgq_new_queue(&q_pub, "test_queue", 1024); msgq_new_queue(&q_sub, "test_queue", 1024); @@ -214,7 +234,11 @@ TEST_CASE("msgq_msg_send test invalidation") TEST_CASE("msgq_init_subscriber init 2 subscribers") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif msgq_queue_t q1, q2; msgq_new_queue(&q1, "test_queue", 1024); msgq_new_queue(&q2, "test_queue", 1024); @@ -237,7 +261,11 @@ TEST_CASE("msgq_init_subscriber init 2 subscribers") TEST_CASE("Write 1 msg, read 1 msg", "[integration]") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif const size_t msg_size = 128; msgq_queue_t writer, reader; @@ -273,7 +301,11 @@ TEST_CASE("Write 1 msg, read 1 msg", "[integration]") TEST_CASE("Write 2 msg, read 2 msg - conflate = false", "[integration]") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif const size_t msg_size = 128; msgq_queue_t writer, reader; @@ -310,7 +342,11 @@ TEST_CASE("Write 2 msg, read 2 msg - conflate = false", "[integration]") TEST_CASE("Write 2 msg, read 2 msg - conflate = true", "[integration]") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif const size_t msg_size = 128; msgq_queue_t writer, reader; @@ -348,7 +384,11 @@ TEST_CASE("Write 2 msg, read 2 msg - conflate = true", "[integration]") TEST_CASE("1 publisher, 1 slow subscriber", "[integration]") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif msgq_queue_t writer, reader; msgq_new_queue(&writer, "test_queue", 1024); @@ -391,7 +431,11 @@ TEST_CASE("1 publisher, 1 slow subscriber", "[integration]") TEST_CASE("1 publisher, 2 subscribers", "[integration]") { - remove("/dev/shm/test_queue"); + #ifdef __APPLE__ + remove("/tmp/test_queue"); + #else + remove("/dev/shm/test_queue"); + #endif msgq_queue_t writer, reader1, reader2; msgq_new_queue(&writer, "test_queue", 1024);