From 93b71a7989f678bf36f12333787a056559f29ccf Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期日, 25 四月 2021 10:21:39 +0800
Subject: [PATCH] remove failed msgq.

---
 utest/utest.cpp |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/utest/utest.cpp b/utest/utest.cpp
index fae22b1..ff5d2ed 100644
--- a/utest/utest.cpp
+++ b/utest/utest.cpp
@@ -10,7 +10,14 @@
 #include <thread>
 #include <vector>
 
+using namespace bhome_shm;
 using namespace bhome_msg;
+
+SharedMemory &TestShm()
+{
+	static SharedMemory shm("utest_0", 1024 * 1024 * 512);
+	return shm;
+}
 
 template <class A, class B>
 struct IsSameType {
@@ -84,10 +91,9 @@
 
 BOOST_AUTO_TEST_CASE(PubSubTest)
 {
-	const std::string shm_name("ShmPubSub");
-	ShmRemover auto_remove(shm_name); //remove twice? in case of killed?
-	SharedMemory shm(shm_name, 1024 * 1024 * 50);
-	DEFER1(shm.Remove());
+	SharedMemory &shm = TestShm();
+	MsgI::BindShm(shm);
+
 	auto Avail = [&]() { return shm.get_free_memory(); };
 	auto init_avail = Avail();
 	int *flag = shm.find_or_construct<int>("flag")(123);
@@ -196,9 +202,8 @@
 
 BOOST_AUTO_TEST_CASE(ReqRepTest)
 {
-	const std::string shm_name("ShmReqRep");
-	ShmRemover auto_remove(shm_name);
-	SharedMemory shm(shm_name, 1024 * 1024 * 512);
+	SharedMemory &shm = TestShm();
+	MsgI::BindShm(shm);
 
 	auto Avail = [&]() { return shm.get_free_memory(); };
 	auto init_avail = Avail();

--
Gitblit v1.8.0