8 #define BOOST_TEST_DYN_LINK
9 #define BOOST_TEST_MODULE SubdeviceBackendTest
10 #define BOOST_NO_EXCEPTIONS
11 #include <boost/test/unit_test.hpp>
12 using namespace boost::unit_test_framework;
13 #undef BOOST_NO_EXCEPTIONS
17 #define CHECK_TIMEOUT(execPreCheck, condition, maxMilliseconds) \
19 std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now(); \
20 execPreCheck while(!(condition)) { \
21 bool timeout_reached = (std::chrono::steady_clock::now() - t0) > std::chrono::milliseconds(maxMilliseconds); \
22 BOOST_CHECK(!timeout_reached); \
23 if(timeout_reached) break; \
29 BOOST_AUTO_TEST_SUITE(SubdeviceBackendTestSuite)
65 target.
open(
"TARGET1");
70 BOOST_CHECK(acc1.getHighLevelImplElement()->mayReplaceOther(acc1_2.getHighLevelImplElement()));
71 BOOST_CHECK(acc1_2.getHighLevelImplElement()->mayReplaceOther(acc1.getHighLevelImplElement()));
77 BOOST_CHECK(!acc1.getHighLevelImplElement()->mayReplaceOther(acc1_2.getHighLevelImplElement()));
78 BOOST_CHECK(!acc1_2.getHighLevelImplElement()->mayReplaceOther(acc1.getHighLevelImplElement()));
84 BOOST_CHECK(acc1.getHighLevelImplElement()->mayReplaceOther(acc1_2.getHighLevelImplElement()));
85 BOOST_CHECK(acc1_2.getHighLevelImplElement()->mayReplaceOther(acc1.getHighLevelImplElement()));
91 BOOST_CHECK(!acc1.getHighLevelImplElement()->mayReplaceOther(acc1_2.getHighLevelImplElement()));
92 BOOST_CHECK(!acc1_2.getHighLevelImplElement()->mayReplaceOther(acc1.getHighLevelImplElement()));
98 BOOST_CHECK(!acc1.getHighLevelImplElement()->mayReplaceOther(acc1_2.getHighLevelImplElement()));
99 BOOST_CHECK(!acc1_2.getHighLevelImplElement()->mayReplaceOther(acc1.getHighLevelImplElement()));
111 target.
open(
"TARGET1");
119 BOOST_CHECK_EQUAL(int32_t(acc1t), 42);
124 BOOST_CHECK_EQUAL(int32_t(acc1t), -120);
132 BOOST_CHECK_EQUAL(int32_t(acc2t), 666);
137 BOOST_CHECK_EQUAL(int32_t(acc2t), -99999);
139 acc2.setAsCooked<
float>(42.5);
140 BOOST_CHECK_EQUAL(int32_t(acc2), 170);
142 BOOST_CHECK_CLOSE(acc2.getAsCooked<
float>(), 666, 0.01);
155 target.
open(
"TARGET1");
163 BOOST_CHECK_EQUAL((int32_t)acc1t, 42);
168 BOOST_CHECK_EQUAL((int32_t)acc1t, -120);
176 BOOST_CHECK_EQUAL((int32_t)acc2t, 666);
181 BOOST_CHECK_EQUAL((int32_t)acc2t, -99999);
194 target.
open(
"TARGET1");
199 acc1 = {10, 20, 30, 40, 50, 60};
202 BOOST_CHECK((std::vector<int32_t>)acc1t == std::vector<int32_t>({10, 20, 30, 40, 50, 60}));
204 acc1 = {15, 25, 35, 45, 55, 65};
207 BOOST_CHECK((std::vector<int32_t>)acc1t == std::vector<int32_t>({15, 25, 35, 45, 55, 65}));
220 target.
open(
"TARGET1");
228 BOOST_CHECK_EQUAL((int32_t)acc1t, 42);
233 BOOST_CHECK_EQUAL((int32_t)acc1t, -120);
241 BOOST_CHECK_EQUAL((int32_t)acc2t, 666 * 4);
246 BOOST_CHECK_EQUAL((int32_t)acc2t,
247 (-333 * 4) & 0x3FFFF);
253 BOOST_CHECK_EQUAL((int32_t)acc2t, 131072);
266 target.
open(
"TARGET1");
271 acc1 = {10, 20, 30, 40, 50, 60};
274 BOOST_CHECK((std::vector<int32_t>)acc1t ==
275 std::vector<int32_t>({10 * 65536, 20 * 65536, 30 * 65536, 40 * 65536, 50 * 65536, 60 * 65536}));
277 acc1 = {15, 25, 35, 45, 55, 65};
280 BOOST_CHECK((std::vector<int32_t>)acc1t ==
281 std::vector<int32_t>({15 * 65536, 25 * 65536, 35 * 65536, 45 * 65536, 55 * 65536, 65 * 65536}));
295 target.
open(
"TARGET1");
303 BOOST_CHECK_EQUAL((int32_t)acc1, 42);
308 BOOST_CHECK_EQUAL((int32_t)acc1, -120);
316 BOOST_CHECK_EQUAL((int32_t)acc2, 666);
321 BOOST_CHECK_EQUAL((int32_t)acc2, -99999);
334 target.
open(
"TARGET1");
342 BOOST_CHECK_EQUAL((int32_t)acc1, 42);
347 BOOST_CHECK_EQUAL((int32_t)acc1, -120);
355 BOOST_CHECK_EQUAL((int32_t)acc2, 666);
360 BOOST_CHECK_EQUAL((int32_t)acc2, -99999);
373 target.
open(
"TARGET1");
378 acc1t = {10, 20, 30, 40, 50, 60};
381 BOOST_CHECK((std::vector<int32_t>)acc1 == std::vector<int32_t>({10, 20, 30, 40, 50, 60}));
383 acc1t = {15, 25, 35, 45, 55, 65};
386 BOOST_CHECK((std::vector<int32_t>)acc1 == std::vector<int32_t>({15, 25, 35, 45, 55, 65}));
399 target.
open(
"TARGET1");
407 BOOST_CHECK_EQUAL((int32_t)acc1, 42);
412 BOOST_CHECK_EQUAL((int32_t)acc1, -120);
420 BOOST_CHECK_EQUAL((int32_t)acc2, 666);
425 BOOST_CHECK_EQUAL((int32_t)acc2,
431 BOOST_CHECK_EQUAL((int32_t)acc2, -32768);
444 target.
open(
"TARGET1");
449 acc1t = {10 * 65536, 20 * 65536, 30 * 65536, 40 * 65536, 50 * 65536, 60 * 65536};
452 BOOST_CHECK((std::vector<int32_t>)acc1 == std::vector<int32_t>({10, 20, 30, 40, 50, 60}));
454 acc1t = {15 * 65536, 25 * 65536, 35 * 65536, 45 * 65536, 55 * 65536, 65 * 65536};
457 BOOST_CHECK((std::vector<int32_t>)acc1 == std::vector<int32_t>({15, 25, 35, 45, 55, 65}));
470 target.
open(
"TARGET1");
477 std::atomic<bool> done;
486 t = std::thread([&] {
492 BOOST_CHECK(done ==
false);
498 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(accD), 42 * 4);
503 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(accA), 0);
505 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(accD), 120);
518 target.
open(
"TARGET1");
524 std::atomic<bool> done;
530 t = std::thread([&] {
537 BOOST_CHECK(done ==
false);
543 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(accD), 456);
559 target.
open(
"TARGET1");
565 std::atomic<bool> done;
573 t = std::thread([&] {
579 BOOST_CHECK(done ==
false);
584 BOOST_CHECK(accA == 1);
586 BOOST_CHECK(accD == 1897);
599 target.
open(
"TARGET1");
606 std::atomic<bool> done;
610 std::vector<int> vec = {1, 2, 3, 4, 5, 6};
615 t = std::thread([&] {
625 BOOST_CHECK(done ==
false);
626 int countStatusResets = 0;
635 }
while(accS == 0 && !done);
641 BOOST_CHECK(countStatusResets == 8);
644 BOOST_CHECK(accArea[0] == 1897);
645 BOOST_CHECK(accArea[1] == 1897 * 4);
646 BOOST_CHECK(accArea[2] == 65536 * vec[0]);
647 BOOST_CHECK(accArea[3] == 65536 * vec[1]);
659 target.
open(
"TARGET1");
673 std::chrono::duration<double> diff =
stop - start;
674 BOOST_CHECK(diff.count() >= 1.0);
677 BOOST_CHECK(accA == 4);
679 BOOST_CHECK_EQUAL(
static_cast<int32_t
>(accD), 666 * 4);
692 target.
open(
"TARGET1");
705 BOOST_AUTO_TEST_SUITE_END()