Commit ab6f3b7f authored by Dominik Charousset's avatar Dominik Charousset

Fix unit test failures

parent ce5a53ca
...@@ -82,9 +82,8 @@ public: ...@@ -82,9 +82,8 @@ public:
system_ = &parent.system(); system_ = &parent.system();
executor_.system_ptr(system_); executor_.system_ptr(system_);
executor_.proxy_registry_ptr(&proxies_); executor_.proxy_registry_ptr(&proxies_);
// TODO: use `if constexpr` when switching to C++17.
// Allow unit tests to run the application without endpoint manager. // Allow unit tests to run the application without endpoint manager.
if (!std::is_base_of<test_tag, Parent>::value) if constexpr (!std::is_base_of<test_tag, Parent>::value)
manager_ = &parent.manager(); manager_ = &parent.manager();
size_t workers; size_t workers;
if (auto workers_cfg = get_if<size_t>(&system_->config(), if (auto workers_cfg = get_if<size_t>(&system_->config(),
......
...@@ -105,7 +105,8 @@ void middleman::add_module_options(actor_system_config& cfg) { ...@@ -105,7 +105,8 @@ void middleman::add_module_options(actor_system_config& cfg) {
"max. number of consecutive reads per broker") "max. number of consecutive reads per broker")
.add<bool>("manual-multiplexing", .add<bool>("manual-multiplexing",
"disables background activity of the multiplexer") "disables background activity of the multiplexer")
.add<size_t>("workers", "number of deserialization workers"); .add<size_t>("workers", "number of deserialization workers")
.add<std::string>("network-backend", "legacy option");
} }
expected<endpoint_manager_ptr> middleman::connect(const uri& locator) { expected<endpoint_manager_ptr> middleman::connect(const uri& locator) {
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "caf/net/basp/connection_state.hpp" #include "caf/net/basp/connection_state.hpp"
#include "caf/net/basp/constants.hpp" #include "caf/net/basp/constants.hpp"
#include "caf/net/basp/ec.hpp" #include "caf/net/basp/ec.hpp"
#include "caf/net/middleman.hpp"
#include "caf/net/packet_writer.hpp" #include "caf/net/packet_writer.hpp"
#include "caf/none.hpp" #include "caf/none.hpp"
#include "caf/uri.hpp" #include "caf/uri.hpp"
...@@ -42,7 +43,13 @@ using namespace caf::net; ...@@ -42,7 +43,13 @@ using namespace caf::net;
namespace { namespace {
struct fixture : test_coordinator_fixture<>, struct config : actor_system_config {
config() {
net::middleman::add_module_options(*this);
}
};
struct fixture : test_coordinator_fixture<config>,
proxy_registry::backend, proxy_registry::backend,
basp::application::test_tag, basp::application::test_tag,
public packet_writer { public packet_writer {
...@@ -242,8 +249,7 @@ CAF_TEST(actor message) { ...@@ -242,8 +249,7 @@ CAF_TEST(actor message) {
MOCK(basp::message_type::actor_message, make_message_id().integer_value(), MOCK(basp::message_type::actor_message, make_message_id().integer_value(),
mars, actor_id{42}, self->id(), std::vector<strong_actor_ptr>{}, mars, actor_id{42}, self->id(), std::vector<strong_actor_ptr>{},
make_message("hello world!")); make_message("hello world!"));
allow((monitor_atom, strong_actor_ptr), expect((monitor_atom, strong_actor_ptr), from(_).to(self));
from(_).to(self).with(monitor_atom_v, _));
expect((std::string), from(_).to(self).with("hello world!")); expect((std::string), from(_).to(self).with("hello world!"));
} }
......
...@@ -164,7 +164,7 @@ CAF_TEST(send and receive) { ...@@ -164,7 +164,7 @@ CAF_TEST(send and receive) {
auto buf = std::make_shared<byte_buffer>(); auto buf = std::make_shared<byte_buffer>();
auto sockets = unbox(make_stream_socket_pair()); auto sockets = unbox(make_stream_socket_pair());
CAF_CHECK_EQUAL(nonblocking(sockets.second, true), none); CAF_CHECK_EQUAL(nonblocking(sockets.second, true), none);
CAF_CHECK_EQUAL(read(sockets.second, read_buf), -1); CAF_CHECK_LESS(read(sockets.second, read_buf), 0);
CAF_CHECK(last_socket_error_is_temporary()); CAF_CHECK(last_socket_error_is_temporary());
auto guard = detail::make_scope_guard([&] { close(sockets.second); }); auto guard = detail::make_scope_guard([&] { close(sockets.second); });
auto mgr = make_endpoint_manager(mpx, sys, auto mgr = make_endpoint_manager(mpx, sys,
......
...@@ -75,9 +75,9 @@ struct fixture : host_fixture { ...@@ -75,9 +75,9 @@ struct fixture : host_fixture {
CAF_TEST_FIXTURE_SCOPE(network_socket_tests, fixture) CAF_TEST_FIXTURE_SCOPE(network_socket_tests, fixture)
CAF_TEST(read on empty sockets) { CAF_TEST(read on empty sockets) {
CAF_CHECK_EQUAL(read(first, rd_buf), -1); CAF_CHECK_LESS(read(first, rd_buf), 0);
CAF_CHECK(last_socket_error_is_temporary()); CAF_CHECK(last_socket_error_is_temporary());
CAF_CHECK_EQUAL(read(second, rd_buf), -1); CAF_CHECK_LESS(read(second, rd_buf), 0);
CAF_CHECK(last_socket_error_is_temporary()); CAF_CHECK(last_socket_error_is_temporary());
} }
......
...@@ -208,8 +208,8 @@ CAF_TEST(receive) { ...@@ -208,8 +208,8 @@ CAF_TEST(receive) {
auto buf = std::make_shared<byte_buffer>(); auto buf = std::make_shared<byte_buffer>();
auto sockets = unbox(make_stream_socket_pair()); auto sockets = unbox(make_stream_socket_pair());
CAF_CHECK_EQUAL(nonblocking(sockets.second, true), none); CAF_CHECK_EQUAL(nonblocking(sockets.second, true), none);
CAF_CHECK_EQUAL(read(sockets.second, read_buf), CAF_CHECK_LESS(read(sockets.second, read_buf), 0);
sec::unavailable_or_would_block); CAF_CHECK(last_socket_error_is_temporary());
CAF_MESSAGE("adding both endpoint managers"); CAF_MESSAGE("adding both endpoint managers");
auto mgr1 = make_endpoint_manager( auto mgr1 = make_endpoint_manager(
mpx, sys, transport_type{sockets.first, application_type{buf}}); mpx, sys, transport_type{sockets.first, application_type{buf}});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment