-
Notifications
You must be signed in to change notification settings - Fork 7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Similar to gTest, CppuTest is a CPP framework for unit tests. This commit adds support based on the console output of a cpputest test suite application. Signed-off-by: Victor Chavez <vchavezb@protonmail.com>
- Loading branch information
Showing
9 changed files
with
315 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2025, Victor Chavez (vchavezb@protonmail.com) | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(cpputest_sample) | ||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
CppUTest | ||
GIT_REPOSITORY https://github.com/cpputest/cpputest.git | ||
GIT_TAG v4.0 | ||
) | ||
set(TESTS OFF CACHE BOOL "Switch off CppUTest Test build") | ||
|
||
FetchContent_MakeAvailable(CppUTest) | ||
|
||
|
||
target_sources(app PRIVATE src/main.cpp | ||
src/test_suite.cpp | ||
) | ||
|
||
target_link_libraries(app PRIVATE | ||
CppUTest | ||
CppUTestExt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CONFIG_CPP=y | ||
CONFIG_LOG=y | ||
CONFIG_STD_CPP17=y | ||
CONFIG_REQUIRES_FULL_LIBCPP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2025, Victor Chavez (vchavezb@protonmail.com) | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <CppUTest/CommandLineTestRunner.h> | ||
#include <posix_board_if.h> // posix_exit | ||
|
||
int main(void) | ||
{ | ||
/* Enable cpputest verbose mode (-v) to get the name | ||
* of tests that have passed. Otherwise only a dot | ||
* is printed per test. | ||
*/ | ||
const char *cppu_test_args[] = {__FILE__, "-v", "-c"}; | ||
int num_args = std::size(cppu_test_args); | ||
int test_Res = CommandLineTestRunner::RunAllTests(num_args, cppu_test_args); | ||
/* Exit before main ends as zephyr idle thread runs in the background */ | ||
posix_exit(test_Res); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright (c) 2025, Victor Chavez (vchavezb@protonmail.com) | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <zephyr/logging/log.h> | ||
#include <CppUTest/CommandLineTestRunner.h> | ||
#include <CppUTestExt/MockSupport.h> | ||
|
||
LOG_MODULE_REGISTER(test_suite, CONFIG_LOG_DEFAULT_LEVEL); | ||
|
||
TEST_GROUP(my_test_group) { | ||
void setup() final | ||
{ | ||
} | ||
void teardown() final | ||
{ | ||
} | ||
}; | ||
|
||
TEST(my_test_group, test_1) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
common: | ||
tags: | ||
- test_framework | ||
|
||
tests: | ||
base.my_test_group: | ||
platform_allow: | ||
- native_sim/native/64 | ||
harness: "cpputest" |