diff options
author | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-07-15 16:38:25 +0200 |
---|---|---|
committer | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-07-15 16:38:25 +0200 |
commit | 6b68a4f7ddac183f460b668bee7a385daada0ce5 (patch) | |
tree | 61e960a96fc35e040f3e7c4f7e649344e30846bc /modules/remote | |
parent | 816760c8480e8e76c7f4021a845161eb697e215c (diff) |
Move files and ammend remote-sycl
Diffstat (limited to 'modules/remote')
-rw-r--r-- | modules/remote/tests/SConscript | 31 | ||||
-rw-r--r-- | modules/remote/tests/remote_loopback.cpp | 73 |
2 files changed, 104 insertions, 0 deletions
diff --git a/modules/remote/tests/SConscript b/modules/remote/tests/SConscript new file mode 100644 index 0000000..f8ffc92 --- /dev/null +++ b/modules/remote/tests/SConscript @@ -0,0 +1,31 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +test_cases_env = env.Clone(); + +test_cases_env.Append(LIBS=['forstio-test']); + +test_cases_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) +test_cases_env.headers = sorted(glob.glob(dir_path + "/*.hpp")) + +env.sources += test_cases_env.sources; +env.headers += test_cases_env.headers; + +objects_static = [] +test_cases_env.add_source_files(objects_static, test_cases_env.sources, shared=False); +test_cases_env.program = test_cases_env.Program('#bin/tests', [objects_static, env.library_static]); + +# Set Alias +env.Alias('test', test_cases_env.program); +env.Alias('check', test_cases_env.program); + +env.targets += ['test','check']; diff --git a/modules/remote/tests/remote_loopback.cpp b/modules/remote/tests/remote_loopback.cpp new file mode 100644 index 0000000..2895ee7 --- /dev/null +++ b/modules/remote/tests/remote_loopback.cpp @@ -0,0 +1,73 @@ +#include <forstio/test/suite.hpp> + +#include "../c++/remote_loopback.hpp" + +namespace { +namespace sch { +using namespace saw::schema; + +using TestInterface = Interface< + Member<Function<UInt32, Int64>, "foo"> +>; + +using GroupedSchemas = saw::tmpl_group< + UInt64, + String, + Array<Int32>, + Float64 +>; +} + +SAW_TEST("Remote Loopback Data"){ + using namespace saw; + + remote<rmt::Loopback> rmt; + + auto eov = rmt.parse_address(); + SAW_EXPECT(eov.is_value(), "Didn't parse correctly"); + auto& val = eov.get_value(); + + interface<sch::TestInterface, encode::Native, storage::Default> iface{ + [](data<sch::UInt32>& foo){ + return foo.template cast_to<sch::Int64>(); + } + }; + + auto srv = data_server<sch::GroupedSchemas, encode::Native, rmt::Loopback>{}; + auto client = data_client<sch::GroupedSchemas, encode::Native, rmt::Loopback>{srv}; + + data<sch::UInt64> foo{421}; + id<sch::UInt64> sent_id = [&](){ + auto eov = client.send(foo); + SAW_EXPECT(eov.is_value(), "Failed send."); + return eov.get_value(); + }(); + + event_loop loop; + wait_scope wait{loop}; + + { + auto conv = client.receive(sent_id); + auto eov = conv.take(); + + SAW_EXPECT(eov.is_value(), "Failed receive."); + SAW_EXPECT(eov.get_value() == foo, "Wrong received value."); + } + { + auto eov = client.find(sent_id); + SAW_EXPECT(eov.is_value(), "Failed find."); + auto& f_val = eov.get_value(); + SAW_EXPECT(f_val, "Nullptr in find."); + SAW_EXPECT(*f_val == foo, "Wrong received value."); + } + { + auto eov = client.erase(sent_id); + SAW_EXPECT(eov.is_value(), "Failed erase."); + } + { + auto conv = client.receive(sent_id); + auto eov = conv.take(); + SAW_EXPECT(!eov.is_value(), "Failed receive. Value should already be erased."); + } +} +} |