Refactor to remove redundant initialization and add NVS storage tests

- Removed unnecessary calls to relay_chn_create and g_is_component_initialized in multiple test cases across test_relay_chn_core_single.c, test_relay_chn_listener_multi.c, and test_relay_chn_listener_single.c.
- Introduced new test files for NVS functionality: test_relay_chn_nvs_multi.c and test_relay_chn_nvs_single.c, covering initialization, direction setting, invalid parameters, and erase operations.
- Updated partition table configuration to support NVS storage, including the addition of a new partition file part_nvs.csv.
- Adjusted sdkconfig files to enable NVS support and configure custom partition settings for relay channels.
This commit is contained in:
2025-08-19 17:36:23 +03:00
parent b19f0c553b
commit 61edf11b75
19 changed files with 428 additions and 218 deletions

View File

@@ -4,9 +4,7 @@ const char *TEST_TAG = "RELAY_CHN_TEST";
const uint8_t relay_chn_count = CONFIG_RELAY_CHN_COUNT;
const uint32_t opposite_inertia_ms = CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS;
const uint32_t test_delay_margin_ms = 50; // ms toleransı
bool g_is_component_initialized = false;
const uint32_t test_delay_margin_ms = 50; // ms tolerance
// Test-wide GPIO map
#if CONFIG_RELAY_CHN_COUNT > 1
@@ -36,4 +34,19 @@ const uint8_t gpio_map[] = {
const uint8_t gpio_map[] = {4, 5};
#endif
const uint8_t gpio_count = sizeof(gpio_map) / sizeof(gpio_map[0]);
const uint8_t gpio_count = sizeof(gpio_map) / sizeof(gpio_map[0]);
void reset_channels_to_idle_state()
{
#if CONFIG_RELAY_CHN_COUNT > 1
relay_chn_stop(RELAY_CHN_ID_ALL);
vTaskDelay(pdMS_TO_TICKS(opposite_inertia_ms + test_delay_margin_ms));
for (int i = 0; i < CONFIG_RELAY_CHN_COUNT; i++) {
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state(i));
}
#else
relay_chn_stop();
vTaskDelay(pdMS_TO_TICKS(opposite_inertia_ms + test_delay_margin_ms));
TEST_ASSERT_EQUAL(RELAY_CHN_STATE_IDLE, relay_chn_get_state());
#endif
}