4 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE SharedDummyBackendTest
13 #include <boost/filesystem.hpp>
14 #include <boost/interprocess/managed_shared_memory.hpp>
15 #include <boost/test/unit_test.hpp>
29 using namespace boost::unit_test_framework;
31 static TestLocker testLocker(
"shareddummyTest.dmap");
34 bool testRegisterNotInCatalogue(
const std::string& registerPath) {
38 auto catalogue = backendInstance->getRegisterCatalogue();
42 for(
auto& info : catalogue) {
43 if(info.getRegisterName() == registerPath) {
53 BOOST_AUTO_TEST_SUITE(SharedDummyBackendTestSuite)
62 dev.
open(
"SHDMEMDEV");
71 dev.
open(
"SHDMEMDEV");
86 dev.
open(
"SHDMEMDEV");
92 std::generate(processVars11.
begin(), processVars11.
end(), [n]()
mutable { return n++; });
93 processVars11.
write();
98 std::generate(processVars23.
begin(), processVars23.
end(), [n]()
mutable { return n++; });
99 processVars23.
write();
100 processVars23.
read();
105 std::generate(processVarsWrite21.
begin(), processVarsWrite21.
end(), [n]()
mutable { return n++; });
106 processVarsWrite21.
write();
109 BOOST_CHECK(!std::system(
"./testSharedDummyBackendExt "
110 "--run_test=SharedDummyBackendTestSuite/testReadWrite"));
114 processVarsRead.
read();
116 BOOST_CHECK(
static_cast<std::vector<int>
>(processVarsWrite21) ==
static_cast<std::vector<int>
>(processVarsRead));
125 dev.
open(
"SHDMEMDEV");
131 BOOST_CHECK(roRegisterOne.isReadOnly());
132 BOOST_CHECK(!roRegisterOne.isWriteable());
133 BOOST_CHECK(!roRegisterTwo_dw.isReadOnly());
134 BOOST_CHECK(roRegisterTwo_dw.isWriteable());
136 BOOST_CHECK(testRegisterNotInCatalogue(
"WORD_READ_ONLY_2.DUMMY_WRITEABLE"));
141 roRegisterTwo_dw = 25;
142 roRegisterTwo_dw.write();
147 BOOST_CHECK(!std::system(
"./testSharedDummyBackendExt "
148 "--run_test=SharedDummyBackendTestSuite/testWriteToReadOnly"));
150 roRegisterOne.read();
151 BOOST_CHECK_EQUAL(roRegisterTwo_dw, roRegisterOne);
164 BOOST_CHECK(backendInst1.get() == backendInst2.get());
165 BOOST_CHECK(backendInst3.get() != backendInst2.get());
171 BOOST_AUTO_TEST_SUITE_END()