Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e9fbfad
WIP: test support library
smanes0213 Apr 16, 2026
5f0f65c
Resolve compilation issues
smanes0213 Apr 17, 2026
e03f7a2
Add Test plugin test to workflow
smanes0213 Apr 20, 2026
68f35e9
Update Test_Thunder_Test_Support.yml
smanes0213 Apr 20, 2026
deeda11
Update Test_Thunder_Test_Support.yml
smanes0213 Apr 20, 2026
9be539e
Update Test_Thunder_Test_Support.yml
smanes0213 Apr 20, 2026
689d4c8
Update Test_Thunder_Test_Support.yml
smanes0213 Apr 20, 2026
8912b88
Update Test_Thunder_Test_Support.yml
smanes0213 Apr 20, 2026
30bab10
Update Test_Thunder_Test_Support.yml
smanes0213 Apr 20, 2026
4c7ce48
Update TestPluginTest.cpp
smanes0213 Apr 20, 2026
8468c7d
Resolve header include error
smanes0213 Apr 20, 2026
3f4d329
Resolve workflow issue
smanes0213 Apr 20, 2026
df16a47
Resolve workflow issue
smanes0213 Apr 20, 2026
57f7007
Update Test_Thunder_Test_Support.yml
smanes0213 Apr 20, 2026
f801490
Move out TestPlugin Test file
smanes0213 Apr 21, 2026
bfcdfce
Resolve workflow failures
smanes0213 Apr 21, 2026
ed48229
Resolve workflow failures
smanes0213 Apr 21, 2026
5f0e7b6
Resolve workflow failures
smanes0213 Apr 21, 2026
b45292e
Add conditional gaurd to initialize and deinitialize
smanes0213 Apr 21, 2026
5689025
Update ThunderTestRuntime.cpp
smanes0213 Apr 21, 2026
8e977ab
Add debug comments
smanes0213 Apr 21, 2026
4770e55
Add thunder_test_main static library providing a GTest main() that
smanes0213 Apr 21, 2026
6b4fa47
Resolve workflow errors
smanes0213 May 11, 2026
1fd89ec
Update ThunderTestRuntime.cpp
smanes0213 May 11, 2026
89caa5a
Fix segfault during test shutdown by installing signal handler before…
smanes0213 May 11, 2026
adfb594
Resolve Copilot review comments.
smanes0213 May 11, 2026
9d5f035
docs: add ThunderTestSupport library documentation
smanes0213 May 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 185 additions & 0 deletions .github/workflows/Test_Thunder_Test_Support.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: Test Thunder Test Support Library

permissions:
contents: read

on:
workflow_dispatch:

pull_request:
branches: ["R5_3", "development/test-support"]

jobs:
SmokeTest:
runs-on: ubuntu-24.04

strategy:
matrix:
build_type: [Debug, Release]

name: Smoke Test - ${{matrix.build_type}}

steps:
- name: Install necessary packages
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 10
command: |
sudo gem install apt-spy2
sudo apt-spy2 fix --commit --launchpad --country=US
sudo apt-get update
sudo apt-get install -y python3-pip build-essential cmake ninja-build libusb-1.0-0-dev zlib1g-dev libssl-dev libgtest-dev
python3 -m venv venv
source venv/bin/activate
pip install jsonref

# ----- Checkout -----
- name: Checkout Thunder
uses: actions/checkout@v4
with:
path: Thunder
# ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Checkout ThunderTools - default
if: ${{ !contains(github.event.pull_request.body, '[DependsOn=ThunderTools:') }}
uses: actions/checkout@v4
with:
path: ThunderTools
repository: rdkcentral/ThunderTools
ref: R5.3.0

- name: Regex ThunderTools
if: ${{ contains(github.event.pull_request.body, '[DependsOn=ThunderTools:') }}
id: tools
uses: AsasInnab/regex-action@v1
with:
regex_pattern: '(?<=\[DependsOn=ThunderTools:).*(?=\])'
regex_flags: 'gim'
search_string: ${{github.event.pull_request.body}}

- name: Checkout ThunderTools - ${{steps.tools.outputs.first_match}}
if: ${{ contains(github.event.pull_request.body, '[DependsOn=ThunderTools:') }}
uses: actions/checkout@v4
with:
path: ThunderTools
repository: rdkcentral/ThunderTools
ref: ${{steps.tools.outputs.first_match}}

- name: Checkout ThunderInterfaces - default
if: ${{ !contains(github.event.pull_request.body, '[DependsOn=ThunderInterfaces:') }}
uses: actions/checkout@v4
with:
path: ThunderInterfaces
repository: rdkcentral/ThunderInterfaces
# TODO: Remove ref once qa_interfaces changes are merged to master
ref: development/test-support

- name: Regex ThunderInterfaces
if: ${{ contains(github.event.pull_request.body, '[DependsOn=ThunderInterfaces:') }}
id: interfaces
uses: AsasInnab/regex-action@v1
with:
regex_pattern: '(?<=\[DependsOn=ThunderInterfaces:).*(?=\])'
regex_flags: 'gim'
search_string: ${{github.event.pull_request.body}}

- name: Checkout ThunderInterfaces - ${{steps.interfaces.outputs.first_match}}
if: ${{ contains(github.event.pull_request.body, '[DependsOn=ThunderInterfaces:') }}
uses: actions/checkout@v4
with:
path: ThunderInterfaces
repository: rdkcentral/ThunderInterfaces
ref: ${{steps.interfaces.outputs.first_match}}

- name: Checkout ThunderNanoServices - default
if: ${{ !contains(github.event.pull_request.body, '[DependsOn=ThunderNanoServices:') }}
uses: actions/checkout@v4
with:
path: ThunderNanoServices
repository: rdkcentral/ThunderNanoServices
# TODO: Remove ref once TestPlugin changes are merged to master
ref: development/test-support

- name: Regex ThunderNanoServices
if: ${{ contains(github.event.pull_request.body, '[DependsOn=ThunderNanoServices:') }}
id: nanoservices
uses: AsasInnab/regex-action@v1
with:
regex_pattern: '(?<=\[DependsOn=ThunderNanoServices:).*(?=\])'
regex_flags: 'gim'
search_string: ${{github.event.pull_request.body}}

- name: Checkout ThunderNanoServices - ${{steps.nanoservices.outputs.first_match}}
if: ${{ contains(github.event.pull_request.body, '[DependsOn=ThunderNanoServices:') }}
uses: actions/checkout@v4
with:
path: ThunderNanoServices
repository: rdkcentral/ThunderNanoServices
ref: ${{steps.nanoservices.outputs.first_match}}

# ----- Build -----
- name: Build ThunderTools
run: |
source venv/bin/activate
cmake -G Ninja -S ThunderTools -B ${{matrix.build_type}}/build/ThunderTools \
-DCMAKE_INSTALL_PREFIX="${{matrix.build_type}}/install/usr"
cmake --build ${{matrix.build_type}}/build/ThunderTools --target install

- name: Build Thunder with test support
run: |
source venv/bin/activate
cmake -G Ninja -S Thunder -B ${{matrix.build_type}}/build/Thunder \
-DBINDING="127.0.0.1" \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_INSTALL_PREFIX="${{matrix.build_type}}/install/usr" \
-DCMAKE_MODULE_PATH="${PWD}/${{matrix.build_type}}/install/usr/include/Thunder/Modules" \
-DPORT="0" \
-DENABLE_TEST_RUNTIME=ON
cmake --build ${{matrix.build_type}}/build/Thunder --target install

- name: Build ThunderInterfaces
run: |
source venv/bin/activate
cmake -G Ninja -S ThunderInterfaces -B ${{matrix.build_type}}/build/ThunderInterfaces \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_INSTALL_PREFIX="${{matrix.build_type}}/install/usr" \
-DCMAKE_MODULE_PATH="${PWD}/${{matrix.build_type}}/install/usr/include/Thunder/Modules" \
-DCMAKE_PREFIX_PATH="${PWD}/${{matrix.build_type}}/install/usr"
cmake --build ${{matrix.build_type}}/build/ThunderInterfaces --target install

- name: Build ThunderNanoServices TestPlugin + test
run: |
source venv/bin/activate
cmake -G Ninja -S ThunderNanoServices/tests -B ${{matrix.build_type}}/build/ThunderNanoServicesTests \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_INSTALL_PREFIX="${{matrix.build_type}}/install/usr" \
-DCMAKE_MODULE_PATH="${PWD}/${{matrix.build_type}}/install/usr/include/Thunder/Modules" \
-DCMAKE_PREFIX_PATH="${PWD}/${{matrix.build_type}}/install/usr" \
-DPLUGIN_TESTPLUGIN=ON \
-DTEST_PLUGIN_PATH="${PWD}/${{matrix.build_type}}/install/usr/lib/thunder/plugins"
cmake --build ${{matrix.build_type}}/build/ThunderNanoServicesTests --target install

# ----- Run smoke test -----
- name: Run smoke test
run: |
LD_LIBRARY_PATH="${{matrix.build_type}}/install/usr/lib:$LD_LIBRARY_PATH" \
${{matrix.build_type}}/build/Thunder/Tests/test_support/tests/thunder_test_runtime_smoke \
--gtest_output="xml:smoke-test-results.xml" \
--gtest_color=yes

# ----- Run plugin test -----
- name: Run plugin test (COM-RPC + JSON-RPC + events)
run: |
LD_LIBRARY_PATH="${{matrix.build_type}}/install/usr/lib:${PWD}/${{matrix.build_type}}/install/usr/lib/thunder/plugins:$LD_LIBRARY_PATH" \
${{matrix.build_type}}/build/ThunderNanoServicesTests/TestPlugin/test/thunder_testplugin_test \
--gtest_output="xml:plugin-test-results.xml" \
--gtest_color=yes

- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results-${{matrix.build_type}}
path: |
smoke-test-results.xml
plugin-test-results.xml
5 changes: 5 additions & 0 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ option(FILE_UNLINK_TEST "File unlink test" OFF)
option(REDIRECT_TEST "Test stream redirection" OFF)
option(MESSAGEBUFFER_TEST "Test message buffer" OFF)
option(UNRAVELLER "reveal thread details" OFF)
option(ENABLE_TEST_RUNTIME "Build the in-process Thunder test runtime library" OFF)

if(BUILD_TESTS)
add_subdirectory(unit)
Expand Down Expand Up @@ -40,4 +41,8 @@ endif()

if(UNRAVELLER)
add_subdirectory(unraveller)
endif()

if(ENABLE_TEST_RUNTIME)
add_subdirectory(test_support)
endif()
152 changes: 152 additions & 0 deletions Tests/test_support/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# ==========================================================================
# thunder_test_support — static library for in-process Thunder plugin testing
#
# Compiles the test runtime together with the subset of Source/Thunder
# objects needed to host an embedded PluginHost::Server. The resulting
# archive is linked via whole-archive so that MODULE_NAME_DECLARATION
# statics are not dropped by the linker.
# ==========================================================================

find_package(Threads REQUIRED)

set(THUNDER_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../Source/Thunder")

set(THREADPOOL_COUNT "4" CACHE STRING "The number of threads in the thread pool for test runtime")

set(TARGET thunder_test_support)

add_library(${TARGET} STATIC
ThunderTestRuntime.cpp
Module.cpp
${THUNDER_SOURCE_DIR}/PluginServer.cpp
${THUNDER_SOURCE_DIR}/Controller.cpp
${THUNDER_SOURCE_DIR}/SystemInfo.cpp
${THUNDER_SOURCE_DIR}/PostMortem.cpp
${THUNDER_SOURCE_DIR}/Probe.cpp
)

target_include_directories(${TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}>
PRIVATE
${THUNDER_SOURCE_DIR}
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/Source/plugins/generated/jsonrpc>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/Source/Thunder/generated>
)

target_compile_definitions(${TARGET}
PRIVATE
NAMESPACE=${NAMESPACE}
APPLICATION_NAME=ThunderTestRuntime
MODULE_NAME=ThunderTestRuntime
THREADPOOL_COUNT=${THREADPOOL_COUNT}
DEFAULT_SYSTEM_PATH="${SYSTEM_PATH}"
DEFAULT_PROXYSTUB_PATH="${PROXYSTUB_PATH}"
)

target_compile_options(${TARGET} PRIVATE -Wno-psabi)

set_target_properties(${TARGET} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
)

target_link_libraries(${TARGET}
PRIVATE
CompileSettings::CompileSettings
CompileSettingsDebug::CompileSettingsDebug
)

if(EXCEPTION_CATCHING)
set_source_files_properties(${THUNDER_SOURCE_DIR}/PluginServer.cpp PROPERTIES COMPILE_FLAGS "-fexceptions")
endif()

target_link_libraries(${TARGET}
PUBLIC
${NAMESPACE}Core::${NAMESPACE}Core
${NAMESPACE}Cryptalgo::${NAMESPACE}Cryptalgo
${NAMESPACE}COM::${NAMESPACE}COM
${NAMESPACE}Messaging::${NAMESPACE}Messaging
${NAMESPACE}WebSocket::${NAMESPACE}WebSocket
${NAMESPACE}Plugins::${NAMESPACE}Plugins
Threads::Threads
)

# COMProcess is an INTERFACE library carrying only a compile definition.
# It is not in any export set, so we absorb its effect directly.
target_compile_definitions(${TARGET} PRIVATE HOSTING_COMPROCESS=ThunderPlugin)

# ------------------------------------------------------------------
# Whole-archive link. Ensures that the MODULE_NAME_DECLARATION
# constructors from the Server objects are not discarded.
# BUILD_INTERFACE only — installed consumers get this via the
# custom Config.cmake.in template instead.
# ------------------------------------------------------------------
if(APPLE)
target_link_options(${TARGET} INTERFACE
"$<BUILD_INTERFACE:SHELL:-Wl,-force_load,$<TARGET_FILE:${TARGET}>>"
)
else()
target_link_options(${TARGET} INTERFACE
"$<BUILD_INTERFACE:SHELL:-Wl,--whole-archive $<TARGET_FILE:${TARGET}> -Wl,--no-whole-archive>"
)
endif()

# ------------------------------------------------------------------
# Optional features – only link when enabled in the main build.
# ------------------------------------------------------------------
if(WARNING_REPORTING)
target_sources(${TARGET}
PRIVATE
${THUNDER_SOURCE_DIR}/WarningReportingCategories.cpp
)
endif()

if(PROCESSCONTAINERS)
target_link_libraries(${TARGET}
PUBLIC
${NAMESPACE}ProcessContainers::${NAMESPACE}ProcessContainers
)
target_compile_definitions(${TARGET}
PUBLIC
PROCESSCONTAINERS_ENABLED=1
)
endif()

if(HIBERNATESUPPORT)
target_link_libraries(${TARGET}
PUBLIC
${NAMESPACE}Hibernate::${NAMESPACE}Hibernate
)
target_compile_definitions(${TARGET}
PUBLIC
HIBERNATE_SUPPORT_ENABLED=1
)
endif()

# ------------------------------------------------------------------
# Install the library and header so external projects can use it
# via find_package(thunder_test_support)
# ------------------------------------------------------------------
install(
FILES ThunderTestRuntime.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/test_support
COMPONENT ${NAMESPACE}_Development
)

install(
TARGETS ${TARGET} EXPORT ${TARGET}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${NAMESPACE}_Development
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}
)

InstallCMakeConfig(
TARGETS ${TARGET}
TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/thunder_test_supportConfig.cmake.in
)

# ------------------------------------------------------------------
# Smoke test sub-directory
# ------------------------------------------------------------------
add_subdirectory(tests)
3 changes: 3 additions & 0 deletions Tests/test_support/Module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "Module.h"

MODULE_NAME_ARCHIVE_DECLARATION
10 changes: 10 additions & 0 deletions Tests/test_support/Module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#ifndef MODULE_NAME
#define MODULE_NAME ThunderTestRuntime
#endif

#include <plugins/plugins.h>

#undef EXTERNAL
#define EXTERNAL
Loading
Loading