From 54c8190760f8938d52e220914a1e8071924fd61c Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Thu, 18 Dec 2025 17:18:55 +0530 Subject: [PATCH] apps/examples/kernel_update_test/kernel_update_test_main.c: Modify kernel update test to accept command line arguments - Add support for running specific tests: same_version, new_version, invalid, all - Each test now runs independently with proper error handling - Update main function to parse argc/argv and call appropriate test functions --- .../kernel_update_test_main.c | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) 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..342b167adc 100644 --- a/apps/examples/kernel_update_test/kernel_update_test_main.c +++ b/apps/examples/kernel_update_test/kernel_update_test_main.c @@ -619,6 +619,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 +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; }