Skip to content

Commit

Permalink
Fix the error that debug_level doesn't work in ide_test.ini
Browse files Browse the repository at this point in the history
Signed-off-by: Min Xu <min.m.xu@intel.com>
  • Loading branch information
mxu9 committed Apr 10, 2024
1 parent d2d9a3b commit a43f6c1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion teeio-validator/include/ide_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions teeio-validator/teeio_validator/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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++) {
Expand Down Expand Up @@ -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':
Expand Down
13 changes: 9 additions & 4 deletions teeio-validator/teeio_validator/ide_test_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions teeio-validator/teeio_validator/teeio_validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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"));
Expand All @@ -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;
Expand All @@ -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)) {
Expand Down

0 comments on commit a43f6c1

Please sign in to comment.