diff options
Diffstat (limited to 'test/routing_tests')
17 files changed, 125 insertions, 168 deletions
diff --git a/test/routing_tests/external_local_routing_test_client_external.json b/test/routing_tests/conf/external_local_routing_test_client_external.json.in index fb33ae8..3633538 100644 --- a/test/routing_tests/external_local_routing_test_client_external.json +++ b/test/routing_tests/conf/external_local_routing_test_client_external.json.in @@ -1,5 +1,5 @@ { - "unicast" : "172.16.100.131", + "unicast" : "@TEST_IP_SLAVE@", "netmask" : "255.255.255.0", "logging" : { @@ -22,19 +22,13 @@ } ], - "servicegroups" : + "services" : [ { - "name" : "remote", - "unicast" : "134.86.56.183", - "services" : - [ - { - "service" : "0x1234", - "instance" : "0x5678", - "unreliable" : "30509" - } - ] + "service" : "0x1234", + "instance" : "0x5678", + "unicast" : "@TEST_IP_MASTER@", + "unreliable" : "30509" } ], diff --git a/test/routing_tests/conf/external_local_routing_test_service.json.in b/test/routing_tests/conf/external_local_routing_test_service.json.in new file mode 100644 index 0000000..0ef1f77 --- /dev/null +++ b/test/routing_tests/conf/external_local_routing_test_service.json.in @@ -0,0 +1,41 @@ +{ + "unicast" : "@TEST_IP_MASTER@", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : + { + "enable" : "false", + "path" : "/tmp/vsomeip.log" + }, + + "dlt" : "false" + }, + + "applications" : + [ + { + "name" : "external_local_routing_test_service", + "id" : "0x1277" + } + ], + + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "unreliable" : "30509" + } + ], + + "routing" : "external_local_routing_test_service", + "service-discovery" : + { + "enable" : "false", + "multicast" : "224.0.0.1", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/test/routing_tests/external_local_routing_test_client_external_start.sh b/test/routing_tests/external_local_routing_test_client_external_start.sh index 44b5187..a40dece 100755 --- a/test/routing_tests/external_local_routing_test_client_external_start.sh +++ b/test/routing_tests/external_local_routing_test_client_external_start.sh @@ -5,5 +5,5 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. export VSOMEIP_APPLICATION_NAME=external_local_routing_test_client_external -export VSOMEIP_CONFIGURATION_FILE=external_local_routing_test_client_external.json +export VSOMEIP_CONFIGURATION=external_local_routing_test_client_external.json ./local_routing_test_client diff --git a/test/routing_tests/external_local_routing_test_service.cpp b/test/routing_tests/external_local_routing_test_service.cpp index 2553898..72899fd 100644 --- a/test/routing_tests/external_local_routing_test_service.cpp +++ b/test/routing_tests/external_local_routing_test_service.cpp @@ -9,11 +9,11 @@ external_local_routing_test_service::external_local_routing_test_service(bool _use_static_routing) : app_(vsomeip::runtime::get()->create_application()), is_registered_(false), - blocked_(false), use_static_routing_(_use_static_routing), - offer_thread_(std::bind(&external_local_routing_test_service::run, this)), + blocked_(false), number_received_messages_local_(0), - number_received_messages_external_(0) + number_received_messages_external_(0), + offer_thread_(std::bind(&external_local_routing_test_service::run, this)) { } @@ -32,8 +32,8 @@ void external_local_routing_test_service::init() std::bind(&external_local_routing_test_service::on_message, this, std::placeholders::_1)); - app_->register_event_handler( - std::bind(&external_local_routing_test_service::on_event, this, + app_->register_state_handler( + std::bind(&external_local_routing_test_service::on_state, this, std::placeholders::_1)); VSOMEIP_INFO << "Static routing " << (use_static_routing_ ? "ON" : "OFF"); @@ -50,7 +50,7 @@ void external_local_routing_test_service::stop() VSOMEIP_INFO << "Stopping..."; app_->unregister_message_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, vsomeip_test::TEST_SERVICE_METHOD_ID); - app_->unregister_event_handler(); + app_->unregister_state_handler(); app_->stop(); } @@ -69,16 +69,17 @@ void external_local_routing_test_service::stop_offer() app_->stop_offer_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID); } -void external_local_routing_test_service::on_event(vsomeip::event_type_e _event) +void external_local_routing_test_service::on_state(vsomeip::state_type_e _state) { VSOMEIP_INFO << "Application " << app_->get_name() << " is " - << (_event == vsomeip::event_type_e::ET_REGISTERED ? "registered." : + << (_state == vsomeip::state_type_e::ST_REGISTERED ? "registered." : "deregistered."); - if(_event == vsomeip::event_type_e::ET_REGISTERED) + if(_state == vsomeip::state_type_e::ST_REGISTERED) { if(!is_registered_) { + std::lock_guard<std::mutex> its_lock(mutex_); is_registered_ = true; blocked_ = true; // "start" the run method thread diff --git a/test/routing_tests/external_local_routing_test_service.hpp b/test/routing_tests/external_local_routing_test_service.hpp index d5b767e..82f6220 100644 --- a/test/routing_tests/external_local_routing_test_service.hpp +++ b/test/routing_tests/external_local_routing_test_service.hpp @@ -27,7 +27,7 @@ public: void offer(); void stop_offer(); void join_offer_thread(); - void on_event(vsomeip::event_type_e _event); + void on_state(vsomeip::state_type_e _state); void on_message(const std::shared_ptr<vsomeip::message> &_request); void run(); @@ -36,12 +36,12 @@ private: bool is_registered_; bool use_static_routing_; - std::thread offer_thread_; std::mutex mutex_; std::condition_variable condition_; bool blocked_; std::uint32_t number_received_messages_local_; std::uint32_t number_received_messages_external_; + std::thread offer_thread_; }; #endif /* EXTERNALLOCALROUTINGTESTSERVICE_HPP_ */ diff --git a/test/routing_tests/external_local_routing_test_service.json b/test/routing_tests/external_local_routing_test_service.json deleted file mode 100644 index d48a33a..0000000 --- a/test/routing_tests/external_local_routing_test_service.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "unicast" : "134.86.56.183", - "logging" : - { - "level" : "debug", - "console" : "true", - "file" : - { - "enable" : "false", - "path" : "/tmp/vsomeip.log" - }, - - "dlt" : "false" - }, - - "applications" : - [ - { - "name" : "external_local_routing_test_service", - "id" : "0x1277" - } - ], - - "servicegroups" : - [ - { - "name" : "default", - "unicast" : "local", - "delays" : - { - "initial" : - { - "minimum" : "10", - "maximum" : "100" - }, - - "repetition-base" : "200", - "repetition-max" : "3", - "cyclic-offer" : "2000", - "cyclic-request" : "2001" - }, - - "services" : - [ - { - "service" : "0x1234", - "instance" : "0x5678", - "unreliable" : "30509" - } - ] - } - ], - - "routing" : "external_local_routing_test_service", - "service-discovery" : - { - "enable" : "false", - "multicast" : "224.0.0.1", - "port" : "30490", - "protocol" : "udp" - } -}
\ No newline at end of file diff --git a/test/routing_tests/external_local_routing_test_service_start.sh b/test/routing_tests/external_local_routing_test_service_start.sh index b28b6cf..e6ac677 100755 --- a/test/routing_tests/external_local_routing_test_service_start.sh +++ b/test/routing_tests/external_local_routing_test_service_start.sh @@ -5,5 +5,5 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. export VSOMEIP_APPLICATION_NAME=external_local_routing_test_service -export VSOMEIP_CONFIGURATION_FILE=external_local_routing_test_service.json +export VSOMEIP_CONFIGURATION=external_local_routing_test_service.json ./external_local_routing_test_service diff --git a/test/routing_tests/external_local_routing_test_starter.sh b/test/routing_tests/external_local_routing_test_starter.sh index dc0a2c3..abee34d 100755 --- a/test/routing_tests/external_local_routing_test_starter.sh +++ b/test/routing_tests/external_local_routing_test_starter.sh @@ -49,7 +49,7 @@ check_tcp_udp_sockets_are_closed () # Start the service export VSOMEIP_APPLICATION_NAME=external_local_routing_test_service -export VSOMEIP_CONFIGURATION_FILE=external_local_routing_test_service.json +export VSOMEIP_CONFIGURATION=external_local_routing_test_service.json ./external_local_routing_test_service & SERIVCE_PID=$! sleep 1; @@ -59,7 +59,7 @@ check_tcp_udp_sockets_are_open $SERIVCE_PID # Start the client (we reuse the one from the local_routing_test to check # the local routing functionality). export VSOMEIP_APPLICATION_NAME=local_routing_test_client -export VSOMEIP_CONFIGURATION_FILE=local_routing_test_client.json +export VSOMEIP_CONFIGURATION=local_routing_test_client.json ./local_routing_test_client & CLIENT_PID=$! diff --git a/test/routing_tests/local_routing_test_client.cpp b/test/routing_tests/local_routing_test_client.cpp index a9a11f5..0659e48 100644 --- a/test/routing_tests/local_routing_test_client.cpp +++ b/test/routing_tests/local_routing_test_client.cpp @@ -8,13 +8,13 @@ local_routing_test_client::local_routing_test_client(bool _use_tcp) : app_(vsomeip::runtime::get()->create_application()), request_(vsomeip::runtime::get()->create_request(_use_tcp)), - sender_(std::bind(&local_routing_test_client::run, this)), running_(true), blocked_(false), is_available_(false), number_of_messages_to_send_(vsomeip_test::NUMBER_OF_MESSAGES_TO_SEND), number_of_sent_messages_(0), - number_of_acknowledged_messages_(0) + number_of_acknowledged_messages_(0), + sender_(std::bind(&local_routing_test_client::run, this)) { } @@ -22,24 +22,20 @@ void local_routing_test_client::init() { app_->init(); - app_->register_event_handler( - std::bind(&local_routing_test_client::on_event, this, + app_->register_state_handler( + std::bind(&local_routing_test_client::on_state, this, std::placeholders::_1)); - app_->register_availability_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, - vsomeip_test::TEST_SERVICE_INSTANCE_ID, - std::bind(&local_routing_test_client::on_availability, this, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); - app_->register_message_handler(vsomeip::ANY_SERVICE, vsomeip_test::TEST_SERVICE_INSTANCE_ID, vsomeip::ANY_METHOD, std::bind(&local_routing_test_client::on_message, this, std::placeholders::_1)); - request_->set_service(vsomeip_test::TEST_SERVICE_SERVICE_ID); - request_->set_instance(vsomeip_test::TEST_SERVICE_INSTANCE_ID); - request_->set_method(vsomeip_test::TEST_SERVICE_METHOD_ID); + app_->register_availability_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, + std::bind(&local_routing_test_client::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); } void local_routing_test_client::start() @@ -53,7 +49,7 @@ void local_routing_test_client::stop() VSOMEIP_INFO << "Stopping..."; app_->unregister_availability_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID); - app_->unregister_event_handler(); + app_->unregister_state_handler(); app_->unregister_message_handler(vsomeip::ANY_SERVICE, vsomeip_test::TEST_SERVICE_INSTANCE_ID, vsomeip::ANY_METHOD); @@ -66,9 +62,9 @@ void local_routing_test_client::join_sender_thread(){ ASSERT_EQ(number_of_sent_messages_, number_of_acknowledged_messages_); } -void local_routing_test_client::on_event(vsomeip::event_type_e _event) +void local_routing_test_client::on_state(vsomeip::state_type_e _state) { - if(_event == vsomeip::event_type_e::ET_REGISTERED) + if(_state == vsomeip::state_type_e::ST_REGISTERED) { app_->request_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, false); @@ -107,6 +103,11 @@ void local_routing_test_client::on_message(const std::shared_ptr<vsomeip::messag << _response->get_client() << "/" << std::setw(4) << std::setfill('0') << std::hex << _response->get_session() << "]"; number_of_acknowledged_messages_++; + if(number_of_acknowledged_messages_ == number_of_messages_to_send_) { + std::lock_guard<std::mutex> its_lock(mutex_); + blocked_ = true; + condition_.notify_one(); + } } void local_routing_test_client::send() @@ -123,8 +124,12 @@ void local_routing_test_client::run() { condition_.wait(its_lock); } + blocked_ = false; + request_->set_service(vsomeip_test::TEST_SERVICE_SERVICE_ID); + request_->set_instance(vsomeip_test::TEST_SERVICE_INSTANCE_ID); + request_->set_method(vsomeip_test::TEST_SERVICE_METHOD_ID); - for (int i = 0; i < number_of_messages_to_send_; i++) + for (uint32_t i = 0; i < number_of_messages_to_send_; i++) { app_->send(request_, true); VSOMEIP_INFO << "Client/Session [" << std::setw(4) << std::setfill('0') @@ -137,18 +142,15 @@ void local_routing_test_client::run() number_of_sent_messages_++; } blocked_ = false; - // wait until all send messages have been acknowledged, but a maximum of 5 sec. - int cnt = 0; - while (number_of_acknowledged_messages_ != number_of_messages_to_send_ - && cnt < 5) + // wait until all messages have been acknowledged + while (!blocked_) { - std::this_thread::sleep_for(std::chrono::seconds(1)); - cnt++; + condition_.wait(its_lock); } stop(); } -TEST(someip_header_factory_test, send_ten_messages_over_local_uds_socket) +TEST(someip_local_routing_test, send_ten_messages_to_service_and_receive_reply) { bool use_tcp = false; local_routing_test_client test_client_(use_tcp); diff --git a/test/routing_tests/local_routing_test_client.hpp b/test/routing_tests/local_routing_test_client.hpp index 1eedc8a..311b6eb 100644 --- a/test/routing_tests/local_routing_test_client.hpp +++ b/test/routing_tests/local_routing_test_client.hpp @@ -25,7 +25,7 @@ public: void start(); void stop(); void join_sender_thread(); - void on_event(vsomeip::event_type_e _event); + void on_state(vsomeip::state_type_e _state); void on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available); void on_message(const std::shared_ptr<vsomeip::message> &_response); @@ -37,13 +37,13 @@ private: std::shared_ptr<vsomeip::message> request_; std::mutex mutex_; std::condition_variable condition_; - std::thread sender_; bool running_; bool blocked_; bool is_available_; std::uint32_t number_of_messages_to_send_; std::uint32_t number_of_sent_messages_; std::uint32_t number_of_acknowledged_messages_; + std::thread sender_; }; #endif /* LOCALROUTINGTESTCLIENT_HPP_ */ diff --git a/test/routing_tests/local_routing_test_client.json b/test/routing_tests/local_routing_test_client.json index fa8d46a..a5991c2 100644 --- a/test/routing_tests/local_routing_test_client.json +++ b/test/routing_tests/local_routing_test_client.json @@ -22,16 +22,8 @@ } ], - "servicegroups" : + "services" : [ - { - "name" : "remote", - "unicast" : "127.0.0.1", - "services" : - [ - - ] - } ], "routing" : "local_routing_test_service", diff --git a/test/routing_tests/local_routing_test_client_start.sh b/test/routing_tests/local_routing_test_client_start.sh index ebe1bf9..1c9cad9 100755 --- a/test/routing_tests/local_routing_test_client_start.sh +++ b/test/routing_tests/local_routing_test_client_start.sh @@ -5,5 +5,5 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. export VSOMEIP_APPLICATION_NAME=local_routing_test_client -export VSOMEIP_CONFIGURATION_FILE=local_routing_test_client.json +export VSOMEIP_CONFIGURATION=local_routing_test_client.json ./local_routing_test_client diff --git a/test/routing_tests/local_routing_test_service.cpp b/test/routing_tests/local_routing_test_service.cpp index 36dbe72..7e04f01 100644 --- a/test/routing_tests/local_routing_test_service.cpp +++ b/test/routing_tests/local_routing_test_service.cpp @@ -8,10 +8,10 @@ local_routing_test_service::local_routing_test_service(bool _use_static_routing) : app_(vsomeip::runtime::get()->create_application()), is_registered_(false), - blocked_(false), use_static_routing_(_use_static_routing), - offer_thread_(std::bind(&local_routing_test_service::run, this)), - number_of_received_messages_(0) + blocked_(false), + number_of_received_messages_(0), + offer_thread_(std::bind(&local_routing_test_service::run, this)) { } @@ -25,8 +25,8 @@ void local_routing_test_service::init() std::bind(&local_routing_test_service::on_message, this, std::placeholders::_1)); - app_->register_event_handler( - std::bind(&local_routing_test_service::on_event, this, + app_->register_state_handler( + std::bind(&local_routing_test_service::on_state, this, std::placeholders::_1)); VSOMEIP_INFO << "Static routing " << (use_static_routing_ ? "ON" : "OFF"); @@ -43,7 +43,7 @@ void local_routing_test_service::stop() VSOMEIP_INFO << "Stopping..."; app_->unregister_message_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID, vsomeip_test::TEST_SERVICE_METHOD_ID); - app_->unregister_event_handler(); + app_->unregister_state_handler(); app_->stop(); } @@ -62,17 +62,18 @@ void local_routing_test_service::stop_offer() app_->stop_offer_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, vsomeip_test::TEST_SERVICE_INSTANCE_ID); } -void local_routing_test_service::on_event(vsomeip::event_type_e _event) +void local_routing_test_service::on_state(vsomeip::state_type_e _state) { VSOMEIP_INFO << "Application " << app_->get_name() << " is " - << (_event == vsomeip::event_type_e::ET_REGISTERED ? "registered." : + << (_state == vsomeip::state_type_e::ST_REGISTERED ? "registered." : "deregistered."); - if(_event == vsomeip::event_type_e::ET_REGISTERED) + if(_state == vsomeip::state_type_e::ST_REGISTERED) { if(!is_registered_) { is_registered_ = true; + std::lock_guard<std::mutex> its_lock(mutex_); blocked_ = true; // "start" the run method thread condition_.notify_one(); @@ -118,7 +119,9 @@ void local_routing_test_service::on_message(const std::shared_ptr<vsomeip::messa if(number_of_received_messages_ >= vsomeip_test::NUMBER_OF_MESSAGES_TO_SEND) { - app_->stop(); + std::lock_guard<std::mutex> its_lock(mutex_); + blocked_ =true; + condition_.notify_one(); } ASSERT_LT(number_of_received_messages_, vsomeip_test::NUMBER_OF_MESSAGES_TO_SEND + 1); @@ -130,10 +133,17 @@ void local_routing_test_service::run() while (!blocked_) condition_.wait(its_lock); + blocked_ = false; if(use_static_routing_) { offer(); } + while (!blocked_) + condition_.wait(its_lock); + + std::thread t2([](){ usleep(1000000 * 5);}); + t2.join(); + app_->stop(); } TEST(someip_local_routing_test, receive_ten_messages_over_local_uds_socket) diff --git a/test/routing_tests/local_routing_test_service.hpp b/test/routing_tests/local_routing_test_service.hpp index 8ee00b4..8cd4fb9 100644 --- a/test/routing_tests/local_routing_test_service.hpp +++ b/test/routing_tests/local_routing_test_service.hpp @@ -26,7 +26,7 @@ public: void offer(); void stop_offer(); void join_offer_thread(); - void on_event(vsomeip::event_type_e _event); + void on_state(vsomeip::state_type_e _state); void on_message(const std::shared_ptr<vsomeip::message> &_request); void run(); @@ -35,11 +35,11 @@ private: bool is_registered_; bool use_static_routing_; - std::thread offer_thread_; - std::mutex mutex_; - std::condition_variable condition_; bool blocked_; std::uint32_t number_of_received_messages_; + std::mutex mutex_; + std::condition_variable condition_; + std::thread offer_thread_; }; #endif /* LOCALROUTINGTESTSERVICE_HPP_ */ diff --git a/test/routing_tests/local_routing_test_service.json b/test/routing_tests/local_routing_test_service.json index 6726f0e..528074f 100644 --- a/test/routing_tests/local_routing_test_service.json +++ b/test/routing_tests/local_routing_test_service.json @@ -1,5 +1,5 @@ { - "unicast" : "134.86.56.183", + "unicast" : "127.0.0.1", "logging" : { "level" : "debug", @@ -21,32 +21,11 @@ } ], - "servicegroups" : + "services" : [ { - "name" : "default", - "unicast" : "local", - "delays" : - { - "initial" : - { - "minimum" : "10", - "maximum" : "100" - }, - - "repetition-base" : "200", - "repetition-max" : "3", - "cyclic-offer" : "2000", - "cyclic-request" : "2001" - }, - - "services" : - [ - { - "service" : "0x1234", - "instance" : "0x5678" - } - ] + "service" : "0x1234", + "instance" : "0x5678" } ], @@ -58,4 +37,4 @@ "port" : "30490", "protocol" : "udp" } -}
\ No newline at end of file +} diff --git a/test/routing_tests/local_routing_test_service_start.sh b/test/routing_tests/local_routing_test_service_start.sh index fef108e..acafd51 100755 --- a/test/routing_tests/local_routing_test_service_start.sh +++ b/test/routing_tests/local_routing_test_service_start.sh @@ -5,5 +5,5 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. export VSOMEIP_APPLICATION_NAME=local_routing_test_service -export VSOMEIP_CONFIGURATION_FILE=local_routing_test_service.json +export VSOMEIP_CONFIGURATION=local_routing_test_service.json ./local_routing_test_service diff --git a/test/routing_tests/local_routing_test_starter.sh b/test/routing_tests/local_routing_test_starter.sh index 6c803b9..97bd67d 100755 --- a/test/routing_tests/local_routing_test_starter.sh +++ b/test/routing_tests/local_routing_test_starter.sh @@ -35,7 +35,7 @@ check_tcp_udp_sockets_are_closed () # Start the service export VSOMEIP_APPLICATION_NAME=local_routing_test_service -export VSOMEIP_CONFIGURATION_FILE=local_routing_test_service.json +export VSOMEIP_CONFIGURATION=local_routing_test_service.json ./local_routing_test_service & SERIVCE_PID=$! sleep 1; @@ -44,7 +44,7 @@ check_tcp_udp_sockets_are_closed $SERIVCE_PID # Start the client export VSOMEIP_APPLICATION_NAME=local_routing_test_client -export VSOMEIP_CONFIGURATION_FILE=local_routing_test_client.json +export VSOMEIP_CONFIGURATION=local_routing_test_client.json ./local_routing_test_client & CLIENT_PID=$! |