From f9e11231f250363dc2c24353172e60835e0bdaef Mon Sep 17 00:00:00 2001 From: vjayaraman Date: Mon, 30 Sep 2024 16:30:27 +0200 Subject: [PATCH 1/2] libeloscpp utest setup completed --- test/utest/CMakeLists.txt | 1 + test/utest/libelos-cpp/CMakeLists.txt | 7 +++++ test/utest/libelos-cpp/connect/CMakeLists.txt | 15 ++++++++++ .../libelos-cpp/connect/case_success.cpp | 23 +++++++++++++++ .../libelos-cpp/connect/connect_utest.cpp | 20 +++++++++++++ .../utest/libelos-cpp/connect/connect_utest.h | 13 +++++++++ .../libelos-cpp/disconnect/CMakeLists.txt | 15 ++++++++++ .../libelos-cpp/disconnect/case_success.cpp | 23 +++++++++++++++ .../disconnect/disconnect_utest.cpp | 20 +++++++++++++ .../libelos-cpp/disconnect/disconnect_utest.h | 13 +++++++++ test/utest/libelos-cpp/publish/CMakeLists.txt | 15 ++++++++++ .../libelos-cpp/publish/case_success.cpp | 24 ++++++++++++++++ .../libelos-cpp/publish/publish_utest.cpp | 20 +++++++++++++ .../utest/libelos-cpp/publish/publish_utest.h | 13 +++++++++ .../libelos-cpp/subscribe/CMakeLists.txt | 15 ++++++++++ .../libelos-cpp/subscribe/case_success.cpp | 28 +++++++++++++++++++ .../libelos-cpp/subscribe/subscribe_utest.cpp | 20 +++++++++++++ .../libelos-cpp/subscribe/subscribe_utest.h | 13 +++++++++ 18 files changed, 298 insertions(+) create mode 100644 test/utest/libelos-cpp/CMakeLists.txt create mode 100644 test/utest/libelos-cpp/connect/CMakeLists.txt create mode 100644 test/utest/libelos-cpp/connect/case_success.cpp create mode 100644 test/utest/libelos-cpp/connect/connect_utest.cpp create mode 100644 test/utest/libelos-cpp/connect/connect_utest.h create mode 100644 test/utest/libelos-cpp/disconnect/CMakeLists.txt create mode 100644 test/utest/libelos-cpp/disconnect/case_success.cpp create mode 100644 test/utest/libelos-cpp/disconnect/disconnect_utest.cpp create mode 100644 test/utest/libelos-cpp/disconnect/disconnect_utest.h create mode 100644 test/utest/libelos-cpp/publish/CMakeLists.txt create mode 100644 test/utest/libelos-cpp/publish/case_success.cpp create mode 100644 test/utest/libelos-cpp/publish/publish_utest.cpp create mode 100644 test/utest/libelos-cpp/publish/publish_utest.h create mode 100644 test/utest/libelos-cpp/subscribe/CMakeLists.txt create mode 100644 test/utest/libelos-cpp/subscribe/case_success.cpp create mode 100644 test/utest/libelos-cpp/subscribe/subscribe_utest.cpp create mode 100644 test/utest/libelos-cpp/subscribe/subscribe_utest.h diff --git a/test/utest/CMakeLists.txt b/test/utest/CMakeLists.txt index e8438a25..da1e6ca5 100644 --- a/test/utest/CMakeLists.txt +++ b/test/utest/CMakeLists.txt @@ -3,6 +3,7 @@ if(UNIT_TESTS) include(unit_test.cmake) add_subdirectory(components) add_subdirectory(libelos) + add_subdirectory(libelos-cpp) if (ELOS_PLUGINS) add_subdirectory(plugins) endif (ELOS_PLUGINS) diff --git a/test/utest/libelos-cpp/CMakeLists.txt b/test/utest/libelos-cpp/CMakeLists.txt new file mode 100644 index 00000000..30bcdced --- /dev/null +++ b/test/utest/libelos-cpp/CMakeLists.txt @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: MIT + +add_subdirectory(connect) +add_subdirectory(disconnect) +add_subdirectory(publish) +add_subdirectory(subscribe) + diff --git a/test/utest/libelos-cpp/connect/CMakeLists.txt b/test/utest/libelos-cpp/connect/CMakeLists.txt new file mode 100644 index 00000000..792e4532 --- /dev/null +++ b/test/utest/libelos-cpp/connect/CMakeLists.txt @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: MIT +find_package(safu 0.56.2 REQUIRED) +find_package(cmocka_mocks 0.54.2 REQUIRED) + +enable_language(CXX) + +create_unit_test( + NAME + test_libelos-cpp_connect_utest + SOURCES + case_success.cpp + connect_utest.cpp + LIBRARIES + libelos-cpp_static +) diff --git a/test/utest/libelos-cpp/connect/case_success.cpp b/test/utest/libelos-cpp/connect/case_success.cpp new file mode 100644 index 00000000..81545abf --- /dev/null +++ b/test/utest/libelos-cpp/connect/case_success.cpp @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +#include "connect_utest.h" + +int elosTestConnectSuccessSetup(UNUSED void **state) { + return 0; +} + +int elosTestConnectSuccessTeardown(UNUSED void **state) { + return 0; +} + +void elosTestConnectSuccess(UNUSED void **state) { + using namespace elos; + elosSession_t *testSession = NULL; + safuResultE_t result; + Elos testObject; + + TEST("connect"); + SHOULD("%s", "create successfully a tcp-ip connection"); + + result = testObject.connect("0.0.0.0", 54321, &testSession); + assert_int_equal(result, SAFU_RESULT_OK); +} diff --git a/test/utest/libelos-cpp/connect/connect_utest.cpp b/test/utest/libelos-cpp/connect/connect_utest.cpp new file mode 100644 index 00000000..51ed9f47 --- /dev/null +++ b/test/utest/libelos-cpp/connect/connect_utest.cpp @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +#include "connect_utest.h" + +TEST_SUITE_FUNC_PROTOTYPES(connectUtest) + +int main() { + const struct CMUnitTest tests[] = { + TEST_CASE(elosTestConnectSuccess), + }; + + return RUN_TEST_SUITE(tests, connectUtest); +} + +static int connectUtestSetup(UNUSED void **state) { + return 0; +} + +static int connectUtestTeardown(UNUSED void **state) { + return 0; +} diff --git a/test/utest/libelos-cpp/connect/connect_utest.h b/test/utest/libelos-cpp/connect/connect_utest.h new file mode 100644 index 00000000..b6462bd0 --- /dev/null +++ b/test/utest/libelos-cpp/connect/connect_utest.h @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +#pragma once +#include +#include +#include +#include +extern "C" { +#include +} +#include +#include + +TEST_CASE_FUNC_PROTOTYPES(elosTestConnectSuccess) diff --git a/test/utest/libelos-cpp/disconnect/CMakeLists.txt b/test/utest/libelos-cpp/disconnect/CMakeLists.txt new file mode 100644 index 00000000..60c45590 --- /dev/null +++ b/test/utest/libelos-cpp/disconnect/CMakeLists.txt @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: MIT +find_package(safu 0.56.2 REQUIRED) +find_package(cmocka_mocks 0.54.2 REQUIRED) + +enable_language(CXX) + +create_unit_test( + NAME + test_libelos-cpp_disconnect_utest + SOURCES + case_success.cpp + disconnect_utest.cpp + LIBRARIES + libelos-cpp_static +) diff --git a/test/utest/libelos-cpp/disconnect/case_success.cpp b/test/utest/libelos-cpp/disconnect/case_success.cpp new file mode 100644 index 00000000..6fe44ca6 --- /dev/null +++ b/test/utest/libelos-cpp/disconnect/case_success.cpp @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +#include "disconnect_utest.h" + +int elosTestDisconnectSuccessSetup(UNUSED void **state) { + return 0; +} + +int elosTestDisconnectSuccessTeardown(UNUSED void **state) { + return 0; +} + +void elosTestDisconnectSuccess(UNUSED void **state) { + using namespace elos; + elosSession_t *testSession = NULL; + safuResultE_t result; + Elos testObject; + + TEST("disconnect"); + SHOULD("%s", "successfully close a connection"); + + result = testObject.disconnect(&testSession); + assert_int_equal(result, SAFU_RESULT_OK); +} diff --git a/test/utest/libelos-cpp/disconnect/disconnect_utest.cpp b/test/utest/libelos-cpp/disconnect/disconnect_utest.cpp new file mode 100644 index 00000000..9c452383 --- /dev/null +++ b/test/utest/libelos-cpp/disconnect/disconnect_utest.cpp @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +#include "disconnect_utest.h" + +TEST_SUITE_FUNC_PROTOTYPES(disconnectUtest) + +int main() { + const struct CMUnitTest tests[] = { + TEST_CASE(elosTestDisconnectSuccess), + }; + + return RUN_TEST_SUITE(tests, disconnectUtest); +} + +static int disconnectUtestSetup(UNUSED void **state) { + return 0; +} + +static int disconnectUtestTeardown(UNUSED void **state) { + return 0; +} diff --git a/test/utest/libelos-cpp/disconnect/disconnect_utest.h b/test/utest/libelos-cpp/disconnect/disconnect_utest.h new file mode 100644 index 00000000..7ef9d9e0 --- /dev/null +++ b/test/utest/libelos-cpp/disconnect/disconnect_utest.h @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +#pragma once +#include +#include +#include +#include +extern "C" { +#include +} +#include +#include + +TEST_CASE_FUNC_PROTOTYPES(elosTestDisconnectSuccess) diff --git a/test/utest/libelos-cpp/publish/CMakeLists.txt b/test/utest/libelos-cpp/publish/CMakeLists.txt new file mode 100644 index 00000000..5c6692a0 --- /dev/null +++ b/test/utest/libelos-cpp/publish/CMakeLists.txt @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: MIT +find_package(safu 0.56.2 REQUIRED) +find_package(cmocka_mocks 0.54.2 REQUIRED) + +enable_language(CXX) + +create_unit_test( + NAME + test_libelos-cpp_publish_utest + SOURCES + case_success.cpp + publish_utest.cpp + LIBRARIES + libelos-cpp_static +) diff --git a/test/utest/libelos-cpp/publish/case_success.cpp b/test/utest/libelos-cpp/publish/case_success.cpp new file mode 100644 index 00000000..101dbc32 --- /dev/null +++ b/test/utest/libelos-cpp/publish/case_success.cpp @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +#include "publish_utest.h" + +int elosTestPublishSuccessSetup(UNUSED void **state) { + return 0; +} + +int elosTestPublishSuccessTeardown(UNUSED void **state) { + return 0; +} + +void elosTestPublishSuccess(UNUSED void **state) { + using namespace elos; + elosSession_t *testSession = NULL; + elosEvent_t *testEvent = NULL; + safuResultE_t result; + Elos testObject; + + TEST("publish"); + SHOULD("%s", "successfully publish an event"); + + result = testObject.publish(&testSession, testEvent); + assert_int_equal(result, SAFU_RESULT_OK); +} diff --git a/test/utest/libelos-cpp/publish/publish_utest.cpp b/test/utest/libelos-cpp/publish/publish_utest.cpp new file mode 100644 index 00000000..ae9ee227 --- /dev/null +++ b/test/utest/libelos-cpp/publish/publish_utest.cpp @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +#include "publish_utest.h" + +TEST_SUITE_FUNC_PROTOTYPES(publishUtest) + +int main() { + const struct CMUnitTest tests[] = { + TEST_CASE(elosTestPublishSuccess), + }; + + return RUN_TEST_SUITE(tests, publishUtest); +} + +static int publishUtestSetup(UNUSED void **state) { + return 0; +} + +static int publishUtestTeardown(UNUSED void **state) { + return 0; +} diff --git a/test/utest/libelos-cpp/publish/publish_utest.h b/test/utest/libelos-cpp/publish/publish_utest.h new file mode 100644 index 00000000..c69afd35 --- /dev/null +++ b/test/utest/libelos-cpp/publish/publish_utest.h @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +#pragma once +#include +#include +#include +#include +extern "C" { +#include +} +#include +#include + +TEST_CASE_FUNC_PROTOTYPES(elosTestPublishSuccess) diff --git a/test/utest/libelos-cpp/subscribe/CMakeLists.txt b/test/utest/libelos-cpp/subscribe/CMakeLists.txt new file mode 100644 index 00000000..dc4eecbd --- /dev/null +++ b/test/utest/libelos-cpp/subscribe/CMakeLists.txt @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: MIT +find_package(safu 0.56.2 REQUIRED) +find_package(cmocka_mocks 0.54.2 REQUIRED) + +enable_language(CXX) + +create_unit_test( + NAME + test_libelos-cpp_subscribe_utest + SOURCES + case_success.cpp + subscribe_utest.cpp + LIBRARIES + libelos-cpp_static +) diff --git a/test/utest/libelos-cpp/subscribe/case_success.cpp b/test/utest/libelos-cpp/subscribe/case_success.cpp new file mode 100644 index 00000000..fff65a68 --- /dev/null +++ b/test/utest/libelos-cpp/subscribe/case_success.cpp @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT +#include + +#include "subscribe_utest.h" + +int elosTestSubscribeSuccessSetup(UNUSED void **state) { + return 0; +} + +int elosTestSubscribeSuccessTeardown(UNUSED void **state) { + return 0; +} + +void elosTestSubscribeSuccess(UNUSED void **state) { + using namespace elos; + elosSession_t *testSession = NULL; + const char *testFilterRule = NULL; + size_t testSize = 0; + elosEventQueueId_t *testQueue = NULL; + safuResultE_t result; + Elos testObject; + + TEST("subscribe"); + SHOULD("%s", "Create a subscription message, send it, evaluate the response and return list of message queue ids"); + + result = testObject.subscribe(&testSession, &testFilterRule, testSize, testQueue); + assert_int_equal(result, SAFU_RESULT_OK); +} diff --git a/test/utest/libelos-cpp/subscribe/subscribe_utest.cpp b/test/utest/libelos-cpp/subscribe/subscribe_utest.cpp new file mode 100644 index 00000000..e170f0f5 --- /dev/null +++ b/test/utest/libelos-cpp/subscribe/subscribe_utest.cpp @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +#include "subscribe_utest.h" + +TEST_SUITE_FUNC_PROTOTYPES(subscribeUtest) + +int main() { + const struct CMUnitTest tests[] = { + TEST_CASE(elosTestSubscribeSuccess), + }; + + return RUN_TEST_SUITE(tests, subscribeUtest); +} + +static int subscribeUtestSetup(UNUSED void **state) { + return 0; +} + +static int subscribeUtestTeardown(UNUSED void **state) { + return 0; +} diff --git a/test/utest/libelos-cpp/subscribe/subscribe_utest.h b/test/utest/libelos-cpp/subscribe/subscribe_utest.h new file mode 100644 index 00000000..3d4ce18b --- /dev/null +++ b/test/utest/libelos-cpp/subscribe/subscribe_utest.h @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +#pragma once +#include +#include +#include +#include +extern "C" { +#include +} +#include +#include + +TEST_CASE_FUNC_PROTOTYPES(elosTestSubscribeSuccess) From 64ead5bdf97d1b2e03effb7d488b1bd405c6b725 Mon Sep 17 00:00:00 2001 From: Wolfgang Gehrhardt Date: Wed, 9 Oct 2024 17:41:57 +0200 Subject: [PATCH 2/2] elos: Update to 0.65.1 --- cmake/project.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/project.cmake b/cmake/project.cmake index 7866e326..0ebc2bb2 100644 --- a/cmake/project.cmake +++ b/cmake/project.cmake @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -set(ELOS_VERSION 0.65.0) +set(ELOS_VERSION 0.65.1) # Attention: Aside from the version, as many things as possible in this file # should be put into functions, as this solves potential issues with commands