Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 66 additions & 16 deletions apps/examples/kernel_update_test/kernel_update_test_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -489,10 +495,7 @@ static int binary_update_new_version_test(void)
printf("\n** Download and set bootparam for kernel binary. (new version) **\n");
printf("** (Both common and app1 binary will be updated with same version) **\n");
for (i = 0; i < bin_count; i++) {
int version_up = false;
if (bin_names[i] == KERNEL) {
version_up = true;
}
int version_up = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set version_up to true only for kernel, because this is kernel update test.
What I intended is that even if only kernel binary is updated, binary manager should load the latest version of kernel and same version of app1/app2.
app1/app2 version update test need to be tested in loadable_sample/wifiapp/binary_update.c

ret = download_binary_and_set_bootparam(bin_names[i], version_up, DOWNLOAD_VALID_BIN, bin_types[i]);
if (ret != OK) {
printf("Failed to download and set bootparam for %s\n", bin_names[i]);
Expand Down Expand Up @@ -530,9 +533,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;

Expand Down Expand Up @@ -619,6 +619,16 @@ static int binary_update_run_tests(void)
return OK;
}

static void show_usage(void)
{
printf("Usage: kernel_update <test_type>\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
****************************************************************************/
Expand All @@ -628,5 +638,45 @@ 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;
}
printf("Same version test completed successfully\n");
return OK;
} 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;
}
printf("New version test completed successfully\n");
return OK;
} 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 binary test completed successfully\n");
return OK;
}
printf("Invalid test type: %s\n", argv[1]);
show_usage();
return ERROR;
}
25 changes: 25 additions & 0 deletions loadable_apps/loadable_sample/wifiapp/binary_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 17 additions & 2 deletions loadable_apps/loadable_sample/wifiapp/wifiapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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':
Expand Down