Skip to content

Commit

Permalink
Core SDK unit test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaKasar committed Sep 23, 2024
1 parent ed1d3c1 commit 031a761
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ endif ()

find_package(WPEFramework CONFIG REQUIRED)
find_package(${NAMESPACE}Core CONFIG REQUIRED)
find_package(Firebolt CONFIG REQUIRED)
find_package(${FIREBOLT_NAMESPACE}SDK CONFIG REQUIRED)

set(TESTAPP TestFireboltCore)

Expand All @@ -52,13 +50,13 @@ target_link_libraries(${TESTAPP}
PRIVATE
${NAMESPACE}Core::${NAMESPACE}Core
${FIREBOLT_NAMESPACE}SDK::${FIREBOLT_NAMESPACE}SDK
nlohmann_json_schema_validator
gtest_main
)

target_include_directories(${TESTAPP}
PRIVATE
$<BUILD_INTERFACE:${FIREBOLT_PATH}/usr/include/${FIREBOLT_NAMESPACE}SDK>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SRC_DIR}/>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SRC_DIR}/../>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/>
)

if (POLYMORPHICS_REDUCER_METHODS)
Expand All @@ -79,3 +77,36 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${TESTAPP} ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin
)

if(ENABLE_UNIT_TESTS)
set(UNIT_TESTS_APP FireboltCoreUnitTests)

message("Setup ${UNIT_TESTS_APP}")

add_definitions(-DUNIT_TEST)

file(GLOB UNIT_TESTS "unit/*")

add_executable(${UNIT_TESTS_APP}
CoreSDKTest.cpp
Unit.cpp
${UNIT_TESTS}
)

link_directories(${CMAKE_SOURCE_DIR}/../../Thunder/install/usr/lib/)
target_link_libraries(${UNIT_TESTS_APP}
PRIVATE
${NAMESPACE}Core::${NAMESPACE}Core
${FIREBOLT_NAMESPACE}SDK::${FIREBOLT_NAMESPACE}SDK
nlohmann_json_schema_validator
gtest_main
)

target_include_directories(${UNIT_TESTS_APP}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/>
)

include(GoogleTest)
gtest_discover_tests(${UNIT_TESTS_APP})
endif()
9 changes: 9 additions & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/Unit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "gtest/gtest.h"
#include "CoreSDKTest.h"

int main(int argc, char** argv) {
std::string url = "ws://localhost:9998";
CoreSDKTest::CreateFireboltInstance(url);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
5 changes: 5 additions & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/unit/unit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "gtest/gtest.h"
#include "../CoreSDKTest.h"
#include "json_engine.h"

0 comments on commit 031a761

Please sign in to comment.