doc: renamed project

This commit is contained in:
SylvanArnold
2025-04-29 13:52:54 +02:00
committed by Sylvan Arnold
parent 244e516bd8
commit 32618389d1
985 changed files with 1 additions and 1 deletions

View File

@@ -0,0 +1,59 @@
# file: Collect all files that need to be compiled.
# You can use a GLOB function as shown here, or explicitly mention the specific files
#file(GLOB FILES *.c *.h)
# Need to include CTest on every CMakeLists.txt which is going to use tests
include(CTest)
set(THIS_LIBRARY_NAME srcTestsLib)
file(GLOB FILES
*.c
)
# add_library: With this declaration, you express the intent to build a library.
# The first argument is the name of the library,
# the second argument are the files that will be compiled to create your library.
add_library(${THIS_LIBRARY_NAME} ${FILES})
# target_link_libraries: If you link with other libraries, list them here
target_link_libraries(
${THIS_LIBRARY_NAME}
PRIVATE McuLib
PRIVATE unityLib
PRIVATE srcLib
PRIVATE pico_cyw43_arch_lwip_sys_freertos
)
# target_include_directories: Libraries need to publish their header files
# so that you can import them in source code. This statement expresses where to find the files
# - typically in an include directory of your projects.
target_include_directories(
${THIS_LIBRARY_NAME}
PUBLIC
.
)
#################################################################################
# Note: --pc off --sp off are needed, if application runs from the ROM bootloader, might add --verbose
set (JRUN_CTEST_COMMAND "$ENV{SEGGER_PATH}/JRun" --device RP2040_M0_0 --rtt -if SWD --pc off --sp off)
add_test(
NAME Led
COMMAND ${JRUN_CTEST_COMMAND} --args "led" ${TEST_EXECUTABLE}
)
add_test(
NAME Sensor
COMMAND ${JRUN_CTEST_COMMAND} --args "sensor" ${TEST_EXECUTABLE}
)
add_test(
NAME DNS
COMMAND ${JRUN_CTEST_COMMAND} --args "dns" ${TEST_EXECUTABLE}
)
set_tests_properties(
Led Sensor DNS
PROPERTIES
TIMEOUT 15
)

6588
pico-sensor/src/tests/fff.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2023, Erich Styger
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "platform.h"
#if PL_CONFIG_USE_UNIT_TESTS
#include "test_dns_resolver.h"
#include "McuUtility.h"
#include "dns_resolver.h"
#include "unity/unity.h"
#include "fff.h"
DEFINE_FFF_GLOBALS;
FAKE_VOID_FUNC(DnsResolver_Init);
void TestDnsResolver_Test(void) {
DnsResolver_info_t info;
int res;
unsigned char buf[16];
// DnsResolver_ResolveName(NULL, NULL, 0); // will fail and crash!
res = DnsResolver_ResolveName("127.0.0.1", &info, 0);
TEST_ASSERT_MESSAGE(res==0, "fixed IP does not need resolving");
ip4addr_ntoa_r(&info.resolved_addr, buf, sizeof(buf));
TEST_ASSERT(McuUtility_strcmp(buf, "127.0.0.1")==0);
TEST_ASSERT_MESSAGE(DnsResolver_ResolveName("server", &info, -1)==-2, "negative timeout shall return -2");
//DnsResolver_Init();
//TEST_ASSERT_MESSAGE(DnsResolver_Init_fake.call_count==1, "call count shall be 1");
}
#endif /* PL_CONFIG_USE_UNIT_TESTS */

View File

@@ -0,0 +1,12 @@
/*
* Copyright (c) 2023, Erich Styger
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _TEST_DNS_RESOLVER_H__
#define _TEST_DNS_RESOLVER_H__
void TestDnsResolver_Test(void);
#endif /* _TEST_DNS_RESOLVER_H__ */

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2023, Erich Styger
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "platform.h"
#if PL_CONFIG_USE_UNIT_TESTS
#include "tests.h"
#include "unity.h"
#include "McuUnity.h"
#include "McuRTOS.h"
#include "McuShell.h"
#include "McuRTT.h"
#include "McuUtility.h"
#include "McuLog.h"
#include "test_sensor.h"
#include "test_leds.h"
#include "test_dns_resolver.h"
static void TestArgFailed(void) {
TEST_ASSERT_MESSAGE(false, "wrong test_arg value");
}
void Tests_Run(void) {
int nofFailures;
uint32_t test_arg = -1;
int nofBytes;
unsigned char buf[32];
nofBytes = McuUnity_RTT_GetArgs(buf, sizeof(buf));
UNITY_BEGIN();
if (nofBytes>0) {
if (McuUtility_strcmp(buf, "led")==0) {
RUN_TEST(TestLeds_OnOff);
RUN_TEST(TestLeds_Toggle);
} else if (McuUtility_strcmp(buf, "sensor")==0) {
RUN_TEST(TestSensor_Temperature);
RUN_TEST(TestSensor_Humidity);
RUN_TEST(TestSensor_Both);
} else if (McuUtility_strcmp(buf, "dns")==0) {
RUN_TEST(TestDnsResolver_Test);
} else {
RUN_TEST(TestArgFailed);
}
} else {
RUN_TEST(TestArgFailed);
}
nofFailures = UNITY_END();
#if PL_CONFIG_USE_RTT
McuUnity_Exit_JRun_RTT(nofFailures==0);
#else
McuUnity_Exit_LinkServer_Log(nofFailures==0);
#endif
}
static void TestTask(void *pv) {
McuLog_info("starting test task");
vTaskDelay(pdMS_TO_TICKS(100)); /* give sensor some time */
Tests_Run();
vTaskDelete(NULL); /* terminate task */
}
void Tests_Init(void) {
if (xTaskCreate(
TestTask, /* pointer to the task */
"Test", /* task name for kernel awareness debugging */
1500/sizeof(StackType_t), /* task stack size */
(void*)NULL, /* optional task startup argument */
tskIDLE_PRIORITY, /* initial priority */
(TaskHandle_t*)NULL /* optional task handle to create */
) != pdPASS)
{
McuLog_fatal("Failed creating task");
for(;;){} /* error! probably out of memory */
}
}
#endif /* PL_CONFIG_USE_UNIT_TESTS */

View File

@@ -0,0 +1,14 @@
/*
* Copyright (c) 2023, Erich Styger
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef TESTS_H_
#define TESTS_H_
void Tests_Run(void);
void Tests_Init(void);
#endif /* TESTS_H_ */