Use original names for config parameters

The config parameter names defined in the relay_chn_defs.h file
have been changed back to their original names (with the CONFIG_ prefix),
so that they are not confused with application-level defines.

Refs #1085
This commit is contained in:
2025-08-25 10:24:13 +03:00
parent 9d3f8ddbff
commit 5afefc4dc0
21 changed files with 186 additions and 207 deletions

View File

@@ -7,7 +7,7 @@
#include "unity_test_runner.h"
#include "test_common.h"
#if RELAY_CHN_ENABLE_NVS == 1
#if CONFIG_RELAY_CHN_ENABLE_NVS == 1
#include "nvs_flash.h"
#include "relay_chn_nvs.h"
#endif
@@ -32,14 +32,14 @@ void tearDown()
static void test_nvs_flash_init(void)
{
esp_err_t ret;
#if RELAY_CHN_NVS_CUSTOM_PARTITION == 1
ret = nvs_flash_init_partition(RELAY_CHN_NVS_CUSTOM_PARTITION_NAME);
#if CONFIG_RELAY_CHN_NVS_CUSTOM_PARTITION == 1
ret = nvs_flash_init_partition(CONFIG_RELAY_CHN_NVS_CUSTOM_PARTITION_NAME);
ESP_LOGI(TEST_TAG, "test_nvs_flash_init: NVS flash init partition return: %s", esp_err_to_name(ret));
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
// NVS partition is truncated and needs to be erased
ret = nvs_flash_erase_partition(RELAY_CHN_NVS_CUSTOM_PARTITION_NAME);
ret = nvs_flash_erase_partition(CONFIG_RELAY_CHN_NVS_CUSTOM_PARTITION_NAME);
if (ret == ESP_OK) {
ret = nvs_flash_init_partition(RELAY_CHN_NVS_CUSTOM_PARTITION_NAME);
ret = nvs_flash_init_partition(CONFIG_RELAY_CHN_NVS_CUSTOM_PARTITION_NAME);
}
}
#else
@@ -61,8 +61,8 @@ TEST_ESP_OK(ret);
static void test_nvs_flash_deinit(void)
{
esp_err_t ret;
#if RELAY_CHN_NVS_CUSTOM_PARTITION == 1
ret = nvs_flash_deinit_partition(RELAY_CHN_NVS_CUSTOM_PARTITION_NAME);
#if CONFIG_RELAY_CHN_NVS_CUSTOM_PARTITION == 1
ret = nvs_flash_deinit_partition(CONFIG_RELAY_CHN_NVS_CUSTOM_PARTITION_NAME);
#else
ret = nvs_flash_deinit();
#endif

View File

@@ -8,7 +8,7 @@ TEST_CASE("relay_chn_create handles invalid arguments", "[relay_chn][core]")
// 1. Test with NULL gpio_map
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_create(NULL, gpio_count));
// 2. Test with incorrect gpio_count (must be RELAY_CHN_COUNT * 2)
// 2. Test with incorrect gpio_count (must be CONFIG_RELAY_CHN_COUNT * 2)
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_create(gpio_map, gpio_count - 1));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_create(gpio_map, 1));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_create(gpio_map, 0));

View File

@@ -8,7 +8,7 @@ TEST_CASE("relay_chn_create handles invalid arguments", "[relay_chn][core]")
// 1. Test with NULL gpio_map
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_create(NULL, gpio_count));
// 2. Test with incorrect gpio_count (must be RELAY_CHN_COUNT * 2)
// 2. Test with incorrect gpio_count (must be CONFIG_RELAY_CHN_COUNT * 2)
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_create(gpio_map, gpio_count - 1));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_create(gpio_map, 1));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_create(gpio_map, 0));

View File

@@ -41,7 +41,7 @@ TEST_CASE("Test invalid parameters", "[relay_chn][nvs]")
TEST_ESP_OK(relay_chn_nvs_init());
// Test NULL pointer for all channels
for (int channel = 0; channel < RELAY_CHN_COUNT; channel++) {
for (int channel = 0; channel < CONFIG_RELAY_CHN_COUNT; channel++) {
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_direction(channel, NULL));
}
@@ -54,13 +54,13 @@ TEST_CASE("Test relay_chn_nvs_erase_all", "[relay_chn][nvs]")
// Store some test data first
relay_chn_direction_t direction = RELAY_CHN_DIRECTION_FLIPPED;
for (int channel = 0; channel < RELAY_CHN_COUNT; channel++) {
for (int channel = 0; channel < CONFIG_RELAY_CHN_COUNT; channel++) {
TEST_ESP_OK(relay_chn_nvs_set_direction(0, direction));
}
#ifdef RELAY_CHN_ENABLE_TILTING
#ifdef CONFIG_RELAY_CHN_ENABLE_TILTING
uint8_t sensitivity = 50;
for (int channel = 0; channel < RELAY_CHN_COUNT; channel++) {
for (int channel = 0; channel < CONFIG_RELAY_CHN_COUNT; channel++) {
TEST_ESP_OK(relay_chn_nvs_set_tilt_sensitivity(0, sensitivity));
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(0, 100));
}
@@ -73,7 +73,7 @@ TEST_CASE("Test relay_chn_nvs_erase_all", "[relay_chn][nvs]")
relay_chn_direction_t read_direction;
TEST_ASSERT_EQUAL(ESP_ERR_NVS_NOT_FOUND, relay_chn_nvs_get_direction(0, &read_direction));
#ifdef RELAY_CHN_ENABLE_TILTING
#ifdef CONFIG_RELAY_CHN_ENABLE_TILTING
uint8_t read_sensitivity;
TEST_ASSERT_EQUAL(ESP_ERR_NVS_NOT_FOUND, relay_chn_nvs_get_tilt_sensitivity(0, &read_sensitivity));
@@ -101,7 +101,7 @@ TEST_CASE("Test run limit setting and getting", "[relay_chn][nvs][run_limit]")
}
#endif
#ifdef RELAY_CHN_ENABLE_TILTING
#ifdef CONFIG_RELAY_CHN_ENABLE_TILTING
TEST_CASE("Test sensitivity setting and getting", "[relay_chn][nvs][tilt]")
{
TEST_ESP_OK(relay_chn_nvs_init());
@@ -110,7 +110,7 @@ TEST_CASE("Test sensitivity setting and getting", "[relay_chn][nvs][tilt]")
uint8_t sensitivity;
// Test all channels
for (int channel = 0; channel < RELAY_CHN_COUNT; channel++) {
for (int channel = 0; channel < CONFIG_RELAY_CHN_COUNT; channel++) {
TEST_ESP_OK(relay_chn_nvs_set_tilt_sensitivity(channel, test_sensitivity));
TEST_ESP_OK(relay_chn_nvs_get_tilt_sensitivity(channel, &sensitivity));
TEST_ASSERT_EQUAL(test_sensitivity, sensitivity);
@@ -127,7 +127,7 @@ TEST_CASE("Test tilt counter operations", "[relay_chn][nvs][tilt]")
uint16_t tilt_count_read;
// Test all channels
for (int channel = 0; channel < RELAY_CHN_COUNT; channel++) {
for (int channel = 0; channel < CONFIG_RELAY_CHN_COUNT; channel++) {
// Test setting counters
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(channel, tilt_count));
TEST_ESP_OK(relay_chn_nvs_get_tilt_count(channel, &tilt_count_read));
@@ -142,11 +142,11 @@ TEST_CASE("Test tilting invalid parameters", "[relay_chn][nvs][tilt]")
TEST_ESP_OK(relay_chn_nvs_init());
// Test NULL pointers for all channels
for (int channel = 0; channel < RELAY_CHN_COUNT; channel++) {
for (int channel = 0; channel < CONFIG_RELAY_CHN_COUNT; channel++) {
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_tilt_sensitivity(channel, NULL));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_tilt_count(channel, NULL));
}
TEST_ESP_OK(relay_chn_nvs_deinit());
}
#endif // RELAY_CHN_ENABLE_TILTING
#endif // CONFIG_RELAY_CHN_ENABLE_TILTING

View File

@@ -53,7 +53,7 @@ TEST_CASE("Test relay_chn_nvs_erase_all", "[relay_chn][nvs]")
relay_chn_direction_t direction = RELAY_CHN_DIRECTION_FLIPPED;
TEST_ESP_OK(relay_chn_nvs_set_direction(0, direction));
#ifdef RELAY_CHN_ENABLE_TILTING
#ifdef CONFIG_RELAY_CHN_ENABLE_TILTING
uint8_t sensitivity = 50;
TEST_ESP_OK(relay_chn_nvs_set_tilt_sensitivity(0, sensitivity));
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(0, 100));
@@ -66,7 +66,7 @@ TEST_CASE("Test relay_chn_nvs_erase_all", "[relay_chn][nvs]")
relay_chn_direction_t read_direction;
TEST_ASSERT_EQUAL(ESP_ERR_NVS_NOT_FOUND, relay_chn_nvs_get_direction(0, &read_direction));
#ifdef RELAY_CHN_ENABLE_TILTING
#ifdef CONFIG_RELAY_CHN_ENABLE_TILTING
uint8_t read_sensitivity;
TEST_ASSERT_EQUAL(ESP_ERR_NVS_NOT_FOUND, relay_chn_nvs_get_tilt_sensitivity(0, &read_sensitivity));
@@ -93,7 +93,7 @@ TEST_CASE("Test run limit setting and getting", "[relay_chn][nvs][run_limit]")
}
#endif
#ifdef RELAY_CHN_ENABLE_TILTING
#ifdef CONFIG_RELAY_CHN_ENABLE_TILTING
TEST_CASE("Test sensitivity setting and getting", "[relay_chn][nvs][tilt]")
{
TEST_ESP_OK(relay_chn_nvs_init());
@@ -134,4 +134,4 @@ TEST_CASE("Test tilting invalid parameters", "[relay_chn][nvs][tilt]")
TEST_ESP_OK(relay_chn_nvs_deinit());
}
#endif // RELAY_CHN_ENABLE_TILTING
#endif // CONFIG_RELAY_CHN_ENABLE_TILTING