diff options
Diffstat (limited to 'test/network_tests/header_factory_tests')
10 files changed, 810 insertions, 0 deletions
diff --git a/test/network_tests/header_factory_tests/header_factory_test.cpp b/test/network_tests/header_factory_tests/header_factory_test.cpp new file mode 100644 index 0000000..14abf92 --- /dev/null +++ b/test/network_tests/header_factory_tests/header_factory_test.cpp @@ -0,0 +1,119 @@ +// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include <gtest/gtest.h> + +#include <vsomeip/vsomeip.hpp> + +#include "../someip_test_globals.hpp" + +class someip_header_factory_test: public ::testing::Test +{ +protected: + std::shared_ptr<vsomeip::message> request_; + std::shared_ptr<vsomeip::message> response_; + std::shared_ptr<vsomeip::message> notification_; + std::shared_ptr<vsomeip::application> app_; + std::shared_ptr<vsomeip::message> message_; + + vsomeip::service_t service_id_ = vsomeip_test::TEST_SERVICE_SERVICE_ID; + vsomeip::method_t method_id_ = vsomeip_test::TEST_SERVICE_METHOD_ID; + vsomeip::instance_t instance_id_ = vsomeip_test::TEST_SERVICE_INSTANCE_ID; + vsomeip::interface_version_t interface_version_ = 0x01; + vsomeip::client_t client_id_ = vsomeip_test::TEST_CLIENT_CLIENT_ID; + vsomeip::session_t session_id_ = vsomeip_test::TEST_INITIAL_SESSION_ID; +}; + +TEST_F(someip_header_factory_test, create_request_test) +{ + ASSERT_TRUE(request_.get() == nullptr); + request_ = vsomeip::runtime::get()->create_request(); + + // check that returned shared_ptr is not null + ASSERT_TRUE(request_.get() != nullptr); + + // Check the protocol version + // this shall be set to 0x01 according to the spec. TR_SOMEIP_00052 + ASSERT_EQ(request_->get_protocol_version(), 0x01); + // Check the message type + // this shall be 0x00 (REQUEST) according to the spec. TR_SOMEIP_00055 + ASSERT_EQ(request_->get_message_type(), vsomeip::message_type_e::MT_REQUEST); + // Check the return code + // this shall be 0x00 (E_OK) according to the spec. TR_SOMEIP_00058 + ASSERT_EQ(request_->get_return_code(), vsomeip::return_code_e::E_OK); + +} + +TEST_F(someip_header_factory_test, create_request_and_response_test) +{ + ASSERT_TRUE(request_.get() == nullptr); + request_ = vsomeip::runtime::get()->create_request(); + // check that returned shared_ptr is not null + ASSERT_TRUE(request_.get() != nullptr); + + request_->set_service(service_id_); + request_->set_method(method_id_); + request_->set_interface_version(interface_version_); + // set the request_id (client_id + session_id). This normally is set by the + // application_impl::send() if a request is send, we set it here to test the + // correct initialization of the response + request_->set_client(client_id_); + request_->set_session(session_id_); + + ASSERT_TRUE(response_.get() == nullptr); + response_ = vsomeip::runtime::get()->create_response(request_); + // check that returned shared_ptr is not null + ASSERT_TRUE(response_.get() != nullptr); + + ASSERT_EQ(response_->get_service(), request_->get_service()); + ASSERT_EQ(response_->get_method(), request_->get_method()); + ASSERT_EQ(response_->get_session(), request_->get_session()); + + // length? --> gets only set if a payload is added + + ASSERT_EQ(response_->get_protocol_version(), request_->get_protocol_version()); + ASSERT_EQ(response_->get_interface_version(), request_->get_interface_version()); + + // Check the message type + // this shall be 0x00 (REQUEST) according to the spec. TR_SOMEIP_00055 + ASSERT_EQ(request_->get_message_type(), vsomeip::message_type_e::MT_REQUEST); + + // Check the message type + // this shall be 0x80 (RESPONSE) according to the spec. TR_SOMEIP_00055 + ASSERT_EQ(response_->get_message_type(), vsomeip::message_type_e::MT_RESPONSE); + + // Check the return code + // this shall be 0x00 (E_OK) according to the spec. TR_SOMEIP_00058 + // and TR_SOMEIP_00191 + ASSERT_EQ(response_->get_return_code(), vsomeip::return_code_e::E_OK); + +} + +TEST_F(someip_header_factory_test, create_notification_test) +{ + ASSERT_TRUE(notification_.get() == nullptr); + notification_ = vsomeip::runtime::get()->create_notification(); + + // check that returned shared_ptr is not null + ASSERT_TRUE(notification_.get() != nullptr); + + // Check the protocol version + // this shall be set to 0x01 according to the spec. TR_SOMEIP_00052 + ASSERT_EQ(notification_->get_protocol_version(), 0x01); + // Check the message type + // this shall be 0x02 (NOTIFICATION) according to the spec. TR_SOMEIP_00055 + ASSERT_EQ(notification_->get_message_type(), vsomeip::message_type_e::MT_NOTIFICATION); + // Check the return code + // this shall be 0x00 (E_OK) according to the spec. TR_SOMEIP_00058 + ASSERT_EQ(notification_->get_return_code(), vsomeip::return_code_e::E_OK); +} + +#if defined(__linux__) || defined(ANDROID) +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} +#endif diff --git a/test/network_tests/header_factory_tests/header_factory_test_client.cpp b/test/network_tests/header_factory_tests/header_factory_test_client.cpp new file mode 100644 index 0000000..3435dea --- /dev/null +++ b/test/network_tests/header_factory_tests/header_factory_test_client.cpp @@ -0,0 +1,170 @@ +// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "header_factory_test_client.hpp" + +header_factory_test_client::header_factory_test_client(bool _use_tcp) : + app_(vsomeip::runtime::get()->create_application()), + request_(vsomeip::runtime::get()->create_request(_use_tcp)), + 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), + sender_(std::bind(&header_factory_test_client::run, this)) +{ +} + +bool header_factory_test_client::init() +{ + if (!app_->init()) { + ADD_FAILURE() << "Couldn't initialize application"; + return false; + } + + app_->register_state_handler( + std::bind(&header_factory_test_client::on_state, this, + std::placeholders::_1)); + + app_->register_message_handler(vsomeip::ANY_SERVICE, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, vsomeip::ANY_METHOD, + std::bind(&header_factory_test_client::on_message, this, + std::placeholders::_1)); + + app_->register_availability_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, + std::bind(&header_factory_test_client::on_availability, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); + return true; +} + +void header_factory_test_client::start() +{ + VSOMEIP_INFO << "Starting..."; + app_->start(); +} + +void header_factory_test_client::stop() +{ + VSOMEIP_INFO << "Stopping..."; + app_->clear_all_handler(); + app_->stop(); +} + +void header_factory_test_client::join_sender_thread(){ + sender_.join(); + + ASSERT_EQ(number_of_sent_messages_, number_of_acknowledged_messages_); +} + +void header_factory_test_client::on_state(vsomeip::state_type_e _state) +{ + if(_state == vsomeip::state_type_e::ST_REGISTERED) + { + app_->request_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, false); + } +} + +void header_factory_test_client::on_availability(vsomeip::service_t _service, + vsomeip::instance_t _instance, bool _is_available) +{ + VSOMEIP_INFO << "Service [" << std::setw(4) << std::setfill('0') << std::hex + << _service << "." << _instance << "] is " + << (_is_available ? "available." : "NOT available."); + + if(vsomeip_test::TEST_SERVICE_SERVICE_ID == _service + && vsomeip_test::TEST_SERVICE_INSTANCE_ID == _instance) + { + if(is_available_ && !_is_available) + { + is_available_ = false; + } + else if(_is_available && !is_available_) + { + is_available_ = true; + send(); + } + } +} + +void header_factory_test_client::on_message(const std::shared_ptr<vsomeip::message>& _response) +{ + VSOMEIP_INFO << "Received a response from Service [" << std::setw(4) + << std::setfill('0') << std::hex << _response->get_service() << "." + << std::setw(4) << std::setfill('0') << std::hex + << _response->get_instance() << "] to Client/Session [" + << std::setw(4) << std::setfill('0') << std::hex + << _response->get_client() << "/" << std::setw(4) + << std::setfill('0') << std::hex << _response->get_session() << "]"; + number_of_acknowledged_messages_++; + ASSERT_EQ(_response->get_service(), vsomeip_test::TEST_SERVICE_SERVICE_ID); + ASSERT_EQ(_response->get_instance(), vsomeip_test::TEST_SERVICE_INSTANCE_ID); + ASSERT_EQ(_response->get_session(), + static_cast<vsomeip::session_t>(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 header_factory_test_client::send() +{ + std::lock_guard<std::mutex> its_lock(mutex_); + blocked_ = true; + condition_.notify_one(); +} + +void header_factory_test_client::run() +{ + std::unique_lock<std::mutex> its_lock(mutex_); + while (!blocked_) + { + 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 (uint32_t i = 0; i < number_of_messages_to_send_; i++) + { + app_->send(request_); + VSOMEIP_INFO << "Client/Session [" << std::setw(4) << std::setfill('0') + << std::hex << request_->get_client() << "/" << std::setw(4) + << std::setfill('0') << std::hex << request_->get_session() + << "] sent a request to Service [" << std::setw(4) + << std::setfill('0') << std::hex << request_->get_service() + << "." << std::setw(4) << std::setfill('0') << std::hex + << request_->get_instance() << "]"; + number_of_sent_messages_++; + } + // wait until all messages have been acknowledged + while (!blocked_) + { + condition_.wait(its_lock); + } + stop(); +} + +TEST(someip_header_factory_test, send_message_ten_times_test) +{ + bool use_tcp = false; + header_factory_test_client test_client_(use_tcp); + if (test_client_.init()) { + test_client_.start(); + test_client_.join_sender_thread(); + } +} + +#if defined(__linux__) || defined(ANDROID) +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} +#endif diff --git a/test/network_tests/header_factory_tests/header_factory_test_client.hpp b/test/network_tests/header_factory_tests/header_factory_test_client.hpp new file mode 100644 index 0000000..8e9a4c2 --- /dev/null +++ b/test/network_tests/header_factory_tests/header_factory_test_client.hpp @@ -0,0 +1,48 @@ +// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef HEADERFACTORYTESTCLIENT_HPP_ +#define HEADERFACTORYTESTCLIENT_HPP_ + +#include <gtest/gtest.h> + +#include <vsomeip/vsomeip.hpp> + +#include <thread> +#include <mutex> +#include <condition_variable> +#include <functional> + +#include "../someip_test_globals.hpp" + +class header_factory_test_client +{ +public: + header_factory_test_client(bool _use_tcp); + bool init(); + void start(); + void stop(); + void join_sender_thread(); + 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); + void send(); + void run(); + +private: + std::shared_ptr<vsomeip::application> app_; + std::shared_ptr<vsomeip::message> request_; + std::mutex mutex_; + std::condition_variable condition_; + 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 /* HEADERFACTORYTESTCLIENT_HPP_ */ diff --git a/test/network_tests/header_factory_tests/header_factory_test_client.json b/test/network_tests/header_factory_tests/header_factory_test_client.json new file mode 100644 index 0000000..71bc75b --- /dev/null +++ b/test/network_tests/header_factory_tests/header_factory_test_client.json @@ -0,0 +1,97 @@ +{ + "unicast" : "127.0.0.1", + "netmask" : "255.255.255.0", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : + { + "enable" : "true", + "path" : "/var/log/vsomeip.log" + }, + + "dlt" : "true" + }, + + "applications" : + [ + { + "name" : "header_factory_test_client", + "id" : "0x1343" + } + ], + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "unreliable" : "30509", + "events" : + [ + { + "event" : "0x0777", + "is_field" : "true" + }, + + { + "event" : "0x0778", + "is_field" : "false" + }, + + { + "event" : "0x0779", + "is_field" : "true" + } + ], + + "eventgroups" : + [ + { + "eventgroup" : "0x4455", + "events" : + [ + "0x777", + "0x778" + ] + }, + + { + "eventgroup" : "0x4465", + "events" : + [ + "0x778", + "0x779" + ], + + "is_multicast" : "true" + }, + + { + "eventgroup" : "0x4555", + "events" : + [ + "0x777", + "0x779" + ] + } + ] + } + ], + + "routing" : "header_factory_test_service", + "service-discovery" : + { + "enable" : "false", + "multicast" : "224.0.0.1", + "port" : "30491", + "protocol" : "udp", + "initial_delay_min" : "10", + "initial_delay_max" : "100", + "repetitions_base_delay" : "200", + "repetitions_max" : "3", + "ttl" : "3", + "cyclic_offer_delay" : "2000", + "request_response_delay" : "1500" + } +}
\ No newline at end of file diff --git a/test/network_tests/header_factory_tests/header_factory_test_client_start.sh b/test/network_tests/header_factory_tests/header_factory_test_client_start.sh new file mode 100755 index 0000000..4e9c1ed --- /dev/null +++ b/test/network_tests/header_factory_tests/header_factory_test_client_start.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +export VSOMEIP_APPLICATION_NAME=header_factory_test_client +export VSOMEIP_CONFIGURATION=header_factory_test_client.json +./header_factory_test_client diff --git a/test/network_tests/header_factory_tests/header_factory_test_send_receive_starter.sh b/test/network_tests/header_factory_tests/header_factory_test_send_receive_starter.sh new file mode 100755 index 0000000..5d1d780 --- /dev/null +++ b/test/network_tests/header_factory_tests/header_factory_test_send_receive_starter.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Purpose: This script is needed to start the client and service with +# one command. This is necessary as ctest - which is used to run the +# tests - isn't able to start two binaries for one testcase. Therefore +# the testcase simply executes this script. This script then runs client +# and service and checks that both exit sucessfully. + +# Start the service +export VSOMEIP_APPLICATION_NAME=header_factory_test_service +export VSOMEIP_CONFIGURATION=header_factory_test_service.json +./header_factory_test_service & +sleep 1; + +# Start the client +export VSOMEIP_APPLICATION_NAME=header_factory_test_client +export VSOMEIP_CONFIGURATION=header_factory_test_client.json +./header_factory_test_client & + +# Wait until client and service are finished +FAIL=0 +for job in $(jobs -p) +do + # Fail gets incremented if either client or service exit + # with a non-zero exit code + wait $job || ((FAIL+=1)) +done + +# Check if client and server both exited sucessfully +if [ $FAIL -eq 0 ] +then + exit 0 +else + exit 1 +fi diff --git a/test/network_tests/header_factory_tests/header_factory_test_service.cpp b/test/network_tests/header_factory_tests/header_factory_test_service.cpp new file mode 100644 index 0000000..4caca7a --- /dev/null +++ b/test/network_tests/header_factory_tests/header_factory_test_service.cpp @@ -0,0 +1,170 @@ +// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "header_factory_test_service.hpp" + +#include <cstdlib> + +header_factory_test_service::header_factory_test_service(bool _use_static_routing) : + app_(vsomeip::runtime::get()->create_application()), + is_registered_(false), + use_static_routing_(_use_static_routing), + blocked_(false), + number_of_received_messages_(0), + offer_thread_(std::bind(&header_factory_test_service::run, this)) +{ +} + +bool header_factory_test_service::init() +{ + std::lock_guard<std::mutex> its_lock(mutex_); + + if (!app_->init()) { + ADD_FAILURE() << "Couldn't initialize application"; + return false; + } + app_->register_message_handler(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID, vsomeip_test::TEST_SERVICE_METHOD_ID, + std::bind(&header_factory_test_service::on_message, this, + std::placeholders::_1)); + + app_->register_state_handler( + std::bind(&header_factory_test_service::on_state, this, + std::placeholders::_1)); + + VSOMEIP_INFO << "Static routing " << (use_static_routing_ ? "ON" : "OFF"); + return true; +} + +void header_factory_test_service::start() +{ + VSOMEIP_INFO << "Starting..."; + app_->start(); +} + +void header_factory_test_service::stop() +{ + VSOMEIP_INFO << "Stopping..."; + app_->clear_all_handler(); + app_->stop(); + std::thread t([](){ std::this_thread::sleep_for(std::chrono::microseconds(1000000 * 5));}); + t.join(); +} + +void header_factory_test_service::join_offer_thread() +{ + offer_thread_.join(); +} + +void header_factory_test_service::offer() +{ + app_->offer_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID); +} + +void header_factory_test_service::stop_offer() +{ + app_->stop_offer_service(vsomeip_test::TEST_SERVICE_SERVICE_ID, + vsomeip_test::TEST_SERVICE_INSTANCE_ID); +} + +void header_factory_test_service::on_state(vsomeip::state_type_e _state) +{ + VSOMEIP_INFO << "Application " << app_->get_name() << " is " + << (_state == vsomeip::state_type_e::ST_REGISTERED ? "registered." : + "deregistered."); + + 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(); + } + } + else + { + is_registered_ = false; + } +} + +void header_factory_test_service::on_message(const std::shared_ptr<vsomeip::message>& _request) +{ + VSOMEIP_INFO << "Received a message with Client/Session [" << std::setw(4) + << std::setfill('0') << std::hex << _request->get_client() << "/" + << std::setw(4) << std::setfill('0') << std::hex + << _request->get_session() << "]"; + + number_of_received_messages_++; + + ASSERT_EQ(_request->get_service(), vsomeip_test::TEST_SERVICE_SERVICE_ID); + ASSERT_EQ(_request->get_method(), vsomeip_test::TEST_SERVICE_METHOD_ID); + + // Check the protocol version this shall be set to 0x01 according to the spec. + // TR_SOMEIP_00052 + ASSERT_EQ(_request->get_protocol_version(), 0x01); + // Check the message type this shall be 0xx (REQUEST) according to the spec. + // TR_SOMEIP_00055 + ASSERT_EQ(_request->get_message_type(), vsomeip::message_type_e::MT_REQUEST); + + // check the session id. + ASSERT_EQ(_request->get_session(), static_cast<vsomeip::session_t>(number_of_received_messages_)); + + + // send response + std::shared_ptr<vsomeip::message> its_response = + vsomeip::runtime::get()->create_response(_request); + + app_->send(its_response); + + if(number_of_received_messages_ >= vsomeip_test::NUMBER_OF_MESSAGES_TO_SEND) + { + 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); +} + +void header_factory_test_service::run() +{ + std::unique_lock<std::mutex> its_lock(mutex_); + while (!blocked_) + condition_.wait(its_lock); + + blocked_ = false; + if(use_static_routing_) + { + offer(); + } + while (!blocked_) + condition_.wait(its_lock); + + std::thread t([](){ std::this_thread::sleep_for(std::chrono::microseconds(1000000 * 5));}); + t.join(); + app_->stop(); +} + +TEST(someip_header_factory_test, reveice_message_ten_times_test) +{ + bool use_static_routing = true; + header_factory_test_service test_service(use_static_routing); + if (test_service.init()) { + test_service.start(); + test_service.join_offer_thread(); + } +} + +#if defined(__linux__) || defined(ANDROID) +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} +#endif diff --git a/test/network_tests/header_factory_tests/header_factory_test_service.hpp b/test/network_tests/header_factory_tests/header_factory_test_service.hpp new file mode 100644 index 0000000..32e49e5 --- /dev/null +++ b/test/network_tests/header_factory_tests/header_factory_test_service.hpp @@ -0,0 +1,45 @@ +// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef HEADERFACTORYTESTSERVICE_HPP_ +#define HEADERFACTORYTESTSERVICE_HPP_ +#include <gtest/gtest.h> + +#include <vsomeip/vsomeip.hpp> + +#include <thread> +#include <mutex> +#include <condition_variable> +#include <functional> + +#include "../someip_test_globals.hpp" + +class header_factory_test_service +{ +public: + header_factory_test_service(bool _use_static_routing); + bool init(); + void start(); + void stop(); + void offer(); + void stop_offer(); + void join_offer_thread(); + void on_state(vsomeip::state_type_e _state); + void on_message(const std::shared_ptr<vsomeip::message> &_request); + void run(); + +private: + std::shared_ptr<vsomeip::application> app_; + bool is_registered_; + bool use_static_routing_; + + std::mutex mutex_; + std::condition_variable condition_; + bool blocked_; + std::uint32_t number_of_received_messages_; + std::thread offer_thread_; +}; + +#endif /* HEADERFACTORYTESTSERVICE_HPP_ */ diff --git a/test/network_tests/header_factory_tests/header_factory_test_service.json b/test/network_tests/header_factory_tests/header_factory_test_service.json new file mode 100644 index 0000000..a99d0a2 --- /dev/null +++ b/test/network_tests/header_factory_tests/header_factory_test_service.json @@ -0,0 +1,105 @@ +{ + "unicast" : "127.0.0.1", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : + { + "enable" : "false", + "path" : "/tmp/vsomeip.log" + }, + "dlt" : "false" + }, + + "applications" : + [ + { + "name" : "header_factory_test_service", + "id" : "0x1277" + } + ], + + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "unreliable" : "30509", + "multicast" : + { + "address" : "224.225.226.233", + "port" : "32344" + }, + + "events" : + [ + { + "event" : "0x0777", + "is_field" : "true", + "update-cycle" : 2000 + }, + + { + "event" : "0x0778", + "is_field" : "true", + "update-cycle" : 0 + }, + + { + "event" : "0x0779", + "is_field" : "true" + } + ], + + "eventgroups" : + [ + { + "eventgroup" : "0x4455", + "events" : + [ + "0x777", + "0x778" + ] + }, + + { + "eventgroup" : "0x4465", + "events" : + [ + "0x778", + "0x779" + ], + + "is_multicast" : "true" + }, + + { + "eventgroup" : "0x4555", + "events" : + [ + "0x777", + "0x779" + ] + } + ] + } + ], + + "routing" : "header_factory_test_service", + + "service-discovery" : + { + "enable" : "false", + "multicast" : "224.0.0.1", + "port" : "30490", + "protocol" : "udp", + "initial_delay_min" : "10", + "initial_delay_max" : "100", + "repetitions_base_delay" : "200", + "repetitions_max" : "3", + "ttl" : "3", + "cyclic_offer_delay" : "2000", + "request_response_delay" : "1500" + } +}
\ No newline at end of file diff --git a/test/network_tests/header_factory_tests/header_factory_test_service_start.sh b/test/network_tests/header_factory_tests/header_factory_test_service_start.sh new file mode 100755 index 0000000..e123a46 --- /dev/null +++ b/test/network_tests/header_factory_tests/header_factory_test_service_start.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +export VSOMEIP_APPLICATION_NAME=header_factory_test_service +export VSOMEIP_CONFIGURATION=header_factory_test_service.json +./header_factory_test_service |