osaf/libs/core/leap/tests/sysf_ipc_test.cc | 31 ++++++++---------------------
1 files changed, 9 insertions(+), 22 deletions(-)
diff --git a/osaf/libs/core/leap/tests/sysf_ipc_test.cc
b/osaf/libs/core/leap/tests/sysf_ipc_test.cc
--- a/osaf/libs/core/leap/tests/sysf_ipc_test.cc
+++ b/osaf/libs/core/leap/tests/sysf_ipc_test.cc
@@ -18,7 +18,7 @@
#include <iostream>
#include <string>
#include <thread>
-#include <mutex>
+#include <atomic>
#include <sched.h>
#include <poll.h>
#include <cstdlib>
@@ -30,8 +30,6 @@
#include "ncs_main_papi.h"
#include "gtest/gtest.h"
-std::mutex send_ctr_mutex;
-
typedef struct message_ {
struct message_ *next;
NCS_IPC_PRIORITY prio;
@@ -61,7 +59,6 @@ class SysfIpcTest : public ::testing::Te
SysfIpcTest() {
// Setup work can be done here for each test.
no_of_msgs_sent = 0;
- no_of_msgs_received = 0;
}
virtual ~SysfIpcTest() {
@@ -138,10 +135,7 @@ class SysfIpcTest : public ::testing::Te
rc = m_NCS_IPC_SEND(&mbox, msg, msg->prio);
EXPECT_EQ(rc, NCSCC_RC_SUCCESS);
- {
- std::lock_guard<std::mutex> lck(send_ctr_mutex);
- no_of_msgs_sent++;
- }
+ no_of_msgs_sent++;
sched_yield();
}
@@ -150,20 +144,19 @@ class SysfIpcTest : public ::testing::Te
// Objects declared here can be used by all tests in the test case.
static SYSF_MBX mbox;
- static uint32_t no_of_msgs_sent;
- static uint32_t no_of_msgs_received;
+ static std::atomic<int> no_of_msgs_sent;
};
-SYSF_MBX SysfIpcTest::mbox = 0;
-uint32_t SysfIpcTest::no_of_msgs_sent = 0;
-uint32_t SysfIpcTest::no_of_msgs_received = 0;
+SYSF_MBX SysfIpcTest::mbox {0};
+std::atomic<int> SysfIpcTest::no_of_msgs_sent {0};
void SysfIpcTest::MessageReceiver() {
NCS_SEL_OBJ mbox_fd;
pollfd fds;
bool done = false;
Message *msg;
-
+ int no_of_msgs_received {0};
+
mbox_fd = ncs_ipc_get_sel_obj(&mbox);
fds.fd = mbox_fd.rmv_obj;
@@ -192,10 +185,7 @@ void SysfIpcTest::MessageReceiver() {
}
}
- {
- std::lock_guard<std::mutex> lck(send_ctr_mutex);
- ASSERT_EQ(no_of_msgs_received, no_of_msgs_sent);
- }
+ ASSERT_EQ(no_of_msgs_received, no_of_msgs_sent);
}
// Tests send and receive
@@ -245,10 +235,7 @@ TEST_F(SysfIpcTest, TestThreadsSendRecei
sched_yield();
- {
- std::lock_guard<std::mutex> lck(send_ctr_mutex);
- no_of_msgs_sent++;
- }
+ no_of_msgs_sent++;
send_msg(NCS_IPC_PRIORITY_LOW, 4711);
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel