diff --git a/apps/examples/kernel_update_test/kernel_update_test_main.c b/apps/examples/kernel_update_test/kernel_update_test_main.c index a97fa892e7..e182b275fd 100644 --- a/apps/examples/kernel_update_test/kernel_update_test_main.c +++ b/apps/examples/kernel_update_test/kernel_update_test_main.c @@ -45,10 +45,22 @@ /* Kernel binary information for update test */ #define KERNEL "kernel" -/* Common/app1 binary names for testing */ -/* Kernel / Common / App1 binary must be set at once */ +/* Common/app1/app2 binary names for testing */ +/* Kernel / Common / App1 / App2 binary must be set at once */ #define COMMON "common" #define APP1 "app1" +#define APP2 "app2" + +#ifdef CONFIG_SUPPORT_COMMON_BINARY +char *bin_names[] = {KERNEL, COMMON, APP1}; +uint8_t bin_types[] = {BINARY_KERNEL, BINARY_COMMON, BINARY_USERAPP}; +#else +char *bin_names[] = {KERNEL, APP1, APP2}; +uint8_t bin_types[] = {BINARY_KERNEL, BINARY_USERAPP, BINARY_USERAPP}; +#endif + +int bin_count = sizeof(bin_names) / sizeof(bin_names[0]); + #define DOWNLOAD_VALID_BIN 0 #define DOWNLOAD_INVALID_BIN 1 @@ -410,9 +422,6 @@ static int binary_update_same_version_test(void) int ret; binary_update_info_t pre_bin_info[3]; binary_update_info_t cur_bin_info[3]; - char *bin_names[] = {KERNEL, COMMON, APP1}; - uint8_t bin_types[] = {BINARY_KERNEL, BINARY_COMMON, BINARY_USERAPP}; - int bin_count = sizeof(bin_names) / sizeof(bin_names[0]); int i; update_type_flag = 0; @@ -468,9 +477,6 @@ static int binary_update_new_version_test(void) int ret; binary_update_info_t pre_bin_info[3]; binary_update_info_t cur_bin_info[3]; - char *bin_names[] = {KERNEL, COMMON, APP1}; - uint8_t bin_types[] = {BINARY_KERNEL, BINARY_COMMON, BINARY_USERAPP}; - int bin_count = sizeof(bin_names) / sizeof(bin_names[0]); int i; update_type_flag = 0; @@ -530,9 +536,6 @@ static int binary_update_invalid_binary_test(void) int ret; binary_update_info_t pre_bin_info[3]; binary_update_info_t cur_bin_info[3]; - char *bin_names[] = {KERNEL, COMMON, APP1}; - uint8_t bin_types[] = {BINARY_KERNEL, BINARY_COMMON, BINARY_USERAPP}; - int bin_count = sizeof(bin_names) / sizeof(bin_names[0]); int i; update_type_flag = 0; @@ -619,6 +622,16 @@ static int binary_update_run_tests(void) return OK; } +static void show_usage(void) +{ + printf("Usage: kernel_update \n"); + printf("Available test types:\n"); + printf(" all - Run all tests\n"); + printf(" same_version - Run same version test\n"); + printf(" new_version - Run new version test\n"); + printf(" invalid - Run invalid binary test\n"); +} + /**************************************************************************** * binary_update_aging_test ****************************************************************************/ @@ -628,5 +641,39 @@ int main(int argc, FAR char *argv[]) int kernel_update_main(int argc, char *argv[]) #endif { - binary_update_run_tests(); + if (argc == 2 && !strncmp(argv[1], "all", 4)) { + /* Run all tests */ + return binary_update_run_tests(); + + } else if (argc == 2 && !strncmp(argv[1], "same_version", 13)) { + /* Get info all test. */ + binary_update_getinfo_all(); + + int ret = binary_update_same_version_test(); + if (ret != OK) { + printf("Same version test failed\n"); + } + return ret; + } else if (argc == 2 && !strncmp(argv[1], "new_version", 12)) { + /* Get info all test. */ + binary_update_getinfo_all(); + + int ret = binary_update_new_version_test(); + if (ret != OK) { + printf("New version test failed\n"); + } + return ret; + } else if (argc == 2 && !strncmp(argv[1], "invalid", 8)) { + /* Get info all test. */ + binary_update_getinfo_all(); + + int ret = binary_update_invalid_binary_test(); + if (ret != OK) { + printf("Invalid binary test failed\n"); + } + return ret; + } + printf("Invalid test type: %s\n", argv[1]); + show_usage(); + return ERROR; } diff --git a/loadable_apps/loadable_sample/wifiapp/binary_update.c b/loadable_apps/loadable_sample/wifiapp/binary_update.c index 948c169d43..2340a2d6f0 100644 --- a/loadable_apps/loadable_sample/wifiapp/binary_update.c +++ b/loadable_apps/loadable_sample/wifiapp/binary_update.c @@ -677,6 +677,31 @@ void binary_update_test(void) { binary_update_execute_ntimes(1); } + +/**************************************************************************** + * binary_update_test_with_type + ****************************************************************************/ +void binary_update_test_with_type(const char *test_type) +{ + if (test_type == NULL) { + /* Default: run all tests */ + binary_update_run_tests(); + return; + } + + if (strcmp(test_type, "same_version") == 0) { + binary_update_same_version_test(APP1_NAME); + } else if (strcmp(test_type, "new_version") == 0) { + binary_update_new_version_test(APP1_NAME); + } else if (strcmp(test_type, "invalid_binary") == 0) { + binary_update_invalid_binary_test(APP1_NAME); + } else if (strcmp(test_type, "all_tests") == 0) { + binary_update_run_tests(); + } else { + printf("Unknown test type: %s\n", test_type); + printf("Available test types: same_version, new_version, invalid_binary, all_tests\n"); + } +} #endif #ifdef CONFIG_EXAMPLES_UPDATE_AGING_TEST diff --git a/loadable_apps/loadable_sample/wifiapp/wifiapp.c b/loadable_apps/loadable_sample/wifiapp/wifiapp.c index 54544a9708..a044e431c6 100644 --- a/loadable_apps/loadable_sample/wifiapp/wifiapp.c +++ b/loadable_apps/loadable_sample/wifiapp/wifiapp.c @@ -42,7 +42,10 @@ static void display_test_scenario(void) printf("\t-Press R or r : Recovery Test\n"); #endif #ifdef CONFIG_EXAMPLES_BINARY_UPDATE_TEST - printf("\t-Press U or u : Binary Update Test\n"); + printf("\t-Press U or u : Binary Update Test (All Tests)\n"); + printf("\t-Press S or s : Same Version Test\n"); + printf("\t-Press N or n : New Version Test\n"); + printf("\t-Press I or i : Invalid Binary Test\n"); #endif printf("\t-Press X or x : Terminate Tests.\n"); } @@ -103,7 +106,19 @@ int wifiapp_main(int argc, char **argv) #ifdef CONFIG_EXAMPLES_BINARY_UPDATE_TEST case 'U': case 'u': - binary_update_test(); + binary_update_test_with_type("all_tests"); + break; + case 'S': + case 's': + binary_update_test_with_type("same_version"); + break; + case 'N': + case 'n': + binary_update_test_with_type("new_version"); + break; + case 'I': + case 'i': + binary_update_test_with_type("invalid_binary"); break; #endif case 'X':