Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrfconnect] Allow running only specific test suites #37811

Merged
merged 3 commits into from
Feb 28, 2025
Merged
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -550,6 +550,25 @@
"runToEntryPoint": "main",
"preLaunchTask": "Debug Open IoT SDK unit-tests",
"showDevDebugOutput": "parsed"
},
{
"name": "Zephyr native tests",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/out/nrf-native-sim-tests/nrfconnect/zephyr/zephyr.exe",
"args": ["-testargs"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/out/nrf-native-sim-tests/nrfconnect",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
],
"inputs": [
3 changes: 3 additions & 0 deletions scripts/tools/check_includes_config.py
Original file line number Diff line number Diff line change
@@ -188,4 +188,7 @@
'src/controller/CHIPDeviceController.cpp': {'string'},
'src/qrcodetool/setup_payload_commands.cpp': {'string'},
'src/access/AccessRestrictionProvider.h': {'vector', 'map'},

# nrfconnect test runner
'src/test_driver/nrfconnect/main/runner.cpp': {'vector'},
}
20 changes: 20 additions & 0 deletions src/test_driver/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -48,6 +48,8 @@ set(CHIP_CFLAGS
list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})

set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo")

# ==================================================
# Build 'all tests' runner
# ==================================================
@@ -56,6 +58,24 @@ project(AllChipTests)
enable_testing()

target_sources(app PRIVATE main/runner.cpp)
target_include_directories(app PUBLIC
${PIGWEED_ROOT}/pw_assert/public
${PIGWEED_ROOT}/pw_assert_zephyr/public
${PIGWEED_ROOT}/pw_assert_zephyr/public_overrides
${PIGWEED_ROOT}/pw_bytes/public
${PIGWEED_ROOT}/pw_preprocessor/public
${PIGWEED_ROOT}/pw_polyfill/public
${PIGWEED_ROOT}/pw_polyfill/standard_library_public
${PIGWEED_ROOT}/pw_polyfill/public_overrides
${PIGWEED_ROOT}/pw_result/public
${PIGWEED_ROOT}/pw_span/public
${PIGWEED_ROOT}/pw_span/public_overrides
${PIGWEED_ROOT}/pw_status/public
${PIGWEED_ROOT}/pw_string/public
${PIGWEED_ROOT}/pw_unit_test/public
${PIGWEED_ROOT}/pw_unit_test/light_public_overrides
${PIGWEED_ROOT}/third_party/fuchsia/repo/sdk/lib/stdcompat/include
)
target_link_libraries(app PUBLIC chip $<TARGET_FILE:kernel>)
target_compile_definitions(app PUBLIC CHIP_HAVE_CONFIG_H)

15 changes: 15 additions & 0 deletions src/test_driver/nrfconnect/main/runner.cpp
Original file line number Diff line number Diff line change
@@ -18,9 +18,12 @@
#include <lib/support/CodeUtils.h>
#include <lib/support/UnitTest.h>
#include <platform/CHIPDeviceLayer.h>
#include <pw_unit_test/framework.h>

#include <unistd.h>
#include <vector>

#include <nsi_cmdline.h>
#include <zephyr/logging/log.h>
#include <zephyr/settings/settings.h>

@@ -33,6 +36,18 @@ int main(void)
{
VerifyOrDie(settings_subsys_init() == 0);

int argc;
char ** argv;
nsi_get_test_cmd_line_args(&argc, &argv);

std::vector<std::string_view> suites_to_run;
for (int i = 0; i < argc; ++i)
{
suites_to_run.push_back(argv[i]);
}

pw::unit_test::SetTestSuitesToRun(suites_to_run);

LOG_INF("Starting CHIP tests!");
int status = 0;
status += chip::test::RunAllTests();