diff --git a/.github/workflows/gdbus_proxy_L1_test.yml b/.github/workflows/gdbus_proxy_L1_test.yml index 242ca6bd..fd1cb77d 100644 --- a/.github/workflows/gdbus_proxy_L1_test.yml +++ b/.github/workflows/gdbus_proxy_L1_test.yml @@ -55,58 +55,11 @@ jobs: uses: jwlawson/actions-setup-cmake@v1.13 with: cmake-version: '3.16.x' - - name: Checkout thunder repositories - if: steps.cache.outputs.cache-hit != 'true' - run: | - git clone https://github.com/rdkcentral/ThunderTools ThunderTools --branch ${{ env.THUNDER_REF }} - git clone https://github.com/rdkcentral/Thunder Thunder --branch ${{ env.THUNDER_REF }} - git clone https://github.com/rdkcentral/ThunderInterfaces ThunderInterfaces --branch ${{ env.THUNDER_REF }} - - name: Checkout networkmanager uses: actions/checkout@v3 with: path: networkmanager - - name: Apply Thunder Patches - if: steps.cache.outputs.cache-hit != 'true' - run: | - cd ${{github.workspace}}/Thunder - git apply ${{github.workspace}}/networkmanager/tests/patches/thunder/SubscribeStub.patch - - - name: Build ThunderTools - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/ThunderTools" -B build/ThunderTools - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - -DGENERIC_CMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - && - cmake --build build/ThunderTools --target install -j8 - - - name: Build Thunder - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/Thunder" -B build/Thunder - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - -DBUILD_TYPE=Debug - -DBINDING=127.0.0.1 - -DPORT=9998 - && - cmake --build build/Thunder --target install -j8 - - - name: ThunderInterfaces - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/ThunderInterfaces" -B build/ThunderInterfaces - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - && - cmake --build build/ThunderInterfaces --target install -j8 - - name: Build networkmanager with Gnome GDBUS Proxy run: > cmake @@ -114,7 +67,7 @@ jobs: -B build/networkmanager_gdbus -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + -DTHUNDER_VERSION="${{ env.THUNDER_REF }}" -DCMAKE_CXX_FLAGS=" -fprofile-arcs -ftest-coverage " -DENABLE_GNOME_NETWORKMANAGER=ON -DENABLE_GNOME_GDBUS=ON diff --git a/.github/workflows/legacy_L1_L2_test.yml b/.github/workflows/legacy_L1_L2_test.yml index b3645cce..2de0a2d4 100644 --- a/.github/workflows/legacy_L1_L2_test.yml +++ b/.github/workflows/legacy_L1_L2_test.yml @@ -58,60 +58,14 @@ jobs: uses: jwlawson/actions-setup-cmake@v1.13 with: cmake-version: '3.16.x' - - name: Checkout thunder repositories - if: steps.cache.outputs.cache-hit != 'true' - run: | - git clone https://github.com/rdkcentral/ThunderTools ThunderTools --branch ${{ env.THUNDER_REF }} - git clone https://github.com/rdkcentral/Thunder Thunder --branch ${{ env.THUNDER_REF }} - git clone https://github.com/rdkcentral/ThunderInterfaces ThunderInterfaces --branch ${{ env.THUNDER_REF }} - - name: Checkout networkmanager uses: actions/checkout@v3 with: path: networkmanager - - name: Apply Thunder Patches - if: steps.cache.outputs.cache-hit != 'true' - run: | - cd ${{github.workspace}}/Thunder - git apply ${{github.workspace}}/networkmanager/tests/patches/thunder/SubscribeStub.patch - - - name: Build ThunderTools - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/ThunderTools" -B build/ThunderTools - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - -DGENERIC_CMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - && - cmake --build build/ThunderTools --target install -j8 - - - name: Build Thunder - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/Thunder" -B build/Thunder - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - -DBUILD_TYPE=Debug - -DBINDING=127.0.0.1 - -DPORT=9998 - && - cmake --build build/Thunder --target install -j8 - - - name: ThunderInterfaces - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/ThunderInterfaces" -B build/ThunderInterfaces - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - && - cmake --build build/ThunderInterfaces --target install -j8 - - name: Generate IARM headers run: | + mkdir -p install/usr/lib touch install/usr/lib/libIARMBus.so mkdir -p install/usr/include/rdk/iarmbus touch install/usr/include/rdk/iarmbus/libIARM.h @@ -127,7 +81,7 @@ jobs: -B build/networkmanager_rdk -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + -DTHUNDER_VERSION="${{ env.THUNDER_REF }}" -DCMAKE_CXX_FLAGS=" -I ${{github.workspace}}/networkmanager/tests/headers -I ${{github.workspace}}/networkmanager/tests/headers/rdk/iarmbus diff --git a/.github/workflows/libnm_proxy_L1_test.yml b/.github/workflows/libnm_proxy_L1_test.yml index 80d945d5..4ee4ce98 100644 --- a/.github/workflows/libnm_proxy_L1_test.yml +++ b/.github/workflows/libnm_proxy_L1_test.yml @@ -55,58 +55,11 @@ jobs: uses: jwlawson/actions-setup-cmake@v1.13 with: cmake-version: '3.16.x' - - name: Checkout thunder repositories - if: steps.cache.outputs.cache-hit != 'true' - run: | - git clone https://github.com/rdkcentral/ThunderTools ThunderTools --branch ${{ env.THUNDER_REF }} - git clone https://github.com/rdkcentral/Thunder Thunder --branch ${{ env.THUNDER_REF }} - git clone https://github.com/rdkcentral/ThunderInterfaces ThunderInterfaces --branch ${{ env.THUNDER_REF }} - - name: Checkout networkmanager uses: actions/checkout@v3 with: path: networkmanager - - name: Apply Thunder Patches - if: steps.cache.outputs.cache-hit != 'true' - run: | - cd ${{github.workspace}}/Thunder - git apply ${{github.workspace}}/networkmanager/tests/patches/thunder/SubscribeStub.patch - - - name: Build ThunderTools - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/ThunderTools" -B build/ThunderTools - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - -DGENERIC_CMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - && - cmake --build build/ThunderTools --target install -j8 - - - name: Build Thunder - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/Thunder" -B build/Thunder - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - -DBUILD_TYPE=Debug - -DBINDING=127.0.0.1 - -DPORT=9998 - && - cmake --build build/Thunder --target install -j8 - - - name: ThunderInterfaces - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/ThunderInterfaces" -B build/ThunderInterfaces - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - && - cmake --build build/ThunderInterfaces --target install -j8 - - name: Generate dependency files run: | sudo bash -c 'echo "ETHERNET_INTERFACE=eth0 @@ -115,6 +68,7 @@ jobs: - name: Generate IARM headers run: | + mkdir -p install/usr/lib touch install/usr/lib/libIARMBus.so touch install/usr/lib/libmfrlib.so mkdir -p install/usr/include/rdk/iarmbus @@ -135,7 +89,7 @@ jobs: -B build/networkmanager_libnm -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + -DTHUNDER_VERSION="${{ env.THUNDER_REF }}" -DCMAKE_CXX_FLAGS=" -fprofile-arcs -ftest-coverage -I ${{github.workspace}}/networkmanager/tests/headers -I ${{github.workspace}}/networkmanager/tests/headers/rdk/iarmbus diff --git a/.github/workflows/rdk_proxy_L1_L2_test.yml b/.github/workflows/rdk_proxy_L1_L2_test.yml index 4fb464fe..e6743a6a 100644 --- a/.github/workflows/rdk_proxy_L1_L2_test.yml +++ b/.github/workflows/rdk_proxy_L1_L2_test.yml @@ -55,60 +55,15 @@ jobs: uses: jwlawson/actions-setup-cmake@v1.13 with: cmake-version: '3.16.x' - - name: Checkout thunder repositories - if: steps.cache.outputs.cache-hit != 'true' - run: | - git clone https://github.com/rdkcentral/ThunderTools ThunderTools --branch ${{ env.THUNDER_REF }} - git clone https://github.com/rdkcentral/Thunder Thunder --branch ${{ env.THUNDER_REF }} - git clone https://github.com/rdkcentral/ThunderInterfaces ThunderInterfaces --branch ${{ env.THUNDER_REF }} - name: Checkout networkmanager uses: actions/checkout@v3 with: path: networkmanager - - name: Apply Thunder Patches - if: steps.cache.outputs.cache-hit != 'true' - run: | - cd ${{github.workspace}}/Thunder - git apply ${{github.workspace}}/networkmanager/tests/patches/thunder/SubscribeStub.patch - - - name: Build ThunderTools - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/ThunderTools" -B build/ThunderTools - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - -DGENERIC_CMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - && - cmake --build build/ThunderTools --target install -j8 - - - name: Build Thunder - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/Thunder" -B build/Thunder - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - -DBUILD_TYPE=Debug - -DBINDING=127.0.0.1 - -DPORT=9998 - && - cmake --build build/Thunder --target install -j8 - - - name: ThunderInterfaces - if: steps.cache.outputs.cache-hit != 'true' - run: > - cmake - -S "${{github.workspace}}/ThunderInterfaces" -B build/ThunderInterfaces - -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" - && - cmake --build build/ThunderInterfaces --target install -j8 - - name: Generate IARM headers run: | + mkdir -p install/usr/lib touch install/usr/lib/libIARMBus.so mkdir -p install/usr/include/rdk/iarmbus touch install/usr/include/rdk/iarmbus/libIARM.h @@ -124,7 +79,7 @@ jobs: -B build/networkmanager_rdk -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" - -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + -DTHUNDER_VERSION="${{ env.THUNDER_REF }}" -DCMAKE_CXX_FLAGS=" -I ${{github.workspace}}/networkmanager/tests/headers -I ${{github.workspace}}/networkmanager/tests/headers/rdk/iarmbus diff --git a/CMakeLists.txt b/CMakeLists.txt index 50e77090..4d49f0e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,19 +20,31 @@ cmake_minimum_required(VERSION 3.3) project(NetworkManager) -# Try WPEFramework first -find_package(WPEFramework QUIET CONFIG) +# When THUNDER_VERSION is explicitly set, always use FetchContent +# (skip find_package — avoids conflicts with stale cached installs) +if(DEFINED THUNDER_VERSION) + message(STATUS "THUNDER_VERSION set — using FetchContent (${THUNDER_VERSION})") + add_subdirectory(tests/thunder) +else() + # Try WPEFramework first + find_package(WPEFramework QUIET CONFIG) -# If WPEFramework isn't found, try Thunder -if (NOT WPEFramework_FOUND) - find_package(Thunder QUIET CONFIG) -endif() + # If WPEFramework isn't found, try Thunder + if (NOT WPEFramework_FOUND) + find_package(Thunder QUIET CONFIG) + endif() -# Error out if neither is found -if (NOT WPEFramework_FOUND AND NOT Thunder_FOUND) - message(FATAL_ERROR - "Neither WPEFramework nor Thunder could be found.\n" - "Install one of them and ensure its CMake package is discoverable via CMAKE_PREFIX_PATH or default locations.") + if (NOT WPEFramework_FOUND AND NOT Thunder_FOUND) + if(ENABLE_UNIT_TESTING) + message(STATUS "Thunder not found via find_package — using FetchContent for test builds") + add_subdirectory(tests/thunder) + else() + message(FATAL_ERROR + "Neither WPEFramework nor Thunder could be found.\n" + "Install one of them and ensure its CMake package is discoverable via CMAKE_PREFIX_PATH or default locations.\n" + "Alternatively, pass -DTHUNDER_VERSION= to use FetchContent.") + endif() + endif() endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") @@ -73,6 +85,17 @@ endif (ENABLE_LEGACY_PLUGINS) add_subdirectory(tools) if(ENABLE_UNIT_TESTING) + # Fetch GoogleTest for all test targets + include(FetchContent) + set(GOOGLE_TEST_VERSION "v1.15.2" CACHE STRING "GoogleTest git tag/branch/commit to use") + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG ${GOOGLE_TEST_VERSION} + ) + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + FetchContent_MakeAvailable(googletest) + add_subdirectory(tests/l1Test) add_subdirectory(tests/l2Test) endif(ENABLE_UNIT_TESTING) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index c7c7bfeb..141ec782 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -18,9 +18,15 @@ ############################################################################# message("Generate ProxyStub for INetworkManager.h") -find_package(${NAMESPACE}Core REQUIRED) -find_package(${NAMESPACE}Plugins REQUIRED) -find_package(CompileSettingsDebug CONFIG REQUIRED) +if(NOT TARGET ${NAMESPACE}Core::${NAMESPACE}Core) + find_package(${NAMESPACE}Core REQUIRED) +endif() +if(NOT TARGET ${NAMESPACE}Plugins::${NAMESPACE}Plugins) + find_package(${NAMESPACE}Plugins REQUIRED) +endif() +if(NOT TARGET CompileSettingsDebug::CompileSettingsDebug) + find_package(CompileSettingsDebug CONFIG REQUIRED) +endif() find_package(ProxyStubGenerator REQUIRED) set(PROXYLIB ${NAMESPACE}${PROJECT_NAME}Proxy) diff --git a/legacy/CMakeLists.txt b/legacy/CMakeLists.txt index e3b11dd7..0b4e5485 100644 --- a/legacy/CMakeLists.txt +++ b/legacy/CMakeLists.txt @@ -18,8 +18,12 @@ ############################################################################# message("Build Legacy Plugins") -find_package(${NAMESPACE}Core REQUIRED) -find_package(${NAMESPACE}Plugins REQUIRED) +if(NOT TARGET ${NAMESPACE}Core::${NAMESPACE}Core) + find_package(${NAMESPACE}Core REQUIRED) +endif() +if(NOT TARGET ${NAMESPACE}Plugins::${NAMESPACE}Plugins) + find_package(${NAMESPACE}Plugins REQUIRED) +endif() set(PLUGIN_LEGACY_NETWORK ${NAMESPACE}Network) set(PLUGIN_LEGACY_WIFI ${NAMESPACE}WiFiManager) diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index 11904b9d..2d84d6c4 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -22,8 +22,12 @@ set(PLUGIN_NAME NetworkManager) set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) set(MODULE_IMPL_NAME ${NAMESPACE}${PLUGIN_NAME}Impl) -find_package(${NAMESPACE}Core REQUIRED) -find_package(${NAMESPACE}Plugins REQUIRED) +if(NOT TARGET ${NAMESPACE}Core::${NAMESPACE}Core) + find_package(${NAMESPACE}Core REQUIRED) +endif() +if(NOT TARGET ${NAMESPACE}Plugins::${NAMESPACE}Plugins) + find_package(${NAMESPACE}Plugins REQUIRED) +endif() find_package(CURL) if (USE_RDK_LOGGER) diff --git a/tests/l1Test/CMakeLists.txt b/tests/l1Test/CMakeLists.txt index dfae9937..689bba76 100644 --- a/tests/l1Test/CMakeLists.txt +++ b/tests/l1Test/CMakeLists.txt @@ -20,8 +20,13 @@ message ("building l1 test") find_package(CURL) find_package(PkgConfig REQUIRED) -find_package(${NAMESPACE}Core REQUIRED) -find_package(${NAMESPACE}Plugins REQUIRED) + +if(NOT TARGET ${NAMESPACE}Core::${NAMESPACE}Core) + find_package(${NAMESPACE}Core REQUIRED) +endif() +if(NOT TARGET ${NAMESPACE}Plugins::${NAMESPACE}Plugins) + find_package(${NAMESPACE}Plugins REQUIRED) +endif() include_directories(${PROJECT_SOURCE_DIR}/interface) include_directories(${PROJECT_SOURCE_DIR}/plugin/rdk) diff --git a/tests/l2Test/CMakeLists.txt b/tests/l2Test/CMakeLists.txt index 74c150bf..33d18717 100644 --- a/tests/l2Test/CMakeLists.txt +++ b/tests/l2Test/CMakeLists.txt @@ -21,16 +21,14 @@ message ("building Networkmanager plugin l2 tests") find_package(CURL) find_package(PkgConfig REQUIRED) -find_package(${NAMESPACE}Core REQUIRED) -find_package(${NAMESPACE}Plugins REQUIRED) -include(FetchContent) -FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip -) - -FetchContent_MakeAvailable(googletest) +# Thunder targets may already exist from FetchContent (test-only builds) +if(NOT TARGET ${NAMESPACE}Core::${NAMESPACE}Core) + find_package(${NAMESPACE}Core REQUIRED) +endif() +if(NOT TARGET ${NAMESPACE}Plugins::${NAMESPACE}Plugins) + find_package(${NAMESPACE}Plugins REQUIRED) +endif() if(ENABLE_LEGACY_PLUGINS) add_subdirectory(legacy) diff --git a/tests/l2Test/legacy/CMakeLists.txt b/tests/l2Test/legacy/CMakeLists.txt index 5106f18e..a674a068 100644 --- a/tests/l2Test/legacy/CMakeLists.txt +++ b/tests/l2Test/legacy/CMakeLists.txt @@ -22,19 +22,24 @@ set(NM_LEGACY_WIFI_UT "legacywifi_tests") set(NM_LEGACY_NETWORK_UT "legacynetwork_tests") find_package(PkgConfig REQUIRED) -find_package(${NAMESPACE}Core REQUIRED) -find_package(${NAMESPACE}Plugins REQUIRED) + +if(NOT TARGET ${NAMESPACE}Core::${NAMESPACE}Core) + find_package(${NAMESPACE}Core REQUIRED) +endif() +if(NOT TARGET ${NAMESPACE}Plugins::${NAMESPACE}Plugins) + find_package(${NAMESPACE}Plugins REQUIRED) +endif() add_executable(${NM_LEGACY_WIFI_UT} ${CMAKE_SOURCE_DIR}/tests/l2Test/legacy/l2_test_LegacyPlugin_WiFiManagerAPIs.cpp - ${CMAKE_SOURCE_DIR}/tests/mocks/thunder/Module.cpp + ${CMAKE_SOURCE_DIR}/plugin/Module.cpp ${CMAKE_SOURCE_DIR}/plugin/NetworkManagerLogger.cpp ${CMAKE_SOURCE_DIR}/legacy/LegacyWiFiManagerAPIs.cpp ) add_executable(${NM_LEGACY_NETWORK_UT} ${CMAKE_SOURCE_DIR}/tests/l2Test/legacy/l2_test_LegacyPlugin_NetworkAPIs.cpp - ${CMAKE_SOURCE_DIR}/tests/mocks/thunder/Module.cpp + ${CMAKE_SOURCE_DIR}/plugin/Module.cpp ${CMAKE_SOURCE_DIR}/plugin/NetworkManagerLogger.cpp ${CMAKE_SOURCE_DIR}/legacy/LegacyNetworkAPIs.cpp ) @@ -55,7 +60,6 @@ include_directories(${PROJECT_SOURCE_DIR}/interface) include_directories(${PROJECT_SOURCE_DIR}/plugin) include_directories(${PROJECT_SOURCE_DIR}/legacy) include_directories(${PROJECT_SOURCE_DIR}/tests/mocks) -include_directories(${PROJECT_SOURCE_DIR}/tests/mocks/thunder) target_include_directories(${NM_LEGACY_WIFI_UT} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/tests/l2Test/legacy/l2_test_LegacyPlugin_NetworkAPIs.cpp b/tests/l2Test/legacy/l2_test_LegacyPlugin_NetworkAPIs.cpp index d55de392..5b77ddbc 100644 --- a/tests/l2Test/legacy/l2_test_LegacyPlugin_NetworkAPIs.cpp +++ b/tests/l2Test/legacy/l2_test_LegacyPlugin_NetworkAPIs.cpp @@ -23,6 +23,7 @@ #include #include "ServiceMock.h" #include "FactoriesImplementation.h" +#include "WorkerPoolImplementation.h" #include "NetworkManagerLogger.h" #include "LegacyNetworkAPIs.h" #include "ThunderPortability.h" @@ -52,6 +53,8 @@ class NetworkTest : public ::testing::Test{ bool m_subsActIfaceChange; bool m_subsIPAddrChange; bool m_subsInternetChange; + Core::ProxyType workerPool; + NiceMock factoriesImplementation; NetworkTest() : plugin(Core::ProxyType::Create()) @@ -62,7 +65,11 @@ class NetworkTest : public ::testing::Test{ , m_subsActIfaceChange(true) , m_subsIPAddrChange(true) , m_subsInternetChange(true) + , workerPool(Core::ProxyType::Create(2, Core::Thread::DefaultStackSize(), 16)) { + PluginHost::IFactories::Assign(&factoriesImplementation); + Core::IWorkerPool::Assign(&(*workerPool)); + workerPool->Run(); ServiceMock* service = new ServiceMock(); WPEFramework::PluginHost::IAuthenticate* mock_security_agent = new MockIAuthenticate(); ServiceMock* mockShell = new ServiceMock(); @@ -98,6 +105,10 @@ class NetworkTest : public ::testing::Test{ plugin->Deinitialize(m_service); m_service->Release(); delete m_service; + + Core::IWorkerPool::Assign(nullptr); + workerPool.Release(); + PluginHost::IFactories::Assign(nullptr); } }; diff --git a/tests/l2Test/legacy/l2_test_LegacyPlugin_WiFiManagerAPIs.cpp b/tests/l2Test/legacy/l2_test_LegacyPlugin_WiFiManagerAPIs.cpp index ddb81495..ed2c4baf 100644 --- a/tests/l2Test/legacy/l2_test_LegacyPlugin_WiFiManagerAPIs.cpp +++ b/tests/l2Test/legacy/l2_test_LegacyPlugin_WiFiManagerAPIs.cpp @@ -22,6 +22,7 @@ #include #include "ServiceMock.h" #include "FactoriesImplementation.h" +#include "WorkerPoolImplementation.h" #include "NetworkManagerLogger.h" #include "LegacyWiFiManagerAPIs.h" #include "ThunderPortability.h" @@ -47,13 +48,19 @@ class WiFiManagerTest : public ::testing::Test { ServiceMock *m_service; Core::JSONRPC::Message message; string response; + Core::ProxyType workerPool; + NiceMock factoriesImplementation; WiFiManagerTest() : plugin(Core::ProxyType::Create()) , handler(*(plugin)) , handlerV2(*(plugin->GetHandler(2))) , INIT_CONX(1, 0) + , workerPool(Core::ProxyType::Create(2, Core::Thread::DefaultStackSize(), 16)) { + PluginHost::IFactories::Assign(&factoriesImplementation); + Core::IWorkerPool::Assign(&(*workerPool)); + workerPool->Run(); ServiceMock* service = new ServiceMock(); WPEFramework::PluginHost::IAuthenticate* mock_security_agent = new MockIAuthenticate(); ServiceMock* mockShell = new ServiceMock(); @@ -86,6 +93,10 @@ class WiFiManagerTest : public ::testing::Test { plugin->Deinitialize(m_service); m_service->Release(); delete m_service; + + Core::IWorkerPool::Assign(nullptr); + workerPool.Release(); + PluginHost::IFactories::Assign(nullptr); } }; diff --git a/tests/l2Test/libnm/CMakeLists.txt b/tests/l2Test/libnm/CMakeLists.txt index 35a7e4e4..d59e2cf1 100644 --- a/tests/l2Test/libnm/CMakeLists.txt +++ b/tests/l2Test/libnm/CMakeLists.txt @@ -8,26 +8,24 @@ set(NM_LIBNM_PROXY_L2_TEST "libnm_proxy_l2_test") find_package(CURL) find_package(PkgConfig REQUIRED) -find_package(${NAMESPACE}Core REQUIRED) -find_package(${NAMESPACE}Plugins REQUIRED) + +if(NOT TARGET ${NAMESPACE}Core::${NAMESPACE}Core) + find_package(${NAMESPACE}Core REQUIRED) +endif() +if(NOT TARGET ${NAMESPACE}Plugins::${NAMESPACE}Plugins) + find_package(${NAMESPACE}Plugins REQUIRED) +endif() pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(LIBNM REQUIRED libnm) pkg_check_modules(GIO REQUIRED gio-2.0) -include(FetchContent) -FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip -) -FetchContent_MakeAvailable(googletest) - message("networkmanager building with libnm") add_executable(${NM_LIBNM_PROXY_L2_TEST} ${CMAKE_SOURCE_DIR}/tests/l2Test/libnm/l2_test_libnmproxyEvent.cpp ${CMAKE_SOURCE_DIR}/tests/l2Test/libnm/l2_test_libnmproxyWifi.cpp ${CMAKE_SOURCE_DIR}/tests/l2Test/libnm/l2_test_libnmproxyInit.cpp ${CMAKE_SOURCE_DIR}/tests/l2Test/libnm/l2_test_libnmproxy.cpp - ${CMAKE_SOURCE_DIR}/tests/mocks/thunder/Module.cpp + ${CMAKE_SOURCE_DIR}/plugin/Module.cpp ${CMAKE_SOURCE_DIR}/tests/mocks/Iarm.cpp ${CMAKE_SOURCE_DIR}/tests/mocks/Wraps.cpp ${CMAKE_SOURCE_DIR}/tests/mocks/LibnmWraps.cpp @@ -63,7 +61,6 @@ include_directories(${PROJECT_SOURCE_DIR}/plugin) include_directories(${PROJECT_SOURCE_DIR}/plugin/gnome) include_directories(${PROJECT_SOURCE_DIR}/legacy) include_directories(${PROJECT_SOURCE_DIR}/tests/mocks) -include_directories(${PROJECT_SOURCE_DIR}/tests/mocks/thunder) target_include_directories(${NM_LIBNM_PROXY_L2_TEST} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/tests/l2Test/rdk/CMakeLists.txt b/tests/l2Test/rdk/CMakeLists.txt index ed5d4fab..a71eb116 100644 --- a/tests/l2Test/rdk/CMakeLists.txt +++ b/tests/l2Test/rdk/CMakeLists.txt @@ -21,14 +21,19 @@ set(NM_RDK_PROXY_L2_TEST "rdkproxy_l2_test") find_package(CURL) find_package(PkgConfig REQUIRED) -find_package(${NAMESPACE}Core REQUIRED) -find_package(${NAMESPACE}Plugins REQUIRED) + +if(NOT TARGET ${NAMESPACE}Core::${NAMESPACE}Core) + find_package(${NAMESPACE}Core REQUIRED) +endif() +if(NOT TARGET ${NAMESPACE}Plugins::${NAMESPACE}Plugins) + find_package(${NAMESPACE}Plugins REQUIRED) +endif() add_executable(${NM_RDK_PROXY_L2_TEST} ${CMAKE_SOURCE_DIR}/tests/l2Test/rdk/l2_test_rdkproxy.cpp ${CMAKE_SOURCE_DIR}/tests/l2Test/rdk/l2_test_rdkproxyEvent.cpp ${CMAKE_SOURCE_DIR}/tests/l2Test/rdk/l2_test_rdkproxyImpl.cpp - ${CMAKE_SOURCE_DIR}/tests/mocks/thunder/Module.cpp + ${CMAKE_SOURCE_DIR}/plugin/Module.cpp ${CMAKE_SOURCE_DIR}/tests/mocks/Iarm.cpp ${CMAKE_SOURCE_DIR}/tests/mocks/Wraps.cpp ${CMAKE_SOURCE_DIR}/tests/mocks/CurlWraps.cpp @@ -54,7 +59,6 @@ include_directories(${PROJECT_SOURCE_DIR}/plugin/rdk) include_directories(${PROJECT_SOURCE_DIR}/plugin) include_directories(${PROJECT_SOURCE_DIR}/legacy) include_directories(${PROJECT_SOURCE_DIR}/tests/mocks) -include_directories(${PROJECT_SOURCE_DIR}/tests/mocks/thunder) include_directories(${PROJECT_SOURCE_DIR}/../install/usr/include/rdk/iarmbus/) include_directories(${PROJECT_SOURCE_DIR}/tools/upnp/) diff --git a/tests/mocks/thunder/COMLinkMock.h b/tests/mocks/COMLinkMock.h similarity index 100% rename from tests/mocks/thunder/COMLinkMock.h rename to tests/mocks/COMLinkMock.h diff --git a/tests/mocks/thunder/FactoriesImplementation.h b/tests/mocks/FactoriesImplementation.h similarity index 100% rename from tests/mocks/thunder/FactoriesImplementation.h rename to tests/mocks/FactoriesImplementation.h diff --git a/tests/mocks/thunder/IStringIteratorMock.h b/tests/mocks/IStringIteratorMock.h similarity index 100% rename from tests/mocks/thunder/IStringIteratorMock.h rename to tests/mocks/IStringIteratorMock.h diff --git a/tests/mocks/thunder/InterfaceIteratorMock.h b/tests/mocks/InterfaceIteratorMock.h similarity index 100% rename from tests/mocks/thunder/InterfaceIteratorMock.h rename to tests/mocks/InterfaceIteratorMock.h diff --git a/tests/mocks/thunder/ServiceMock.h b/tests/mocks/ServiceMock.h similarity index 100% rename from tests/mocks/thunder/ServiceMock.h rename to tests/mocks/ServiceMock.h diff --git a/tests/mocks/thunder/ThunderPortability.h b/tests/mocks/ThunderPortability.h old mode 100755 new mode 100644 similarity index 100% rename from tests/mocks/thunder/ThunderPortability.h rename to tests/mocks/ThunderPortability.h diff --git a/tests/mocks/thunder/WorkerPoolImplementation.h b/tests/mocks/WorkerPoolImplementation.h similarity index 100% rename from tests/mocks/thunder/WorkerPoolImplementation.h rename to tests/mocks/WorkerPoolImplementation.h diff --git a/tests/mocks/thunder/mockauthservices.h b/tests/mocks/mockauthservices.h similarity index 100% rename from tests/mocks/thunder/mockauthservices.h rename to tests/mocks/mockauthservices.h diff --git a/tests/mocks/thunder/Communicator.cpp b/tests/mocks/thunder/Communicator.cpp deleted file mode 100755 index 2bb1bceb..00000000 --- a/tests/mocks/thunder/Communicator.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2025 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "Communicator.h" -#include - -ICommunicatorClient* WPEFramework::RPC::CommunicatorClient::impl = nullptr; - -void WPEFramework::RPC::CommunicatorClient::setImpl(ICommunicatorClient* newImpl) -{ - // Handles both resetting 'impl' to nullptr and assigning a new value to 'impl' - EXPECT_TRUE ((nullptr == impl) || (nullptr == newImpl)); - impl = newImpl; -} diff --git a/tests/mocks/thunder/Communicator.h b/tests/mocks/thunder/Communicator.h deleted file mode 100755 index 5d0524b8..00000000 --- a/tests/mocks/thunder/Communicator.h +++ /dev/null @@ -1,286 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2025 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef __COM_PROCESSLAUNCH_H -#define __COM_PROCESSLAUNCH_H - -#include -#include "Proxy.h" -#include "NodeId.h" -#include "IPCConnector.h" - -using std::string; -const uint32_t CommunicationTimeOut = 3000; - -class ICommunicatorClient { -public: - virtual ~ICommunicatorClient() = default; - virtual uint32_t Open(const uint32_t waitTime) = 0; - virtual void* Open(const std::string& className, const uint32_t version, const uint32_t waitTime) = 0; - virtual void* Acquire(const uint32_t waitTime, const std::string& className, const uint32_t versionId) = 0; - virtual uint32_t Offer(void* offer, const uint32_t version, const uint32_t waitTime) = 0; - virtual uint32_t Revoke(void* offer, const uint32_t version, const uint32_t waitTime) = 0; - virtual uint32_t Close(const uint32_t waitTime) = 0; - virtual void* Acquire(const std::string& className, const uint32_t interfaceId, const uint32_t versionId) = 0; -}; - -namespace WPEFramework { -namespace RPC { - class Object { - public: - enum class HostType { - LOCAL, - DISTRIBUTED, - CONTAINER - }; - - Object() - : _locator() - , _className() - , _callsign() - , _interface(~0) - , _version(~0) - , _user() - , _group() - , _threads() - , _priority() - , _type(HostType::LOCAL) - , _systemRootPath() - , _remoteAddress() - , _configuration() - { - } - Object(const Object& copy) - : _locator(copy._locator) - , _className(copy._className) - , _callsign(copy._callsign) - , _interface(copy._interface) - , _version(copy._version) - , _user(copy._user) - , _group(copy._group) - , _threads(copy._threads) - , _priority(copy._priority) - , _type(copy._type) - , _systemRootPath(copy._systemRootPath) - , _remoteAddress(copy._remoteAddress) - , _configuration(copy._configuration) - { - } - Object(const string& locator, - const string& className, - const string& callsign, - const uint32_t interface, - const uint32_t version, - const string& user, - const string& group, - const uint8_t threads, - const int8_t priority, - const HostType type, - const string& systemRootPath, - const string& remoteAddress, - const string& configuration) - : _locator(locator) - , _className(className) - , _callsign(callsign) - , _interface(interface) - , _version(version) - , _user(user) - , _group(group) - , _threads(threads) - , _priority(priority) - , _type(type) - , _systemRootPath(systemRootPath) - , _remoteAddress(remoteAddress) - , _configuration(configuration) - { - } - ~Object() - { - } - - Object& operator=(const Object& RHS) - { - _locator = RHS._locator; - _className = RHS._className; - _callsign = RHS._callsign; - _interface = RHS._interface; - _version = RHS._version; - _user = RHS._user; - _group = RHS._group; - _threads = RHS._threads; - _priority = RHS._priority; - _systemRootPath = RHS._systemRootPath; - _type = RHS._type; - _remoteAddress = RHS._remoteAddress; - _configuration = RHS._configuration; - - return (*this); - } - - public: - inline const string& Locator() const - { - return (_locator); - } - inline const string& ClassName() const - { - return (_className); - } - inline const string& Callsign() const - { - return (_callsign); - } - inline uint32_t Interface() const - { - return (_interface); - } - inline uint32_t Version() const - { - return (_version); - } - inline const string& User() const - { - return (_user); - } - inline const string& Group() const - { - return (_group); - } - inline uint8_t Threads() const - { - return (_threads); - } - inline int8_t Priority() const - { - return (_priority); - } - inline HostType Type() const - { - return (_type); - } - inline const string& SystemRootPath() const - { - return (_systemRootPath); - } - inline const Core::NodeId RemoteAddress() const - { - return (Core::NodeId(_remoteAddress.c_str())); - } - inline const string& Configuration() const - { - return (_configuration); - } - - private: - string _locator; - string _className; - string _callsign; - uint32_t _interface; - uint32_t _version; - string _user; - string _group; - uint8_t _threads; - int8_t _priority; - HostType _type; - string _systemRootPath; - string _remoteAddress; - string _configuration; - }; - - class CommunicatorClient{ - protected: - static ICommunicatorClient* impl; - - public: - class Source { - bool IsOpen() const - { - return true; - } - }; - CommunicatorClient() = delete; - CommunicatorClient(CommunicatorClient&&) = delete; - CommunicatorClient(const CommunicatorClient&) = delete; - CommunicatorClient& operator=(CommunicatorClient&&) = delete; - CommunicatorClient& operator=(const CommunicatorClient&) = delete; - - static void setImpl(ICommunicatorClient* newImpl); - - CommunicatorClient(const Core::NodeId& remoteNode) { - //Mock CommunicatorClient constructor. - } - - CommunicatorClient(const Core::NodeId& remoteNode, const Core::ProxyType& handler) { - //Mock CommunicatorClient constructor. - } - - ~CommunicatorClient() { - } - - public: - inline uint32_t ConnectionId() const { - return _connectionId; - } - - // Open a communication channel with this process, no need for an initial exchange - uint32_t Open(const uint32_t waitTime) - { - return impl->Open(waitTime); - } - template - INTERFACE* Open(const std::string& className, const uint32_t version = static_cast(~0), const uint32_t waitTime = CommunicationTimeOut) - { - return static_cast(impl->Open(className, version, waitTime)); - } - template - INTERFACE* Acquire(const uint32_t waitTime, const std::string& className, const uint32_t versionId) - { - return static_cast(impl->Acquire(waitTime, className, versionId)); - } - template - uint32_t Offer(INTERFACE* offer, const uint32_t version = static_cast(~0), const uint32_t waitTime = CommunicationTimeOut) - { - return static_cast(impl->Offer(static_cast(offer), version, CommunicationTimeOut)); - } - template - uint32_t Revoke(INTERFACE* offer, const uint32_t version = static_cast(~0), const uint32_t waitTime = CommunicationTimeOut) - { - return static_cast(impl->Revoke(static_cast(offer), version, CommunicationTimeOut)); - } - uint32_t Close(const uint32_t waitTime) - { - if (impl) - return impl->Close(waitTime); - return Core::ERROR_GENERAL; - } - virtual void* Acquire(const std::string& className, const uint32_t interfaceId, const uint32_t versionId) - { - return impl->Acquire(className, interfaceId, versionId); - } - protected: - void StateChange() { - //Mock CommunicatorClient StateChange is calling. - } - private: - uint32_t _connectionId; - }; -} -} -#endif // __COM_PROCESSLAUNCH_H - diff --git a/tests/mocks/thunder/CommunicatorMock.h b/tests/mocks/thunder/CommunicatorMock.h deleted file mode 100755 index b689de20..00000000 --- a/tests/mocks/thunder/CommunicatorMock.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -* If not stated otherwise in this file or this component's LICENSE file the -* following copyright and licenses apply: -* -* Copyright 2025 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#pragma once - -#include -#include "Communicator.h" - -#if 0 -class CommunicatorClientMock : public ICommunicatorClient -{ -public: - virtual ~CommunicatorClientMock() = default; - - MOCK_METHOD(uint32_t, Open, (const uint32_t waitTime), (override)); - MOCK_METHOD(INTERFACE*, Open, (const std::string& className, const uint32_t version, const uint32_t waitTime), (override)); - MOCK_METHOD(INTERFACE*, Acquire, (const uint32_t waitTime, const std::string& className, const uint32_t versionId), (override)); - MOCK_METHOD(uint32_t, Offer, (INTERFACE* offer, const uint32_t version, const uint32_t waitTime), (override)); - MOCK_METHOD(uint32_t, Revoke, (INTERFACE* offer, const uint32_t version, const uint32_t waitTime), (override)); - MOCK_METHOD(uint32_t, Close, (const uint32_t waitTime), (override)); -}; -#else -class CommunicatorClientMock : public ICommunicatorClient { -public: - virtual ~CommunicatorClientMock() = default; - MOCK_METHOD(uint32_t, AddRef, (), (const)); - MOCK_METHOD(uint32_t, Release, (), (const)); - MOCK_METHOD(uint32_t, Open, (const uint32_t waitTime), (override)); - MOCK_METHOD(void*, Open, (const std::string& className, const uint32_t version, const uint32_t waitTime), (override)); - MOCK_METHOD(void*, Acquire, (const uint32_t waitTime, const std::string& className, const uint32_t versionId), (override)); - MOCK_METHOD(uint32_t, Offer, (void* offer, const uint32_t version, const uint32_t waitTime), (override)); - MOCK_METHOD(uint32_t, Revoke, (void* offer, const uint32_t version, const uint32_t waitTime), (override)); - MOCK_METHOD(uint32_t, Close, (const uint32_t waitTime), (override)); - MOCK_METHOD(void*, Acquire, (const std::string& className, const uint32_t interfaceId, const uint32_t versionId), (override)); -}; - -#endif diff --git a/tests/mocks/thunder/DispatcherMock.h b/tests/mocks/thunder/DispatcherMock.h deleted file mode 100644 index 6ae2b7f5..00000000 --- a/tests/mocks/thunder/DispatcherMock.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * If not stated otherwise in this file or this component's LICENSE file the - * following copyright and licenses apply: - * - * Copyright 2023 RDK Management - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISPATCHERMOCK_H -#define DISPATCHERMOCK_H - -#include - -#include "Module.h" - - class DispatcherMock: public WPEFramework::PluginHost::ILocalDispatcher{ - public: - virtual ~DispatcherMock() = default; - MOCK_METHOD(uint32_t, AddRef, (), (const, override)); - MOCK_METHOD(uint32_t, Release, (), (const, override)); - MOCK_METHOD(void*, QueryInterface, (const uint32_t interfaceNummer), (override)); - MOCK_METHOD(void, Activate, (WPEFramework::PluginHost::IShell* service)); - MOCK_METHOD(void, Deactivate, ()); - MOCK_METHOD(void, Dropped, (const uint32_t)); - MOCK_METHOD(uint32_t, Invoke, (const uint32_t channelId, const uint32_t id, const string& token, const string& method, const string& parameters, string& response), (override)); - MOCK_METHOD(WPEFramework::Core::hresult, Invoke, (WPEFramework::PluginHost::IDispatcher::ICallback* callback, const uint32_t channelId, const uint32_t id, const string& token, const string& method, const string& parameters /* @restrict:(4M-1) */, string& response /* @restrict:(4M-1) @out */), (override)); - MOCK_METHOD(WPEFramework::Core::hresult, Revoke, (WPEFramework::PluginHost::IDispatcher::ICallback* callback), (override)); - MOCK_METHOD(WPEFramework::Core::hresult, Validate, (const string& token, const string& method, const string& paramaters /* @restrict:(4M-1) */), (const, override)); - MOCK_METHOD(WPEFramework::PluginHost::ILocalDispatcher*, Local, (), (override)); -}; - -#endif //DISPATCHERMOCK_H diff --git a/tests/mocks/thunder/Module.cpp b/tests/mocks/thunder/Module.cpp deleted file mode 100644 index cd6d4d14..00000000 --- a/tests/mocks/thunder/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/tests/mocks/thunder/Module.h b/tests/mocks/thunder/Module.h deleted file mode 100644 index e113be84..00000000 --- a/tests/mocks/thunder/Module.h +++ /dev/null @@ -1,27 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once - -#ifndef MODULE_NAME -#define MODULE_NAME networkmanager_tests -#endif - -#include -#include diff --git a/tests/mocks/thunder/SystemInfo.h b/tests/mocks/thunder/SystemInfo.h deleted file mode 100644 index c2026627..00000000 --- a/tests/mocks/thunder/SystemInfo.h +++ /dev/null @@ -1,83 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once - -#include - -#include "Module.h" - -class SystemInfo : public WPEFramework::PluginHost::ISubSystem { -private: - SystemInfo(const SystemInfo&) = delete; - SystemInfo& operator=(const SystemInfo&) = delete; - -public: - SystemInfo() - : _flags(0) - { - // Defaults: - ON_CALL(*this, Set(::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const subsystem type, WPEFramework::Core::IUnknown* information) { - _subsystems.emplace(type, information); - - if (type >= NEGATIVE_START) { - _flags &= ~(1 << (type - NEGATIVE_START)); - } else { - _flags |= (1 << type); - } - })); - ON_CALL(*this, Get(::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const subsystem type) -> const WPEFramework::Core::IUnknown* { - const WPEFramework::Core::IUnknown* result(nullptr); - - auto it = _subsystems.find(type); - if (it != _subsystems.end()) { - result = it->second; - } - - return result; - })); - ON_CALL(*this, IsActive(::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const subsystem type) -> bool { - return ((type < END_LIST) && ((_flags & (1 << type)) != 0)); - })); - } - virtual ~SystemInfo() = default; - -public: - MOCK_METHOD(void, Register, (WPEFramework::PluginHost::ISubSystem::INotification * notification), (override)); - MOCK_METHOD(void, Unregister, (WPEFramework::PluginHost::ISubSystem::INotification * notification), (override)); - MOCK_METHOD(string, BuildTreeHash, (), (const, override)); - MOCK_METHOD(void, Set, (const subsystem type, WPEFramework::Core::IUnknown* information), (override)); - MOCK_METHOD(const WPEFramework::Core::IUnknown*, Get, (const subsystem type), (const, override)); - MOCK_METHOD(bool, IsActive, (const subsystem type), (const, override)); - MOCK_METHOD(string, Version, (), (const, override)); - - BEGIN_INTERFACE_MAP(SystemInfo) - INTERFACE_ENTRY(WPEFramework::PluginHost::ISubSystem) - END_INTERFACE_MAP - -private: - std::map _subsystems; - uint32_t _flags; -}; diff --git a/tests/patches/thunder/SubscribeStub.patch b/tests/patches/thunder/SubscribeStub.patch deleted file mode 100644 index 91d16a77..00000000 --- a/tests/patches/thunder/SubscribeStub.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/Source/websocket/JSONRPCLink.h b/Source/websocket/JSONRPCLink.h ---- a/Source/websocket/JSONRPCLink.h 2025-07-21 11:11:43.178011151 -0400 -+++ b/Source/websocket/JSONRPCLink.h 2025-07-21 11:13:11.330611722 -0400 -@@ -1238,12 +1238,15 @@ namespace WPEFramework { - template - uint32_t Subscribe(const uint32_t waitTime, const string& eventName, const METHOD& method) - { -- return Subscribe(waitTime, eventName, method); -+ const string parameters("{ \"event\": \"" + eventName + "\"}"); -+ if (eventName.empty() == false) -+ method(parameters); -+ return 0; - } - template - uint32_t Subscribe(const uint32_t waitTime, const string& eventName, const METHOD& method, REALOBJECT* objectPtr) - { -- return Subscribe(waitTime, eventName, method, objectPtr); -+ return 0; - } - bool IsActivated() - { diff --git a/tests/thunder/CMakeLists.txt b/tests/thunder/CMakeLists.txt new file mode 100644 index 00000000..c86c5c5c --- /dev/null +++ b/tests/thunder/CMakeLists.txt @@ -0,0 +1,93 @@ +# ============================================================================ +# FetchContent setup +# ============================================================================ + +set(THUNDER_VERSION "R5.1" CACHE STRING "Thunder git tag/branch/commit to use") + +include(FetchContent) + +# ============================================================================ +# 1. ThunderTools (source only — needed BEFORE Thunder for generators + cmake) +# ============================================================================ + +FetchContent_Declare(ThunderTools + GIT_REPOSITORY https://github.com/rdkcentral/ThunderTools.git + GIT_TAG ${THUNDER_VERSION} +) +FetchContent_Populate(ThunderTools) + +# Point the generators at the fetched source tree +set(PROXYSTUB_GENERATOR "${thundertools_SOURCE_DIR}/ProxyStubGenerator/StubGenerator.py" CACHE STRING "" FORCE) +set(JSON_GENERATOR "${thundertools_SOURCE_DIR}/JsonGenerator/JsonGenerator.py" CACHE STRING "" FORCE) + +# R4.4.3 templates use @GENERATOR_INSTALL_PATH@ with unconditional set(), so this +# MUST be set before configure_file for the paths to resolve correctly. +set(GENERATOR_INSTALL_PATH "${thundertools_SOURCE_DIR}") + +# The .cmake.in templates use @ONLY substitution for these options (default OFF) +set(PROXYSTUB_GENERATOR_ENABLE_SECURITY OFF) +set(PROXYSTUB_GENERATOR_ENABLE_COHERENCY OFF) +set(JSON_GENERATOR_ENABLE_STATS OFF) + +# Generate the Find*.cmake modules from templates so find_package() works +configure_file("${thundertools_SOURCE_DIR}/cmake/FindProxyStubGenerator.cmake.in" + "${thundertools_BINARY_DIR}/FindProxyStubGenerator.cmake" @ONLY) +configure_file("${thundertools_SOURCE_DIR}/cmake/FindJsonGenerator.cmake.in" + "${thundertools_BINARY_DIR}/FindJsonGenerator.cmake" @ONLY) +configure_file("${thundertools_SOURCE_DIR}/cmake/FindConfigGenerator.cmake.in" + "${thundertools_BINARY_DIR}/FindConfigGenerator.cmake" @ONLY) + +# ============================================================================ +# 2. Thunder (built as static libraries for unit testing) +# ============================================================================ + +FetchContent_Declare(Thunder + GIT_REPOSITORY https://github.com/rdkcentral/Thunder.git + GIT_TAG ${THUNDER_VERSION} +) + +# Thunder as static libs — no executables, no daemons +set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) + +# Build only the components needed for plugin testing +set(CORE ON CACHE BOOL "" FORCE) +set(COM ON CACHE BOOL "" FORCE) +set(MESSAGING ON CACHE BOOL "" FORCE) +set(PLUGINS ON CACHE BOOL "" FORCE) +set(WEBSOCKET ON CACHE BOOL "" FORCE) +set(CRYPTALGO ON CACHE BOOL "" FORCE) + +# Disable components not needed for testing +set(EXECUTABLE OFF CACHE BOOL "" FORCE) +set(PROCESS OFF CACHE BOOL "" FORCE) +set(SECURE_SOCKET OFF CACHE BOOL "" FORCE) + +# Populate Thunder source WITHOUT building — we need to set CMAKE_MODULE_PATH +# first so that Thunder's CMakeLists.txt can find platform, CmakeHelperFunctions, +# and ProxyStubGenerator when it runs. +FetchContent_Populate(Thunder) + +# R4.x uses CMAKE_SOURCE_DIR which breaks when Thunder is built as a subdirectory +# (it points to networkmanager's root instead of Thunder's source). Patch it in-place +# to use CMAKE_CURRENT_SOURCE_DIR, matching the fix applied upstream in R5.0.0+. +file(READ "${thunder_SOURCE_DIR}/CMakeLists.txt" _thunder_cmakelists) +string(REPLACE "CMAKE_SOURCE_DIR}" "CMAKE_CURRENT_SOURCE_DIR}" _thunder_cmakelists "${_thunder_cmakelists}") +file(WRITE "${thunder_SOURCE_DIR}/CMakeLists.txt" "${_thunder_cmakelists}") + +set(CMAKE_MODULE_PATH + "${thundertools_BINARY_DIR}" + "${thunder_SOURCE_DIR}/cmake" + "${thunder_SOURCE_DIR}/cmake/common" + "${thunder_SOURCE_DIR}/cmake/modules" + ${CMAKE_MODULE_PATH} + CACHE PATH "" FORCE +) + +# Now build Thunder (its CMakeLists.txt will find everything it needs) +add_subdirectory(${thunder_SOURCE_DIR} ${thunder_BINARY_DIR}) + +# ProxyStubGenerator needs to resolve Thunder headers (e.g. com/IIteratorType.h) +# when processing INetworkManager.h. Point it at Thunder's Source directory. +set(GENERATOR_SEARCH_PATH "${thunder_SOURCE_DIR}/Source" CACHE PATH "" FORCE) + +# GoogleTest is fetched in the root CMakeLists.txt when ENABLE_UNIT_TESTING is ON \ No newline at end of file diff --git a/tools/plugincli/CMakeLists.txt b/tools/plugincli/CMakeLists.txt index 56883676..d68be4ae 100644 --- a/tools/plugincli/CMakeLists.txt +++ b/tools/plugincli/CMakeLists.txt @@ -20,7 +20,9 @@ message("Building plugin CLI tools") # Required packages find_package(PkgConfig REQUIRED) -find_package(${NAMESPACE}Core REQUIRED) +if(NOT TARGET ${NAMESPACE}Core::${NAMESPACE}Core) + find_package(${NAMESPACE}Core REQUIRED) +endif() pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(GIO REQUIRED gio-2.0)