[FL-2675] /int space reservation (#1448)
* storage: added global #defines for /int, /ext & /any * storage: introduced PATH_EXT, PATH_INT& PATH_ANY macros * core apps: moved hardcoded config files names to separate headers; prefixed them with "."; updater: added file name migration to new naming convention on backup extraction * storage: fixed storage_merge_recursive handling of complex directory structures; storage_move_to_sd: changed data migration logic to all non-dot files & all folders * core: added macro aliases for core record names * Bumped protobuf commit pointer * storage: reserved 5 pages in /int; denying write&creation of non-dot files when running out of free space Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -296,9 +296,9 @@ MU_TEST(flipper_format_string_test) {
|
||||
}
|
||||
|
||||
MU_TEST(flipper_format_file_test) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* flipper_format = flipper_format_file_alloc(storage);
|
||||
mu_check(flipper_format_file_open_always(flipper_format, "/ext/flipper.fff"));
|
||||
mu_check(flipper_format_file_open_always(flipper_format, EXT_PATH("flipper.fff")));
|
||||
Stream* stream = flipper_format_get_raw_stream(flipper_format);
|
||||
|
||||
mu_check(flipper_format_write_header_cstr(flipper_format, test_filetype, test_version));
|
||||
@@ -323,7 +323,7 @@ MU_TEST(flipper_format_file_test) {
|
||||
MU_RUN_TEST_1(flipper_format_read_and_update_test, flipper_format);
|
||||
|
||||
flipper_format_free(flipper_format);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(flipper_format_string_suite) {
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include "../minunit.h"
|
||||
|
||||
#define TEST_DIR TEST_DIR_NAME "/"
|
||||
#define TEST_DIR_NAME "/ext/unit_tests_tmp"
|
||||
#define TEST_DIR_NAME EXT_PATH("unit_tests_tmp")
|
||||
|
||||
static const char* test_filetype = "Flipper File test";
|
||||
static const uint32_t test_version = 666;
|
||||
@@ -66,7 +66,7 @@ static const char* test_file_windows = TEST_DIR READ_TEST_WIN;
|
||||
static const char* test_file_flipper = TEST_DIR READ_TEST_FLP;
|
||||
|
||||
static bool storage_write_string(const char* path, const char* data) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
File* file = storage_file_alloc(storage);
|
||||
bool result = false;
|
||||
|
||||
@@ -79,26 +79,26 @@ static bool storage_write_string(const char* path, const char* data) {
|
||||
|
||||
storage_file_close(file);
|
||||
storage_file_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void tests_setup() {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
mu_assert(storage_simply_remove_recursive(storage, TEST_DIR_NAME), "Cannot clean data");
|
||||
mu_assert(storage_simply_mkdir(storage, TEST_DIR_NAME), "Cannot create dir");
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static void tests_teardown() {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
mu_assert(storage_simply_remove_recursive(storage, TEST_DIR_NAME), "Cannot clean data");
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static bool test_read(const char* file_name) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
@@ -154,13 +154,13 @@ static bool test_read(const char* file_name) {
|
||||
|
||||
flipper_format_free(file);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool test_read_updated(const char* file_name) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
@@ -232,13 +232,13 @@ static bool test_read_updated(const char* file_name) {
|
||||
|
||||
flipper_format_free(file);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool test_write(const char* file_name) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
|
||||
@@ -264,13 +264,13 @@ static bool test_write(const char* file_name) {
|
||||
} while(false);
|
||||
|
||||
flipper_format_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool test_delete_last_key(const char* file_name) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
|
||||
@@ -281,13 +281,13 @@ static bool test_delete_last_key(const char* file_name) {
|
||||
} while(false);
|
||||
|
||||
flipper_format_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool test_append_key(const char* file_name) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
|
||||
@@ -299,13 +299,13 @@ static bool test_append_key(const char* file_name) {
|
||||
} while(false);
|
||||
|
||||
flipper_format_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool test_update(const char* file_name) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
|
||||
@@ -333,13 +333,13 @@ static bool test_update(const char* file_name) {
|
||||
} while(false);
|
||||
|
||||
flipper_format_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool test_update_backward(const char* file_name) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
|
||||
@@ -364,13 +364,13 @@ static bool test_update_backward(const char* file_name) {
|
||||
} while(false);
|
||||
|
||||
flipper_format_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool test_write_multikey(const char* file_name) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
|
||||
@@ -391,13 +391,13 @@ static bool test_write_multikey(const char* file_name) {
|
||||
} while(false);
|
||||
|
||||
flipper_format_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool test_read_multikey(const char* file_name) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
|
||||
@@ -432,7 +432,7 @@ static bool test_read_multikey(const char* file_name) {
|
||||
string_clear(string_value);
|
||||
|
||||
flipper_format_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include <common/infrared_common_i.h>
|
||||
#include "../minunit.h"
|
||||
|
||||
#define IR_TEST_FILES_DIR "/ext/unit_tests/infrared/"
|
||||
#define IR_TEST_FILES_DIR EXT_PATH("unit_tests/infrared/")
|
||||
#define IR_TEST_FILE_PREFIX "test_"
|
||||
#define IR_TEST_FILE_SUFFIX ".irtest"
|
||||
|
||||
@@ -18,7 +18,7 @@ typedef struct {
|
||||
static InfraredTest* test;
|
||||
|
||||
static void infrared_test_alloc() {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
test = malloc(sizeof(InfraredTest));
|
||||
test->decoder_handler = infrared_alloc_decoder();
|
||||
test->encoder_handler = infrared_alloc_encoder();
|
||||
@@ -32,7 +32,7 @@ static void infrared_test_free() {
|
||||
infrared_free_encoder(test->encoder_handler);
|
||||
flipper_format_free(test->ff);
|
||||
string_clear(test->file_path);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
free(test);
|
||||
test = NULL;
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@
|
||||
|
||||
#define TAG "NfcTest"
|
||||
|
||||
#define NFC_TEST_RESOURCES_DIR "/ext/unit_tests/nfc/"
|
||||
#define NFC_TEST_RESOURCES_DIR EXT_PATH("unit_tests/nfc/")
|
||||
#define NFC_TEST_SIGNAL_SHORT_FILE "nfc_nfca_signal_short.nfc"
|
||||
#define NFC_TEST_SIGNAL_LONG_FILE "nfc_nfca_signal_long.nfc"
|
||||
|
||||
@@ -36,13 +36,13 @@ static NfcTest* nfc_test = NULL;
|
||||
static void nfc_test_alloc() {
|
||||
nfc_test = malloc(sizeof(NfcTest));
|
||||
nfc_test->signal = nfca_signal_alloc();
|
||||
nfc_test->storage = furi_record_open("storage");
|
||||
nfc_test->storage = furi_record_open(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static void nfc_test_free() {
|
||||
furi_assert(nfc_test);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
nfca_signal_free(nfc_test->signal);
|
||||
free(nfc_test);
|
||||
nfc_test = NULL;
|
||||
|
@@ -47,7 +47,7 @@ static RpcSessionContext rpc_session[TEST_RPC_SESSIONS];
|
||||
#define MAX_NAME_LENGTH 255
|
||||
#define MAX_DATA_SIZE 512u // have to be exact as in rpc_storage.c
|
||||
#define TEST_DIR TEST_DIR_NAME "/"
|
||||
#define TEST_DIR_NAME "/ext/unit_tests_tmp"
|
||||
#define TEST_DIR_NAME EXT_PATH("unit_tests_tmp")
|
||||
#define MD5SUM_SIZE 16
|
||||
|
||||
#define PING_REQUEST 0
|
||||
@@ -83,7 +83,7 @@ static void test_rpc_setup(void) {
|
||||
furi_check(!rpc);
|
||||
furi_check(!(rpc_session[0].session));
|
||||
|
||||
rpc = furi_record_open("rpc");
|
||||
rpc = furi_record_open(RECORD_RPC);
|
||||
for(int i = 0; !(rpc_session[0].session) && (i < 10000); ++i) {
|
||||
rpc_session[0].session = rpc_session_open(rpc);
|
||||
furi_delay_tick(1);
|
||||
@@ -125,7 +125,7 @@ static void test_rpc_teardown(void) {
|
||||
xSemaphoreTake(rpc_session[0].terminate_semaphore, 0);
|
||||
rpc_session_close(rpc_session[0].session);
|
||||
furi_check(xSemaphoreTake(rpc_session[0].terminate_semaphore, portMAX_DELAY));
|
||||
furi_record_close("rpc");
|
||||
furi_record_close(RECORD_RPC);
|
||||
vStreamBufferDelete(rpc_session[0].output_stream);
|
||||
vSemaphoreDelete(rpc_session[0].close_session_semaphore);
|
||||
vSemaphoreDelete(rpc_session[0].terminate_semaphore);
|
||||
@@ -153,17 +153,17 @@ static void test_rpc_teardown_second_session(void) {
|
||||
static void test_rpc_storage_setup(void) {
|
||||
test_rpc_setup();
|
||||
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
clean_directory(fs_api, TEST_DIR_NAME);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static void test_rpc_storage_teardown(void) {
|
||||
test_rpc_teardown();
|
||||
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
clean_directory(fs_api, TEST_DIR_NAME);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static void test_rpc_session_close_callback(void* context) {
|
||||
@@ -571,7 +571,7 @@ static void test_rpc_storage_list_create_expected_list(
|
||||
MsgList_t msg_list,
|
||||
const char* path,
|
||||
uint32_t command_id) {
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
File* dir = storage_file_alloc(fs_api);
|
||||
|
||||
PB_Main response = {
|
||||
@@ -627,7 +627,7 @@ static void test_rpc_storage_list_create_expected_list(
|
||||
storage_dir_close(dir);
|
||||
storage_file_free(dir);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static void test_rpc_decode_and_compare(MsgList_t expected_msg_list, uint8_t session) {
|
||||
@@ -693,13 +693,13 @@ static void test_rpc_storage_list_run(const char* path, uint32_t command_id) {
|
||||
|
||||
MU_TEST(test_storage_list) {
|
||||
test_rpc_storage_list_run("/", ++command_id);
|
||||
test_rpc_storage_list_run("/ext/nfc", ++command_id);
|
||||
test_rpc_storage_list_run(EXT_PATH("nfc"), ++command_id);
|
||||
|
||||
test_rpc_storage_list_run("/int", ++command_id);
|
||||
test_rpc_storage_list_run("/ext", ++command_id);
|
||||
test_rpc_storage_list_run("/ext/infrared", ++command_id);
|
||||
test_rpc_storage_list_run("/ext/ibutton", ++command_id);
|
||||
test_rpc_storage_list_run("/ext/lfrfid", ++command_id);
|
||||
test_rpc_storage_list_run(STORAGE_INT_PATH_PREFIX, ++command_id);
|
||||
test_rpc_storage_list_run(STORAGE_EXT_PATH_PREFIX, ++command_id);
|
||||
test_rpc_storage_list_run(EXT_PATH("infrared"), ++command_id);
|
||||
test_rpc_storage_list_run(EXT_PATH("ibutton"), ++command_id);
|
||||
test_rpc_storage_list_run(EXT_PATH("lfrfid"), ++command_id);
|
||||
test_rpc_storage_list_run("error_path", ++command_id);
|
||||
}
|
||||
|
||||
@@ -718,7 +718,7 @@ static void test_rpc_add_read_to_list_by_reading_real_file(
|
||||
const char* path,
|
||||
uint32_t command_id) {
|
||||
furi_check(MsgList_empty_p(msg_list));
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
File* file = storage_file_alloc(fs_api);
|
||||
|
||||
bool result = false;
|
||||
@@ -759,7 +759,7 @@ static void test_rpc_add_read_to_list_by_reading_real_file(
|
||||
storage_file_close(file);
|
||||
storage_file_free(file);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static void test_storage_read_run(const char* path, uint32_t command_id) {
|
||||
@@ -777,25 +777,25 @@ static void test_storage_read_run(const char* path, uint32_t command_id) {
|
||||
}
|
||||
|
||||
static bool test_is_exists(const char* path) {
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
FileInfo fileinfo;
|
||||
FS_Error result = storage_common_stat(fs_api, path, &fileinfo);
|
||||
furi_check((result == FSE_OK) || (result == FSE_NOT_EXIST));
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
return result == FSE_OK;
|
||||
}
|
||||
|
||||
static void test_create_dir(const char* path) {
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
FS_Error error = storage_common_mkdir(fs_api, path);
|
||||
(void)error;
|
||||
furi_check((error == FSE_OK) || (error == FSE_EXIST));
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
furi_check(test_is_exists(path));
|
||||
}
|
||||
|
||||
static void test_create_file(const char* path, size_t size) {
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
File* file = storage_file_alloc(fs_api);
|
||||
|
||||
if(storage_file_open(file, path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
|
||||
@@ -813,7 +813,7 @@ static void test_create_file(const char* path, size_t size) {
|
||||
storage_file_close(file);
|
||||
storage_file_free(file);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
furi_check(test_is_exists(path));
|
||||
}
|
||||
|
||||
@@ -827,7 +827,7 @@ static void test_rpc_storage_info_run(const char* path, uint32_t command_id) {
|
||||
PB_Main* response = MsgList_push_new(expected_msg_list);
|
||||
response->command_id = command_id;
|
||||
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
FS_Error error = storage_common_fs_info(
|
||||
fs_api,
|
||||
@@ -856,10 +856,10 @@ static void test_rpc_storage_stat_run(const char* path, uint32_t command_id) {
|
||||
|
||||
test_rpc_create_simple_message(&request, PB_Main_storage_stat_request_tag, path, command_id);
|
||||
|
||||
Storage* fs_api = furi_record_open("storage");
|
||||
Storage* fs_api = furi_record_open(RECORD_STORAGE);
|
||||
FileInfo fileinfo;
|
||||
FS_Error error = storage_common_stat(fs_api, path, &fileinfo);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
PB_Main* response = MsgList_push_new(expected_msg_list);
|
||||
response->command_id = command_id;
|
||||
@@ -884,9 +884,9 @@ static void test_rpc_storage_stat_run(const char* path, uint32_t command_id) {
|
||||
}
|
||||
|
||||
MU_TEST(test_storage_info) {
|
||||
test_rpc_storage_info_run("/any", ++command_id);
|
||||
test_rpc_storage_info_run("/int", ++command_id);
|
||||
test_rpc_storage_info_run("/ext", ++command_id);
|
||||
test_rpc_storage_info_run(STORAGE_ANY_PATH_PREFIX, ++command_id);
|
||||
test_rpc_storage_info_run(STORAGE_INT_PATH_PREFIX, ++command_id);
|
||||
test_rpc_storage_info_run(STORAGE_EXT_PATH_PREFIX, ++command_id);
|
||||
}
|
||||
|
||||
#define TEST_DIR_STAT_NAME TEST_DIR "stat_dir"
|
||||
@@ -897,8 +897,8 @@ MU_TEST(test_storage_stat) {
|
||||
test_create_file(TEST_DIR_STAT "l33t.txt", 1337);
|
||||
|
||||
test_rpc_storage_stat_run("/", ++command_id);
|
||||
test_rpc_storage_stat_run("/int", ++command_id);
|
||||
test_rpc_storage_stat_run("/ext", ++command_id);
|
||||
test_rpc_storage_stat_run(STORAGE_INT_PATH_PREFIX, ++command_id);
|
||||
test_rpc_storage_stat_run(STORAGE_EXT_PATH_PREFIX, ++command_id);
|
||||
|
||||
test_rpc_storage_stat_run(TEST_DIR_STAT "empty.txt", ++command_id);
|
||||
test_rpc_storage_stat_run(TEST_DIR_STAT "l33t.txt", ++command_id);
|
||||
@@ -1225,7 +1225,7 @@ MU_TEST(test_storage_mkdir) {
|
||||
}
|
||||
|
||||
static void test_storage_calculate_md5sum(const char* path, char* md5sum) {
|
||||
Storage* api = furi_record_open("storage");
|
||||
Storage* api = furi_record_open(RECORD_STORAGE);
|
||||
File* file = storage_file_alloc(api);
|
||||
|
||||
if(storage_file_open(file, path, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
@@ -1257,7 +1257,7 @@ static void test_storage_calculate_md5sum(const char* path, char* md5sum) {
|
||||
storage_file_close(file);
|
||||
storage_file_free(file);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static void test_storage_md5sum_run(
|
||||
@@ -1516,7 +1516,8 @@ static void test_app_get_status_lock_run(bool locked_expected, uint32_t command_
|
||||
|
||||
MU_TEST(test_app_start_and_lock_status) {
|
||||
test_app_get_status_lock_run(false, ++command_id);
|
||||
test_app_start_run(NULL, "/ext/file", PB_CommandStatus_ERROR_INVALID_PARAMETERS, ++command_id);
|
||||
test_app_start_run(
|
||||
NULL, EXT_PATH("file"), PB_CommandStatus_ERROR_INVALID_PARAMETERS, ++command_id);
|
||||
test_app_start_run(NULL, NULL, PB_CommandStatus_ERROR_INVALID_PARAMETERS, ++command_id);
|
||||
test_app_get_status_lock_run(false, ++command_id);
|
||||
test_app_start_run(
|
||||
@@ -1765,23 +1766,23 @@ MU_TEST_SUITE(test_rpc_session) {
|
||||
MU_RUN_TEST(test_rpc_feed_rubbish);
|
||||
MU_RUN_TEST(test_rpc_multisession_ping);
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
if(storage_sd_status(storage) != FSE_OK) {
|
||||
FURI_LOG_E(TAG, "SD card not mounted - skip storage tests");
|
||||
} else {
|
||||
MU_RUN_TEST(test_rpc_multisession_storage);
|
||||
}
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
int run_minunit_test_rpc() {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
if(storage_sd_status(storage) != FSE_OK) {
|
||||
FURI_LOG_E(TAG, "SD card not mounted - skip storage tests");
|
||||
} else {
|
||||
MU_RUN_SUITE(test_rpc_storage);
|
||||
}
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
MU_RUN_SUITE(test_rpc_system);
|
||||
MU_RUN_SUITE(test_rpc_app);
|
||||
MU_RUN_SUITE(test_rpc_session);
|
||||
|
@@ -175,10 +175,10 @@ MU_TEST_1(test_dirwalk_full, Storage* storage) {
|
||||
storage_test_paths_alloc(storage_test_dirwalk_full, COUNT_OF(storage_test_dirwalk_full));
|
||||
|
||||
DirWalk* dir_walk = dir_walk_alloc(storage);
|
||||
mu_check(dir_walk_open(dir_walk, "/ext/dirwalk"));
|
||||
mu_check(dir_walk_open(dir_walk, EXT_PATH("dirwalk")));
|
||||
|
||||
while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
|
||||
string_right(path, strlen("/ext/dirwalk/"));
|
||||
string_right(path, strlen(EXT_PATH("dirwalk/")));
|
||||
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
|
||||
}
|
||||
|
||||
@@ -200,10 +200,10 @@ MU_TEST_1(test_dirwalk_no_recursive, Storage* storage) {
|
||||
|
||||
DirWalk* dir_walk = dir_walk_alloc(storage);
|
||||
dir_walk_set_recursive(dir_walk, false);
|
||||
mu_check(dir_walk_open(dir_walk, "/ext/dirwalk"));
|
||||
mu_check(dir_walk_open(dir_walk, EXT_PATH("dirwalk")));
|
||||
|
||||
while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
|
||||
string_right(path, strlen("/ext/dirwalk/"));
|
||||
string_right(path, strlen(EXT_PATH("dirwalk/")));
|
||||
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
|
||||
}
|
||||
|
||||
@@ -239,10 +239,10 @@ MU_TEST_1(test_dirwalk_filter, Storage* storage) {
|
||||
|
||||
DirWalk* dir_walk = dir_walk_alloc(storage);
|
||||
dir_walk_set_filter_cb(dir_walk, test_dirwalk_filter_no_folder_ext, NULL);
|
||||
mu_check(dir_walk_open(dir_walk, "/ext/dirwalk"));
|
||||
mu_check(dir_walk_open(dir_walk, EXT_PATH("dirwalk")));
|
||||
|
||||
while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
|
||||
string_right(path, strlen("/ext/dirwalk/"));
|
||||
string_right(path, strlen(EXT_PATH("dirwalk/")));
|
||||
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
|
||||
}
|
||||
|
||||
@@ -255,15 +255,15 @@ MU_TEST_1(test_dirwalk_filter, Storage* storage) {
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(test_dirwalk_suite) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
storage_dirs_create(storage, "/ext/dirwalk");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_dirs_create(storage, EXT_PATH("dirwalk"));
|
||||
|
||||
MU_RUN_TEST_1(test_dirwalk_full, storage);
|
||||
MU_RUN_TEST_1(test_dirwalk_no_recursive, storage);
|
||||
MU_RUN_TEST_1(test_dirwalk_filter, storage);
|
||||
|
||||
storage_simply_remove_recursive(storage, "/ext/dirwalk");
|
||||
furi_record_close("storage");
|
||||
storage_simply_remove_recursive(storage, EXT_PATH("dirwalk"));
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
int run_minunit_test_dirwalk() {
|
||||
|
@@ -2,28 +2,28 @@
|
||||
#include <furi.h>
|
||||
#include <storage/storage.h>
|
||||
|
||||
#define STORAGE_LOCKED_FILE "/ext/locked_file.test"
|
||||
#define STORAGE_LOCKED_DIR "/int"
|
||||
#define STORAGE_LOCKED_FILE EXT_PATH("locked_file.test")
|
||||
#define STORAGE_LOCKED_DIR STORAGE_INT_PATH_PREFIX
|
||||
|
||||
static void storage_file_open_lock_setup() {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
File* file = storage_file_alloc(storage);
|
||||
storage_simply_remove(storage, STORAGE_LOCKED_FILE);
|
||||
mu_check(storage_file_open(file, STORAGE_LOCKED_FILE, FSAM_WRITE, FSOM_CREATE_NEW));
|
||||
mu_check(storage_file_write(file, "0123", 4) == 4);
|
||||
mu_check(storage_file_close(file));
|
||||
storage_file_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static void storage_file_open_lock_teardown() {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
mu_check(storage_simply_remove(storage, STORAGE_LOCKED_FILE));
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static int32_t storage_file_locker(void* ctx) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FuriSemaphore* semaphore = ctx;
|
||||
File* file = storage_file_alloc(storage);
|
||||
furi_check(storage_file_open(file, STORAGE_LOCKED_FILE, FSAM_READ_WRITE, FSOM_OPEN_EXISTING));
|
||||
@@ -31,13 +31,13 @@ static int32_t storage_file_locker(void* ctx) {
|
||||
furi_delay_ms(1000);
|
||||
|
||||
furi_check(storage_file_close(file));
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
storage_file_free(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MU_TEST(storage_file_open_lock) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
FuriSemaphore* semaphore = furi_semaphore_alloc(1, 0);
|
||||
File* file = storage_file_alloc(storage);
|
||||
@@ -63,13 +63,13 @@ MU_TEST(storage_file_open_lock) {
|
||||
|
||||
// clean data
|
||||
storage_file_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
mu_assert(result, "cannot open locked file");
|
||||
}
|
||||
|
||||
MU_TEST(storage_file_open_close) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
File* file;
|
||||
|
||||
file = storage_file_alloc(storage);
|
||||
@@ -84,7 +84,7 @@ MU_TEST(storage_file_open_close) {
|
||||
storage_file_free(file);
|
||||
}
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(storage_file) {
|
||||
@@ -95,7 +95,7 @@ MU_TEST_SUITE(storage_file) {
|
||||
}
|
||||
|
||||
MU_TEST(storage_dir_open_close) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
File* file;
|
||||
|
||||
file = storage_file_alloc(storage);
|
||||
@@ -109,11 +109,11 @@ MU_TEST(storage_dir_open_close) {
|
||||
storage_file_free(file);
|
||||
}
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
static int32_t storage_dir_locker(void* ctx) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FuriSemaphore* semaphore = ctx;
|
||||
File* file = storage_file_alloc(storage);
|
||||
furi_check(storage_dir_open(file, STORAGE_LOCKED_DIR));
|
||||
@@ -121,13 +121,13 @@ static int32_t storage_dir_locker(void* ctx) {
|
||||
furi_delay_ms(1000);
|
||||
|
||||
furi_check(storage_dir_close(file));
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
storage_file_free(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MU_TEST(storage_dir_open_lock) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
bool result = false;
|
||||
FuriSemaphore* semaphore = furi_semaphore_alloc(1, 0);
|
||||
File* file = storage_file_alloc(storage);
|
||||
@@ -153,7 +153,7 @@ MU_TEST(storage_dir_open_lock) {
|
||||
|
||||
// clean data
|
||||
storage_file_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
mu_assert(result, "cannot open locked dir");
|
||||
}
|
||||
@@ -265,46 +265,48 @@ static bool storage_dir_rename_check(Storage* storage, const char* base) {
|
||||
}
|
||||
|
||||
MU_TEST(storage_file_rename) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
File* file = storage_file_alloc(storage);
|
||||
|
||||
mu_check(write_file_13DA(storage, "/ext/file.old"));
|
||||
mu_check(check_file_13DA(storage, "/ext/file.old"));
|
||||
mu_assert_int_eq(FSE_OK, storage_common_rename(storage, "/ext/file.old", "/ext/file.new"));
|
||||
mu_assert_int_eq(FSE_NOT_EXIST, storage_common_stat(storage, "/ext/file.old", NULL));
|
||||
mu_assert_int_eq(FSE_OK, storage_common_stat(storage, "/ext/file.new", NULL));
|
||||
mu_check(check_file_13DA(storage, "/ext/file.new"));
|
||||
mu_assert_int_eq(FSE_OK, storage_common_remove(storage, "/ext/file.new"));
|
||||
mu_check(write_file_13DA(storage, EXT_PATH("file.old")));
|
||||
mu_check(check_file_13DA(storage, EXT_PATH("file.old")));
|
||||
mu_assert_int_eq(
|
||||
FSE_OK, storage_common_rename(storage, EXT_PATH("file.old"), EXT_PATH("file.new")));
|
||||
mu_assert_int_eq(FSE_NOT_EXIST, storage_common_stat(storage, EXT_PATH("file.old"), NULL));
|
||||
mu_assert_int_eq(FSE_OK, storage_common_stat(storage, EXT_PATH("file.new"), NULL));
|
||||
mu_check(check_file_13DA(storage, EXT_PATH("file.new")));
|
||||
mu_assert_int_eq(FSE_OK, storage_common_remove(storage, EXT_PATH("file.new")));
|
||||
|
||||
storage_file_free(file);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
MU_TEST(storage_dir_rename) {
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
storage_dir_create(storage, "/ext/dir.old");
|
||||
storage_dir_create(storage, EXT_PATH("dir.old"));
|
||||
|
||||
mu_check(storage_dir_rename_check(storage, "/ext/dir.old"));
|
||||
mu_check(storage_dir_rename_check(storage, EXT_PATH("dir.old")));
|
||||
|
||||
mu_assert_int_eq(FSE_OK, storage_common_rename(storage, "/ext/dir.old", "/ext/dir.new"));
|
||||
mu_assert_int_eq(FSE_NOT_EXIST, storage_common_stat(storage, "/ext/dir.old", NULL));
|
||||
mu_check(storage_dir_rename_check(storage, "/ext/dir.new"));
|
||||
mu_assert_int_eq(
|
||||
FSE_OK, storage_common_rename(storage, EXT_PATH("dir.old"), EXT_PATH("dir.new")));
|
||||
mu_assert_int_eq(FSE_NOT_EXIST, storage_common_stat(storage, EXT_PATH("dir.old"), NULL));
|
||||
mu_check(storage_dir_rename_check(storage, EXT_PATH("dir.new")));
|
||||
|
||||
storage_dir_remove(storage, "/ext/dir.new");
|
||||
mu_assert_int_eq(FSE_NOT_EXIST, storage_common_stat(storage, "/ext/dir.new", NULL));
|
||||
storage_dir_remove(storage, EXT_PATH("dir.new"));
|
||||
mu_assert_int_eq(FSE_NOT_EXIST, storage_common_stat(storage, EXT_PATH("dir.new"), NULL));
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(storage_rename) {
|
||||
MU_RUN_TEST(storage_file_rename);
|
||||
MU_RUN_TEST(storage_dir_rename);
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
storage_dir_remove(storage, "/ext/dir.old");
|
||||
storage_dir_remove(storage, "/ext/dir.new");
|
||||
furi_record_close("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_dir_remove(storage, EXT_PATH("dir.old"));
|
||||
storage_dir_remove(storage, EXT_PATH("dir.new"));
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
int run_minunit_test_storage() {
|
||||
|
@@ -278,19 +278,20 @@ MU_TEST(stream_composite_test) {
|
||||
stream_free(stream);
|
||||
|
||||
// test file stream
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
stream = file_stream_alloc(storage);
|
||||
mu_check(file_stream_open(stream, "/ext/filestream.str", FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
|
||||
mu_check(
|
||||
file_stream_open(stream, EXT_PATH("filestream.str"), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
|
||||
MU_RUN_TEST_1(stream_composite_subtest, stream);
|
||||
stream_free(stream);
|
||||
|
||||
// test buffered file stream
|
||||
stream = buffered_file_stream_alloc(storage);
|
||||
mu_check(buffered_file_stream_open(
|
||||
stream, "/ext/filestream.str", FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
|
||||
stream, EXT_PATH("filestream.str"), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
|
||||
MU_RUN_TEST_1(stream_composite_subtest, stream);
|
||||
stream_free(stream);
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
MU_TEST_1(stream_write_subtest, Stream* stream) {
|
||||
@@ -307,7 +308,7 @@ MU_TEST_1(stream_read_subtest, Stream* stream) {
|
||||
MU_TEST(stream_write_read_save_load_test) {
|
||||
Stream* stream_orig = string_stream_alloc();
|
||||
Stream* stream_copy = string_stream_alloc();
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
// write, read
|
||||
MU_RUN_TEST_1(stream_write_subtest, stream_orig);
|
||||
@@ -321,7 +322,7 @@ MU_TEST(stream_write_read_save_load_test) {
|
||||
mu_check(stream_seek(stream_orig, 0, StreamOffsetFromStart));
|
||||
mu_assert_int_eq(
|
||||
strlen(stream_test_data),
|
||||
stream_save_to_file(stream_orig, storage, "/ext/filestream.str", FSOM_CREATE_ALWAYS));
|
||||
stream_save_to_file(stream_orig, storage, EXT_PATH("filestream.str"), FSOM_CREATE_ALWAYS));
|
||||
|
||||
stream_free(stream_copy);
|
||||
stream_free(stream_orig);
|
||||
@@ -330,11 +331,11 @@ MU_TEST(stream_write_read_save_load_test) {
|
||||
Stream* stream_new = string_stream_alloc();
|
||||
mu_assert_int_eq(
|
||||
strlen(stream_test_data),
|
||||
stream_load_from_file(stream_new, storage, "/ext/filestream.str"));
|
||||
stream_load_from_file(stream_new, storage, EXT_PATH("filestream.str")));
|
||||
MU_RUN_TEST_1(stream_read_subtest, stream_new);
|
||||
stream_free(stream_new);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
MU_TEST_1(stream_split_subtest, Stream* stream) {
|
||||
@@ -369,20 +370,21 @@ MU_TEST(stream_split_test) {
|
||||
stream_free(stream);
|
||||
|
||||
// test file stream
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
stream = file_stream_alloc(storage);
|
||||
mu_check(file_stream_open(stream, "/ext/filestream.str", FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
|
||||
mu_check(
|
||||
file_stream_open(stream, EXT_PATH("filestream.str"), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
|
||||
MU_RUN_TEST_1(stream_split_subtest, stream);
|
||||
stream_free(stream);
|
||||
|
||||
// test buffered stream
|
||||
stream = buffered_file_stream_alloc(storage);
|
||||
mu_check(buffered_file_stream_open(
|
||||
stream, "/ext/filestream.str", FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
|
||||
stream, EXT_PATH("filestream.str"), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
|
||||
MU_RUN_TEST_1(stream_split_subtest, stream);
|
||||
stream_free(stream);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
MU_TEST(stream_buffered_large_file_test) {
|
||||
@@ -391,7 +393,7 @@ MU_TEST(stream_buffered_large_file_test) {
|
||||
string_init(input_data);
|
||||
string_init(output_data);
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
// generate test data consisting of several identical lines
|
||||
const size_t data_size = 4096;
|
||||
@@ -405,7 +407,7 @@ MU_TEST(stream_buffered_large_file_test) {
|
||||
// write test data to file
|
||||
Stream* stream = buffered_file_stream_alloc(storage);
|
||||
mu_check(buffered_file_stream_open(
|
||||
stream, "/ext/filestream.str", FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
|
||||
stream, EXT_PATH("filestream.str"), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS));
|
||||
mu_assert_int_eq(0, stream_size(stream));
|
||||
mu_assert_int_eq(string_size(input_data), stream_write_string(stream, input_data));
|
||||
mu_assert_int_eq(string_size(input_data), stream_size(stream));
|
||||
@@ -459,7 +461,7 @@ MU_TEST(stream_buffered_large_file_test) {
|
||||
|
||||
stream_free(stream);
|
||||
|
||||
furi_record_close("storage");
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
string_clear(input_data);
|
||||
string_clear(output_data);
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@
|
||||
#include <flipper_format/flipper_format_i.h>
|
||||
|
||||
#define TAG "SubGhz TEST"
|
||||
#define KEYSTORE_DIR_NAME "/ext/subghz/assets/keeloq_mfcodes"
|
||||
#define CAME_ATOMO_DIR_NAME "/ext/subghz/assets/came_atomo"
|
||||
#define NICE_FLOR_S_DIR_NAME "/ext/subghz/assets/nice_flor_s"
|
||||
#define TEST_RANDOM_DIR_NAME "/ext/unit_tests/subghz/test_random_raw.sub"
|
||||
#define KEYSTORE_DIR_NAME EXT_PATH("subghz/assets/keeloq_mfcodes")
|
||||
#define CAME_ATOMO_DIR_NAME EXT_PATH("subghz/assets/came_atomo")
|
||||
#define NICE_FLOR_S_DIR_NAME EXT_PATH("subghz/assets/nice_flor_s")
|
||||
#define TEST_RANDOM_DIR_NAME EXT_PATH("unit_tests/subghz/test_random_raw.sub")
|
||||
#define TEST_RANDOM_COUNT_PARSE 119
|
||||
#define TEST_TIMEOUT 10000
|
||||
|
||||
@@ -145,7 +145,7 @@ static bool subghz_encoder_test(const char* path) {
|
||||
string_init(temp_str);
|
||||
bool file_load = false;
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
||||
|
||||
do {
|
||||
@@ -210,234 +210,243 @@ MU_TEST(subghz_keystore_test) {
|
||||
MU_TEST(subghz_decoder_came_atomo_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/came_atomo_raw.sub", SUBGHZ_PROTOCOL_CAME_ATOMO_NAME),
|
||||
EXT_PATH("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_decoder_test("/ext/unit_tests/subghz/came_raw.sub", SUBGHZ_PROTOCOL_CAME_NAME),
|
||||
subghz_decoder_test(EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/came_twee_raw.sub", SUBGHZ_PROTOCOL_CAME_TWEE_NAME),
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/faac_slh_raw.sub", SUBGHZ_PROTOCOL_FAAC_SLH_NAME),
|
||||
EXT_PATH("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_decoder_test("/ext/unit_tests/subghz/gate_tx_raw.sub", SUBGHZ_PROTOCOL_GATE_TX_NAME),
|
||||
subghz_decoder_test(
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/hormann_hsm_raw.sub", SUBGHZ_PROTOCOL_HORMANN_HSM_NAME),
|
||||
EXT_PATH("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_decoder_test("/ext/unit_tests/subghz/ido_117_111_raw.sub", SUBGHZ_PROTOCOL_IDO_NAME),
|
||||
subghz_decoder_test(
|
||||
EXT_PATH("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_decoder_test("/ext/unit_tests/subghz/doorhan_raw.sub", SUBGHZ_PROTOCOL_KEELOQ_NAME),
|
||||
subghz_decoder_test(
|
||||
EXT_PATH("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_decoder_test("/ext/unit_tests/subghz/kia_seed_raw.sub", SUBGHZ_PROTOCOL_KIA_NAME),
|
||||
subghz_decoder_test(
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/nero_radio_raw.sub", SUBGHZ_PROTOCOL_NERO_RADIO_NAME),
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/nero_sketch_raw.sub", SUBGHZ_PROTOCOL_NERO_SKETCH_NAME),
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/nice_flo_raw.sub", SUBGHZ_PROTOCOL_NICE_FLO_NAME),
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/nice_flor_s_raw.sub", SUBGHZ_PROTOCOL_NICE_FLOR_S_NAME),
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/Princeton_raw.sub", SUBGHZ_PROTOCOL_PRINCETON_NAME),
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/scher_khan_magic_code.sub", SUBGHZ_PROTOCOL_SCHER_KHAN_NAME),
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/Somfy_keytis_raw.sub", SUBGHZ_PROTOCOL_SOMFY_KEYTIS_NAME),
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/somfy_telis_raw.sub", SUBGHZ_PROTOCOL_SOMFY_TELIS_NAME),
|
||||
EXT_PATH("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_decoder_test(
|
||||
"/ext/unit_tests/subghz/cenmax_raw.sub", SUBGHZ_PROTOCOL_STAR_LINE_NAME),
|
||||
EXT_PATH("unit_tests/subghz/cenmax_raw.sub"), SUBGHZ_PROTOCOL_STAR_LINE_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_STAR_LINE_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_linear_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test("/ext/unit_tests/subghz/linear_raw.sub", SUBGHZ_PROTOCOL_LINEAR_NAME),
|
||||
subghz_decoder_test(
|
||||
EXT_PATH("unit_tests/subghz/linear_raw.sub"), SUBGHZ_PROTOCOL_LINEAR_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_LINEAR_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_megacode_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/megacode_raw.sub", SUBGHZ_PROTOCOL_MEGACODE_NAME),
|
||||
EXT_PATH("unit_tests/subghz/megacode_raw.sub"), SUBGHZ_PROTOCOL_MEGACODE_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_MEGACODE_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_secplus_v1_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/security_pls_1_0_raw.sub", SUBGHZ_PROTOCOL_SECPLUS_V1_NAME),
|
||||
EXT_PATH("unit_tests/subghz/security_pls_1_0_raw.sub"),
|
||||
SUBGHZ_PROTOCOL_SECPLUS_V1_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_SECPLUS_V1_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_secplus_v2_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/security_pls_2_0_raw.sub", SUBGHZ_PROTOCOL_SECPLUS_V2_NAME),
|
||||
EXT_PATH("unit_tests/subghz/security_pls_2_0_raw.sub"),
|
||||
SUBGHZ_PROTOCOL_SECPLUS_V2_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_SECPLUS_V2_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_holtek_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test("/ext/unit_tests/subghz/holtek_raw.sub", SUBGHZ_PROTOCOL_HOLTEK_NAME),
|
||||
subghz_decoder_test(
|
||||
EXT_PATH("unit_tests/subghz/holtek_raw.sub"), SUBGHZ_PROTOCOL_HOLTEK_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_HOLTEK_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_decoder_power_smart_test) {
|
||||
mu_assert(
|
||||
subghz_decoder_test(
|
||||
"/ext/unit_tests/subghz/power_smart_raw.sub", SUBGHZ_PROTOCOL_POWER_SMART_NAME),
|
||||
EXT_PATH("unit_tests/subghz/power_smart_raw.sub"), SUBGHZ_PROTOCOL_POWER_SMART_NAME),
|
||||
"Test decoder " SUBGHZ_PROTOCOL_POWER_SMART_NAME " error\r\n");
|
||||
}
|
||||
|
||||
//test encoders
|
||||
MU_TEST(subghz_encoder_princeton_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/princeton.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/princeton.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_PRINCETON_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_came_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/came.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/came.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_CAME_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_came_twee_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/came_twee.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/came_twee.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_CAME_TWEE_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_gate_tx_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/gate_tx.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/gate_tx.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_GATE_TX_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_nice_flo_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/nice_flo.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/nice_flo.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_NICE_FLO_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_keelog_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/doorhan.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/doorhan.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_KEELOQ_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_linear_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/linear.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/linear.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_LINEAR_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_megacode_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/megacode.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/megacode.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_MEGACODE_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_holtek_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/holtek.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/holtek.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_HOLTEK_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_secplus_v1_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/security_pls_1_0.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/security_pls_1_0.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_SECPLUS_V1_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_secplus_v2_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/security_pls_2_0.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/security_pls_2_0.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_SECPLUS_V2_NAME " error\r\n");
|
||||
}
|
||||
|
||||
MU_TEST(subghz_encoder_power_smart_test) {
|
||||
mu_assert(
|
||||
subghz_encoder_test("/ext/unit_tests/subghz/power_smart.sub"),
|
||||
subghz_encoder_test(EXT_PATH("unit_tests/subghz/power_smart.sub")),
|
||||
"Test encoder " SUBGHZ_PROTOCOL_POWER_SMART_NAME " error\r\n");
|
||||
}
|
||||
|
||||
|
@@ -67,8 +67,8 @@ void unit_tests_cli(Cli* cli, string_t args, void* context) {
|
||||
minunit_fail = 0;
|
||||
minunit_status = 0;
|
||||
|
||||
Loader* loader = furi_record_open("loader");
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
Loader* loader = furi_record_open(RECORD_LOADER);
|
||||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
|
||||
// TODO: lock device while test running
|
||||
if(loader_is_locked(loader)) {
|
||||
@@ -116,16 +116,16 @@ void unit_tests_cli(Cli* cli, string_t args, void* context) {
|
||||
}
|
||||
}
|
||||
|
||||
furi_record_close("notification");
|
||||
furi_record_close("loader");
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
furi_record_close(RECORD_LOADER);
|
||||
}
|
||||
|
||||
void unit_tests_on_system_start() {
|
||||
#ifdef SRV_CLI
|
||||
Cli* cli = furi_record_open("cli");
|
||||
Cli* cli = furi_record_open(RECORD_CLI);
|
||||
|
||||
// We need to launch apps from tests, so we cannot lock loader
|
||||
cli_add_command(cli, "unit_tests", CliCommandFlagParallelSafe, unit_tests_cli, NULL);
|
||||
furi_record_close("cli");
|
||||
furi_record_close(RECORD_CLI);
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user