[FL-2499] Folders rename fix (#1190)
* Toolbox: dir_walk concept (like os.walk) * Storage CLI: tree command * Storage: fix folders copying, stage 1 * UnitTest: proper delays in subghz tests * Toolbox: dir_walk, recursive and filter options * dir_walk: unit tests * Merge: Fix unused param * SubGhz: cleaned up data parsing routine * SubGhz unit test: cleaned up logs, yield data load * SubGhz unit test: naming Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -32,7 +32,7 @@ static void subghz_test_rx_callback(
|
||||
string_init(text);
|
||||
subghz_protocol_decoder_base_get_string(decoder_base, text);
|
||||
subghz_receiver_reset(receiver_handler);
|
||||
FURI_LOG_I(TAG, "\r\n%s", string_get_cstr(text));
|
||||
FURI_LOG_T(TAG, "\r\n%s", string_get_cstr(text));
|
||||
string_clear(text);
|
||||
subghz_test_decoder_count++;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ static void subghz_test_deinit(void) {
|
||||
subghz_environment_free(environment_handler);
|
||||
}
|
||||
|
||||
static bool subghz_decode_test(const char* path, const char* name_decoder) {
|
||||
static bool subghz_decoder_test(const char* path, const char* name_decoder) {
|
||||
subghz_test_decoder_count = 0;
|
||||
uint32_t test_start = furi_hal_get_tick();
|
||||
|
||||
@@ -64,18 +64,18 @@ static bool subghz_decode_test(const char* path, const char* name_decoder) {
|
||||
if(decoder) {
|
||||
file_worker_encoder_handler = subghz_file_encoder_worker_alloc();
|
||||
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path)) {
|
||||
//the worker needs a file in order to open and read part of the file
|
||||
// the worker needs a file in order to open and read part of the file
|
||||
osDelay(100);
|
||||
|
||||
LevelDuration level_duration;
|
||||
while(furi_hal_get_tick() - test_start < TEST_TIMEOUT) {
|
||||
furi_hal_delay_us(
|
||||
500); //you need to have time to read from the file from the SD card
|
||||
level_duration =
|
||||
subghz_file_encoder_worker_get_level_duration(file_worker_encoder_handler);
|
||||
if(!level_duration_is_reset(level_duration)) {
|
||||
bool level = level_duration_get_level(level_duration);
|
||||
uint32_t duration = level_duration_get_duration(level_duration);
|
||||
// Yield, to load data inside the worker
|
||||
osThreadYield();
|
||||
decoder->protocol->decoder->feed(decoder, level, duration);
|
||||
} else {
|
||||
break;
|
||||
@@ -88,7 +88,7 @@ static bool subghz_decode_test(const char* path, const char* name_decoder) {
|
||||
}
|
||||
subghz_file_encoder_worker_free(file_worker_encoder_handler);
|
||||
}
|
||||
FURI_LOG_I(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
|
||||
FURI_LOG_T(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
|
||||
if(furi_hal_get_tick() - test_start > TEST_TIMEOUT) {
|
||||
printf("\033[0;31mTest decoder %s ERROR TimeOut\033[0m\r\n", name_decoder);
|
||||
return false;
|
||||
@@ -97,24 +97,25 @@ static bool subghz_decode_test(const char* path, const char* name_decoder) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool subghz_decode_ramdom_test(const char* path) {
|
||||
static bool subghz_decode_random_test(const char* path) {
|
||||
subghz_test_decoder_count = 0;
|
||||
subghz_receiver_reset(receiver_handler);
|
||||
uint32_t test_start = furi_hal_get_tick();
|
||||
|
||||
file_worker_encoder_handler = subghz_file_encoder_worker_alloc();
|
||||
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path)) {
|
||||
//the worker needs a file in order to open and read part of the file
|
||||
// the worker needs a file in order to open and read part of the file
|
||||
osDelay(100);
|
||||
|
||||
LevelDuration level_duration;
|
||||
while(furi_hal_get_tick() - test_start < TEST_TIMEOUT * 10) {
|
||||
furi_hal_delay_us(500); //you need to have time to read from the file from the SD card
|
||||
level_duration =
|
||||
subghz_file_encoder_worker_get_level_duration(file_worker_encoder_handler);
|
||||
if(!level_duration_is_reset(level_duration)) {
|
||||
bool level = level_duration_get_level(level_duration);
|
||||
uint32_t duration = level_duration_get_duration(level_duration);
|
||||
// Yield, to load data inside the worker
|
||||
osThreadYield();
|
||||
subghz_receiver_decode(receiver_handler, level, duration);
|
||||
} else {
|
||||
break;
|
||||
@@ -126,7 +127,7 @@ static bool subghz_decode_ramdom_test(const char* path) {
|
||||
}
|
||||
subghz_file_encoder_worker_free(file_worker_encoder_handler);
|
||||
}
|
||||
FURI_LOG_I(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
|
||||
FURI_LOG_T(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
|
||||
if(furi_hal_get_tick() - test_start > TEST_TIMEOUT * 10) {
|
||||
printf("\033[0;31mRandom test ERROR TimeOut\033[0m\r\n");
|
||||
return false;
|
||||
@@ -137,7 +138,7 @@ static bool subghz_decode_ramdom_test(const char* path) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool subghz_ecode_test(const char* path) {
|
||||
static bool subghz_encoder_test(const char* path) {
|
||||
subghz_test_decoder_count = 0;
|
||||
uint32_t test_start = furi_hal_get_tick();
|
||||
string_t temp_str;
|
||||
@@ -189,7 +190,7 @@ static bool subghz_ecode_test(const char* path) {
|
||||
subghz_transmitter_free(transmitter);
|
||||
}
|
||||
flipper_format_free(fff_data_file);
|
||||
FURI_LOG_I(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
|
||||
FURI_LOG_T(TAG, "\r\n Decoder count parse \033[0;33m%d\033[0m ", subghz_test_decoder_count);
|
||||
if(furi_hal_get_tick() - test_start > TEST_TIMEOUT) {
|
||||
printf("\033[0;31mTest encoder %s ERROR TimeOut\033[0m\r\n", string_get_cstr(temp_str));
|
||||
subghz_test_decoder_count = 0;
|
||||
@@ -207,167 +208,166 @@ MU_TEST(subghz_keystore_test) {
|
||||
|
||||
MU_TEST(subghz_decoder_came_atomo_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/came_atomo_raw.sub", SUBGHZ_PROTOCOL_CAME_ATOMO_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_CAME_ATOMO_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_came_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test("/ext/unit_tests/subghz/came_raw.sub", SUBGHZ_PROTOCOL_CAME_NAME),
|
||||
subghz_decoder_test("/ext/unit_tests/subghz/came_raw.sub", SUBGHZ_PROTOCOL_CAME_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_CAME_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_came_twee_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/came_twee_raw.sub", SUBGHZ_PROTOCOL_CAME_TWEE_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_CAME_TWEE_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_faac_slh_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/faac_slh_raw.sub", SUBGHZ_PROTOCOL_FAAC_SLH_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_FAAC_SLH_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_gate_tx_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test("/ext/unit_tests/subghz/gate_tx_raw.sub", SUBGHZ_PROTOCOL_GATE_TX_NAME),
|
||||
subghz_decoder_test("/ext/unit_tests/subghz/gate_tx_raw.sub", SUBGHZ_PROTOCOL_GATE_TX_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_GATE_TX_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_hormann_hsm_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/hormann_hsm_raw.sub", SUBGHZ_PROTOCOL_HORMANN_HSM_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_HORMANN_HSM_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_ido_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test("/ext/unit_tests/subghz/ido_117_111_raw.sub", SUBGHZ_PROTOCOL_IDO_NAME),
|
||||
subghz_decoder_test("/ext/unit_tests/subghz/ido_117_111_raw.sub", SUBGHZ_PROTOCOL_IDO_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_IDO_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_keelog_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test("/ext/unit_tests/subghz/doorhan_raw.sub", SUBGHZ_PROTOCOL_KEELOQ_NAME),
|
||||
subghz_decoder_test("/ext/unit_tests/subghz/doorhan_raw.sub", SUBGHZ_PROTOCOL_KEELOQ_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_KEELOQ_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_kia_seed_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test("/ext/unit_tests/subghz/kia_seed_raw.sub", SUBGHZ_PROTOCOL_KIA_NAME),
|
||||
subghz_decoder_test("/ext/unit_tests/subghz/kia_seed_raw.sub", SUBGHZ_PROTOCOL_KIA_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_KIA_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_nero_radio_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/nero_radio_raw.sub", SUBGHZ_PROTOCOL_NERO_RADIO_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_NERO_RADIO_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_nero_sketch_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/nero_sketch_raw.sub", SUBGHZ_PROTOCOL_NERO_SKETCH_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_NERO_SKETCH_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_nice_flo_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/nice_flo_raw.sub", SUBGHZ_PROTOCOL_NICE_FLO_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_NICE_FLO_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_nice_flor_s_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/nice_flor_s_raw.sub", SUBGHZ_PROTOCOL_NICE_FLOR_S_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_NICE_FLOR_S_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_princeton_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/Princeton_raw.sub", SUBGHZ_PROTOCOL_PRINCETON_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_PRINCETON_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_scher_khan_magic_code_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/scher_khan_magic_code.sub", SUBGHZ_PROTOCOL_SCHER_KHAN_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_SCHER_KHAN_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_somfy_keytis_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/Somfy_keytis_raw.sub", SUBGHZ_PROTOCOL_SOMFY_KEYTIS_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_SOMFY_KEYTIS_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_somfy_telis_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/somfy_telis_raw.sub", SUBGHZ_PROTOCOL_SOMFY_TELIS_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_SOMFY_TELIS_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_star_line_test) {
|
||||
mu_assert(
|
||||
subghz_decode_test("/ext/unit_tests/subghz/cenmax_raw.sub", SUBGHZ_PROTOCOL_STAR_LINE_NAME),
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/cenmax_raw.sub", SUBGHZ_PROTOCOL_STAR_LINE_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_STAR_LINE_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_ecoder_princeton_test) {
|
||||
MU_TEST(subghz_encoder_princeton_test) {
|
||||
mu_assert(
|
||||
subghz_ecode_test("/ext/unit_tests/subghz/princeton.sub"),
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/princeton.sub"),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_PRINCETON_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_ecoder_came_test) {
|
||||
MU_TEST(subghz_encoder_came_test) {
|
||||
mu_assert(
|
||||
subghz_ecode_test("/ext/unit_tests/subghz/came.sub"),
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/came.sub"),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_CAME_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_ecoder_came_twee_test) {
|
||||
MU_TEST(subghz_encoder_came_twee_test) {
|
||||
mu_assert(
|
||||
subghz_ecode_test("/ext/unit_tests/subghz/came_twee.sub"),
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/came_twee.sub"),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_CAME_TWEE_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_ecoder_gate_tx_test) {
|
||||
MU_TEST(subghz_encoder_gate_tx_test) {
|
||||
mu_assert(
|
||||
subghz_ecode_test("/ext/unit_tests/subghz/gate_tx.sub"),
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/gate_tx.sub"),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_GATE_TX_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_ecoder_nice_flo_test) {
|
||||
MU_TEST(subghz_encoder_nice_flo_test) {
|
||||
mu_assert(
|
||||
subghz_ecode_test("/ext/unit_tests/subghz/nice_flo.sub"),
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/nice_flo.sub"),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_NICE_FLO_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_ecoder_keelog_test) {
|
||||
MU_TEST(subghz_encoder_keelog_test) {
|
||||
mu_assert(
|
||||
subghz_ecode_test("/ext/unit_tests/subghz/doorhan.sub"),
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/doorhan.sub"),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_KEELOQ_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_random_test) {
|
||||
mu_assert(subghz_decode_ramdom_test(TEST_RANDOM_DIR_NAME), "Random test error\r\n");
|
||||
mu_assert(subghz_decode_random_test(TEST_RANDOM_DIR_NAME), "Random test error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(subghz) {
|
||||
//MU_SUITE_CONFIGURE(&subghz_test_init, &subghz_test_deinit);
|
||||
|
||||
subghz_test_init();
|
||||
MU_RUN_TEST(subghz_keystore_test);
|
||||
|
||||
@@ -390,12 +390,12 @@ MU_TEST_SUITE(subghz) {
|
||||
MU_RUN_TEST(subghz_decoder_somfy_telis_test);
|
||||
MU_RUN_TEST(subghz_decoder_star_line_test);
|
||||
|
||||
MU_RUN_TEST(subghz_ecoder_princeton_test);
|
||||
MU_RUN_TEST(subghz_ecoder_came_test);
|
||||
MU_RUN_TEST(subghz_ecoder_came_twee_test);
|
||||
MU_RUN_TEST(subghz_ecoder_gate_tx_test);
|
||||
MU_RUN_TEST(subghz_ecoder_nice_flo_test);
|
||||
MU_RUN_TEST(subghz_ecoder_keelog_test);
|
||||
MU_RUN_TEST(subghz_encoder_princeton_test);
|
||||
MU_RUN_TEST(subghz_encoder_came_test);
|
||||
MU_RUN_TEST(subghz_encoder_came_twee_test);
|
||||
MU_RUN_TEST(subghz_encoder_gate_tx_test);
|
||||
MU_RUN_TEST(subghz_encoder_nice_flo_test);
|
||||
MU_RUN_TEST(subghz_encoder_keelog_test);
|
||||
|
||||
MU_RUN_TEST(subghz_random_test);
|
||||
subghz_test_deinit();
|
||||
|
Reference in New Issue
Block a user