summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-14 10:19:32 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-14 10:19:32 +0200
commit2a442407538628b7b04c63c0643d521739de6b69 (patch)
tree5fa20a4786b868e81ad26d9ccd16ec62ba159d5a
parentfad5d37382552af7328dd67d038c1eaf44cf0aee (diff)
Adding a macro for simpler test writing and wip on fs
-rw-r--r--default.nix10
-rw-r--r--modules/codec/tests/args.cpp2
-rw-r--r--modules/core/c++/test/suite.hpp9
-rw-r--r--modules/remote-filesystem/SConstruct1
-rw-r--r--modules/remote-filesystem/c++/SConscript24
-rw-r--r--modules/remote-filesystem/c++/remote.hpp2
-rw-r--r--modules/remote-filesystem/c++/transport.hpp4
-rw-r--r--modules/remote-filesystem/tests/transport.cpp30
8 files changed, 65 insertions, 17 deletions
diff --git a/default.nix b/default.nix
index f56cae2..c2d0124 100644
--- a/default.nix
+++ b/default.nix
@@ -96,6 +96,15 @@ in rec {
build_examples = "false";
};
+
+ remote-filesystem = pkgs.callPackage modules/remote-filesystem/.nix/derivation.nix {
+ inherit version;
+ inherit forstio;
+ inherit stdenv;
+ inherit clang-tools;
+
+ build_examples = "false";
+ };
remote-sycl = pkgs.callPackage modules/remote-sycl/.nix/derivation.nix {
inherit version;
@@ -142,6 +151,7 @@ in rec {
forstio.io_codec
forstio.io-tls
forstio.remote
+ forstio.remote-filesystem
forstio.crypto
];
};
diff --git a/modules/codec/tests/args.cpp b/modules/codec/tests/args.cpp
index 7be3c05..f42056a 100644
--- a/modules/codec/tests/args.cpp
+++ b/modules/codec/tests/args.cpp
@@ -40,7 +40,7 @@ SAW_TEST("Codec Args Decode Basic"){
codec<sch::Args<sch::ArgsStruct, sch::ArgsTuple>, encode::Args> args_codec;
auto eov = args_codec.decode(dat_args, dat_nat);
- SAW_EXPECT(eov.is_value(), std::string{"Couldn't decode data. "} + std::string{eov.get_error().get_category()} + std::string{" - "} + std::string{eov.get_error().get_message()});
+ SAW_EOV_EXPECT(eov, "Couldn't decode data. ");
auto& prog = dat_nat.template get<"program">();
auto& str = dat_nat.template get<"args">();
diff --git a/modules/core/c++/test/suite.hpp b/modules/core/c++/test/suite.hpp
index 38a4716..88d741a 100644
--- a/modules/core/c++/test/suite.hpp
+++ b/modules/core/c++/test/suite.hpp
@@ -4,6 +4,7 @@
#include <memory>
#include <stdexcept>
#include <type_traits>
+#include <sstream>
#include "../common.hpp"
@@ -41,3 +42,11 @@ public:
auto msg = msg_split; \
throw std::runtime_error{std::string{msg}};\
}
+
+#define SAW_EOV_EXPECT(eov_expr, msg_split) \
+ if( (eov_expr.is_error()) ){ \
+ auto& err = eov_expr.get_error(); \
+ std::stringstream sstr; \
+ sstr<<msg_split<<" [Category] "<<err.get_category()<<" [Message] "<<err.get_message(); \
+ throw std::runtime_error{sstr.str()}; \
+ }
diff --git a/modules/remote-filesystem/SConstruct b/modules/remote-filesystem/SConstruct
index 5e94c0b..de3fadf 100644
--- a/modules/remote-filesystem/SConstruct
+++ b/modules/remote-filesystem/SConstruct
@@ -74,6 +74,7 @@ env.targets = [];
Export('env')
SConscript('c++/SConscript')
+SConscript('tests/SConscript')
SConscript('examples/SConscript')
env.Alias('cdb', env.cdb);
diff --git a/modules/remote-filesystem/c++/SConscript b/modules/remote-filesystem/c++/SConscript
index 2bf03be..621afdc 100644
--- a/modules/remote-filesystem/c++/SConscript
+++ b/modules/remote-filesystem/c++/SConscript
@@ -10,29 +10,29 @@ Import('env')
dir_path = Dir('.').abspath
# Environment for base library
-remote-filesystem_env = env.Clone();
+remote_filesystem_env = env.Clone();
-remote-filesystem_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
-remote-filesystem_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
+remote_filesystem_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
+remote_filesystem_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
-env.sources += remote-filesystem_env.sources;
-env.headers += remote-filesystem_env.headers;
+env.sources += remote_filesystem_env.sources;
+env.headers += remote_filesystem_env.headers;
## Shared lib
objects_shared = []
-remote-filesystem_env.add_source_files(objects_shared, remote-filesystem_env.sources, shared=True);
-env.library_shared = remote-filesystem_env.SharedLibrary('#build/forstio-remote-filesystem', [objects_shared]);
+remote_filesystem_env.add_source_files(objects_shared, remote_filesystem_env.sources, shared=True);
+env.library_shared = remote_filesystem_env.SharedLibrary('#build/forstio-remote_filesystem', [objects_shared]);
## Static lib
objects_static = []
-remote-filesystem_env.add_source_files(objects_static, remote-filesystem_env.sources, shared=False);
-env.library_static = remote-filesystem_env.StaticLibrary('#build/forstio-remote-filesystem', [objects_static]);
+remote_filesystem_env.add_source_files(objects_static, remote_filesystem_env.sources, shared=False);
+env.library_static = remote_filesystem_env.StaticLibrary('#build/forstio-remote_filesystem', [objects_static]);
# Set Alias
-env.Alias('library_remote-filesystem', [env.library_shared, env.library_static]);
+env.Alias('library_remote_filesystem', [env.library_shared, env.library_static]);
-env.targets += ['library_remote-filesystem'];
+env.targets += ['library_remote_filesystem'];
# Install
env.Install('$prefix/lib/', [env.library_shared, env.library_static]);
-env.Install('$prefix/include/forstio/remote/filesystem/', [remote-filesystem_env.headers]);
+env.Install('$prefix/include/forstio/remote/filesystem/', [remote_filesystem_env.headers]);
diff --git a/modules/remote-filesystem/c++/remote.hpp b/modules/remote-filesystem/c++/remote.hpp
index 062d7ee..8390501 100644
--- a/modules/remote-filesystem/c++/remote.hpp
+++ b/modules/remote-filesystem/c++/remote.hpp
@@ -41,7 +41,7 @@ public:
template<typename Schema, typename Encode>
error_or<own<data_server<Schema, Encode, rmt::File>>> data_listen(ref<remote_address<rmt::File>> addr){
- auto insert_res = registered_data_servers_.emplace(std::make_pair(addr.get_path_string(),{}));
+ auto insert_res = registered_data_servers_.emplace(std::make_pair(addr().get_path_string(),ptr<i_data_server<rmt::File>>{}));
if(!insert_res.second){
return make_error<err::already_exists>();
}
diff --git a/modules/remote-filesystem/c++/transport.hpp b/modules/remote-filesystem/c++/transport.hpp
index 367f533..0db4600 100644
--- a/modules/remote-filesystem/c++/transport.hpp
+++ b/modules/remote-filesystem/c++/transport.hpp
@@ -32,12 +32,10 @@ public:
error_or<void> send(const data<Schema, Encoding>& dat, id<Schema> store_id){
try {
}
-
return make_error<err::not_implemented>();
}
error_or<void> allocate(data<typename meta_schema<Schema>::MetaSchema, Encoding> meta, id<Schema> store_id){
-
return make_error<err::not_implemented>();
}
@@ -46,7 +44,7 @@ public:
}
error_or<data<Schema,Encoding>> receive(id<Schema> store_id){
-
+ return make_error<err::not_implemented>();
}
};
diff --git a/modules/remote-filesystem/tests/transport.cpp b/modules/remote-filesystem/tests/transport.cpp
new file mode 100644
index 0000000..05c13a6
--- /dev/null
+++ b/modules/remote-filesystem/tests/transport.cpp
@@ -0,0 +1,30 @@
+#include <forstio/test/suite.hpp>
+#include "../c++/transport.hpp"
+
+namespace {
+namespace sch {
+using namespace saw::schema;
+
+using Foo = Struct<
+ Member<String, "a">,
+ Member<Int64, "b">
+>;
+}
+
+SAW_TEST("File Remote"){
+ using namespace saw;
+
+ remote<rmt::File> file_remote;
+
+ auto eo_addr = file_remote.parse_address("./example_file");
+ SAW_EOV_EXPECT(eo_addr, "Couldn't parse file");
+ auto& addr = eo_addr.get_value();
+
+ auto eo_dat_srv = file_remote.data_listen({*addr});
+ SAW_EOV_EXPECT(eo_dat_srv, "Couldn't setup data server.");
+ auto& dat_srv = eo_dat_srv.get_value();
+
+
+}
+
+}