From a43f6c14ae38ef8e28b05397c1e05f4963eae085 Mon Sep 17 00:00:00 2001 From: Min M Xu Date: Tue, 9 Apr 2024 23:02:16 -0400 Subject: [PATCH] Fix the error that debug_level doesn't work in ide_test.ini Signed-off-by: Min Xu --- teeio-validator/include/ide_test.h | 2 +- teeio-validator/teeio_validator/cmdline.c | 5 +++-- teeio-validator/teeio_validator/ide_test_ini.c | 13 +++++++++---- teeio-validator/teeio_validator/teeio_validator.c | 13 +++++++++++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/teeio-validator/include/ide_test.h b/teeio-validator/include/ide_test.h index 38fb90d..5c13daa 100644 --- a/teeio-validator/include/ide_test.h +++ b/teeio-validator/include/ide_test.h @@ -154,7 +154,7 @@ struct _IDE_SWITCH_INTERNAL_CONNECTION { typedef struct { bool pci_log; - uint32_t log_level; + uint32_t debug_level; bool wo_tdisp; } IDE_TEST_MAIN_CONFIG; diff --git a/teeio-validator/teeio_validator/cmdline.c b/teeio-validator/teeio_validator/cmdline.c index 25ed235..63f4e64 100644 --- a/teeio-validator/teeio_validator/cmdline.c +++ b/teeio-validator/teeio_validator/cmdline.c @@ -58,7 +58,7 @@ void print_usage() /** * parse the command line option */ -bool parse_cmdline_option(int argc, char *argv[], char* file_name, IDE_TEST_CONFIG *ide_test_config, bool* print_usage) +bool parse_cmdline_option(int argc, char *argv[], char* file_name, IDE_TEST_CONFIG *ide_test_config, bool* print_usage, uint8_t* debug_level) { int opt, v; uint8_t data8; @@ -70,6 +70,7 @@ bool parse_cmdline_option(int argc, char *argv[], char* file_name, IDE_TEST_CONF TEEIO_ASSERT(file_name != NULL); TEEIO_ASSERT(ide_test_config != NULL); TEEIO_ASSERT(print_usage != NULL); + TEEIO_ASSERT(debug_level); // first print the raw command line for(int i = 0; i < argc; i++) { @@ -129,7 +130,7 @@ bool parse_cmdline_option(int argc, char *argv[], char* file_name, IDE_TEST_CONF break; case 'l': - g_debug_level = get_ide_log_level_from_string(optarg); + *debug_level = get_ide_log_level_from_string(optarg); break; case 'h': diff --git a/teeio-validator/teeio_validator/ide_test_ini.c b/teeio-validator/teeio_validator/ide_test_ini.c index 37b943f..290bdd9 100644 --- a/teeio-validator/teeio_validator/ide_test_ini.c +++ b/teeio-validator/teeio_validator/ide_test_ini.c @@ -2311,6 +2311,7 @@ void ParseMainSection(void *context, IDE_TEST_CONFIG *test_config) char section_name[MAX_SECTION_NAME_LENGTH] = {0}; char entry_name[MAX_ENTRY_NAME_LENGTH] = {0}; uint32_t data32 = 0; + uint8_t *entry_value = NULL; sprintf(section_name, "%s", MAIN_SECION); sprintf(entry_name, "pci_log"); @@ -2319,10 +2320,14 @@ void ParseMainSection(void *context, IDE_TEST_CONFIG *test_config) test_config->main_config.pci_log = data32 == 1; } - sprintf(entry_name, "wo_tdisp"); - if (GetDecimalUint32FromDataFile(context, (uint8_t *)section_name, (uint8_t *)entry_name, &data32)) + sprintf(entry_name, "debug_level"); + if (!GetStringFromDataFile(context, (uint8_t *)section_name, (uint8_t *)entry_name, &entry_value)) + { + test_config->main_config.debug_level = TEEIO_DEBUG_WARN; + } + else { - test_config->main_config.wo_tdisp = data32 == 1; + test_config->main_config.debug_level = get_ide_log_level_from_string((const char*)entry_value); } } @@ -2433,7 +2438,7 @@ void dump_test_config(IDE_TEST_CONFIG *test_config) IDE_TEST_MAIN_CONFIG *main = &test_config->main_config; TEEIO_DEBUG((TEEIO_DEBUG_VERBOSE, "[Main]\n")); TEEIO_DEBUG((TEEIO_DEBUG_VERBOSE, " pci_log=%s\n", main->pci_log == 0 ? "false":"true")); - TEEIO_DEBUG((TEEIO_DEBUG_VERBOSE, " wo_tdisp=%s\n", main->wo_tdisp == 0 ? "false":"true")); + TEEIO_DEBUG((TEEIO_DEBUG_VERBOSE, " debug_level=%s\n", get_ide_log_level_string(main->debug_level))); TEEIO_DEBUG((TEEIO_DEBUG_VERBOSE, "\n")); IDE_TEST_PORTS_CONFIG *ports = &test_config->ports_config; diff --git a/teeio-validator/teeio_validator/teeio_validator.c b/teeio-validator/teeio_validator/teeio_validator.c index 0b4375a..5729cd8 100644 --- a/teeio-validator/teeio_validator/teeio_validator.c +++ b/teeio-validator/teeio_validator/teeio_validator.c @@ -33,7 +33,7 @@ void log_file_close(); extern const char *IDE_TEST_IDE_TYPE_NAMES[]; bool parse_ide_test_init(IDE_TEST_CONFIG *test_config, const char* ide_test_ini); -bool parse_cmdline_option(int argc, char *argv[], char* file_name, IDE_TEST_CONFIG *ide_test_config, bool* print_usage); +bool parse_cmdline_option(int argc, char *argv[], char* file_name, IDE_TEST_CONFIG *ide_test_config, bool* print_usage, uint8_t* debug_level); void print_usage(); bool run(IDE_TEST_CONFIG *test_config); bool update_test_config_with_given_top_config_id(IDE_TEST_CONFIG *test_config, int top_id, int config_id, const char* test_case); @@ -43,6 +43,7 @@ int main(int argc, char *argv[]) char ide_test_ini_file[MAX_FILE_NAME] = {0}; bool to_print_usage = false; int ret = -1; + uint8_t debug_level = TEEIO_DEBUG_NUM; if (!log_file_init(LOGFILE)){ TEEIO_PRINT(("Failed to init log file!\n")); @@ -52,11 +53,15 @@ int main(int argc, char *argv[]) TEEIO_PRINT(("%s version %s\n", TEEIO_VALIDATOR_NAME, TEEIO_VALIDATOR_VERSION)); // parse command line optioins - if(!parse_cmdline_option(argc, argv, ide_test_ini_file, &ide_test_config, &to_print_usage)) { + if(!parse_cmdline_option(argc, argv, ide_test_ini_file, &ide_test_config, &to_print_usage, &debug_level)) { print_usage(); goto MainDone; } + if(debug_level != TEEIO_DEBUG_NUM) { + g_debug_level = debug_level; + } + if(to_print_usage) { print_usage(); ret = 0; @@ -75,6 +80,10 @@ int main(int argc, char *argv[]) } g_pci_log = ide_test_config.main_config.pci_log; + if(debug_level == TEEIO_DEBUG_NUM) { + g_debug_level = ide_test_config.main_config.debug_level; + } + // if g_top_ids is valid, then we go into xxx mode if(g_top_id != 0 && g_config_id != 0) { if(!update_test_config_with_given_top_config_id(&ide_test_config, g_top_id, g_config_id, g_test_case)) {