doc(pico-sensor): updated readme with remote tests informations

This commit is contained in:
SylvanArnold
2025-06-04 10:51:17 +02:00
parent 2a5b481d66
commit 0bb52a3a07
6 changed files with 88 additions and 25 deletions

View File

View File

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2025, Sylvan Arnold
*
*/
#include "platform.h"
#if PL_CONFIG_USE_UNIT_TESTS
#include "test_sensors.h"
#include "unity.h"
#include "sensor.h"
void TestSensors_Test(void) {
float temp, hum;
/* Test that initial sensor values are within a reasonable range */
temp = Sensor_GetTemperature();
hum = Sensor_GetHumidity();
/* Check temperature is within plausible sensor range (-40°C to 125°C) */
TEST_ASSERT_TRUE_MESSAGE(temp > -50.0f && temp < 130.0f, "Temperature out of range");
/* Check humidity is within plausible sensor range (0% to 100%) */
TEST_ASSERT_TRUE_MESSAGE(hum >= 0.0f && hum <= 100.0f, "Humidity out of range");
/* Optionally, check that values are not both zero (unless sensor is uninitialized) */
TEST_ASSERT_FALSE_MESSAGE(temp == 0.0f && hum == 0.0f, "Sensor values are both zero, possible init error");
}
# endif

View File

@@ -0,0 +1,11 @@
/*
* Copyright (c) 2025, Sylvan Arnold
*
*/
#ifndef _TEST_SENSORS_H__
#define _TEST_SENSORS_H__
void TestSensors_Test(void);
#endif /* _TEST_SENSORS_H__ */

View File

@@ -14,10 +14,10 @@
#include "McuRTT.h"
#include "McuUtility.h"
#include "McuLog.h"
//#include "test_sensor.h"
//#include "test_leds.h"
#include "test_sensors.h"
#include "test_dns_resolver.h"
static void TestArgFailed(void) {
TEST_ASSERT_MESSAGE(false, "wrong test_arg value");
}
@@ -36,18 +36,12 @@ void Tests_Run(void) {
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);
if (McuUtility_strcmp(buf, "dummy")==0) {
RUN_TEST(TestDummy);
} else if (McuUtility_strcmp(buf, "sensors")==0) {
RUN_TEST(TestSensors_Test);
} else if (McuUtility_strcmp(buf, "dns")==0) {
RUN_TEST(TestDnsResolver_Test);
}
else if (McuUtility_strcmp(buf, "dummy")==0) {
RUN_TEST(TestDummy);
}
else {
RUN_TEST(TestArgFailed);