gpu: nvgpu: unit: add test function name to logs

This patch adds the test function name to output logs to make it
easier to establish traceability between SWUTS and test results.
Also, the unit test name as defined in the UNIT_TEST macro can
now be used to clarify the subcase when a given test function is
used several times with different arguments.

JIRA NVGPU-3510

Change-Id: I652ecd8c06fd89e4d78d419f73b35b69ae71a8ef
Signed-off-by: Nicolas Benech <nbenech@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2241879
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Nicolas Benech
2019-11-18 17:17:28 -05:00
committed by Alex Waterman
parent 1ab3f73230
commit 86f1b2336a
6 changed files with 2182 additions and 1336 deletions

View File

@@ -35,16 +35,24 @@ typedef int (*module_test_fn)(struct unit_module *m,
#define UNIT_FAIL -1
struct unit_module_test {
/*
* Name of the test.
*/
const char *name;
/*
* Function to call to execute the test.
*/
module_test_fn fn;
/*
* Name of the test function. It will be used to match the test
* results with its SWUTS.
*/
const char *fn_name;
/*
* Name of the test. It can be used to describe a subcase when the
* same test function is used several times.
*/
const char *case_name;
/*
* Minimum test plan level (L0, L1) to execute the test.
*/
@@ -148,7 +156,8 @@ struct unit_module {
#define UNIT_TEST(__name, __fn, __args, __test_lvl) \
{ \
.name = #__name, \
.fn_name = #__fn, \
.case_name = #__name, \
.fn = __fn, \
.args = __args, \
.test_lvl = __test_lvl, \
@@ -163,7 +172,8 @@ struct unit_module {
*/
#define UNIT_TEST_REQ(__req, __uid, __vc, __name, __fn, __args, __test_lvl) \
{ \
.name = #__name, \
.fn_name = #__fn, \
.case_name = #__name, \
.fn = __fn, \
.args = __args, \
.test_lvl = __test_lvl, \

View File

File diff suppressed because it is too large Load Diff

View File

@@ -108,18 +108,18 @@ static void *core_exec_module(void *module_param)
if (t->test_lvl > module->fw->args->test_lvl) {
core_add_test_record(module->fw, module, t, SKIPPED);
core_vbs(module->fw, 1, "Skipping L%d test %s.%s\n",
t->test_lvl, module->name, t->name);
t->test_lvl, module->name, t->fn_name);
continue;
}
core_msg(module->fw, "Running %s.%s\n", module->name,
t->name);
core_msg(module->fw, "Running %s.%s(%s)\n", module->name,
t->fn_name, t->case_name);
test_status = t->fn(module, g, t->args);
if (test_status != UNIT_SUCCESS)
core_msg_color(module->fw, C_RED,
" Unit error! Test %s.%s FAILED!\n",
module->name, t->name);
" Unit error! Test %s.%s(%s) FAILED!\n",
module->name, t->fn_name, t->case_name);
core_add_test_record(module->fw, module, t,
test_status == UNIT_SUCCESS ? PASSED : FAILED);
@@ -149,8 +149,9 @@ thread_exit:
static void thread_error_handler(int sig, siginfo_t *siginfo, void *context)
{
core_msg_color(thread_local_module->fw, C_RED,
" Signal %d in Test: %s.%s!\n", sig,
thread_local_module->name, thread_local_test->name);
" Signal %d in Test: %s.%s(%s)!\n", sig,
thread_local_module->name, thread_local_test->fn_name,
thread_local_test->case_name);
core_add_test_record(thread_local_module->fw, thread_local_module,
thread_local_test, FAILED);
sem_post(&unit_thread_semaphore);

View File

@@ -54,14 +54,14 @@ static int check_module(struct unit_fw *fw, struct unit_module *mod)
for (i = 0; i < mod->nr_tests; i++) {
struct unit_module_test *test = &mod->tests[i];
if (test->name == NULL) {
if (test->fn_name == NULL) {
core_err(fw, "%s: Unnamed test\n", mod->name);
return -1;
}
if (test->fn == NULL) {
core_err(fw, "%s: Test %s missing function\n",
mod->name, test->name);
mod->name, test->fn_name);
return -1;
}
}

View File

@@ -126,7 +126,8 @@ static void dump_test_record(FILE *logfile, struct unit_test_record *rec,
{
first ? fprintf(logfile, "\t{") : fprintf(logfile, ",\n\t{");
fprintf(logfile, "\"unit\": \"%s\", ", rec->mod->name);
fprintf(logfile, "\"test\": \"%s\", ", rec->test->name);
fprintf(logfile, "\"test\": \"%s\", ", rec->test->fn_name);
fprintf(logfile, "\"case\": \"%s\", ", rec->test->case_name);
fprintf(logfile, "\"status\": %s, ", status ? "true":"false");
fprintf(logfile, "\"uid\": \"%s\", ", rec->test->jama.unique_id);
fprintf(logfile, "\"vc\": \"%s\", ",
@@ -179,9 +180,10 @@ void core_print_test_status(struct unit_fw *fw)
core_msg(fw, "Skipped tests:\n");
core_msg(fw, "\n");
for_record_in_test_list(skipped_tests, rec) {
core_msg(fw, " %s.%s\n",
core_msg(fw, " %s.%s(%s)\n",
rec->mod->name,
rec->test->name);
rec->test->fn_name,
rec->test->case_name);
}
core_msg(fw, "\n");
@@ -189,9 +191,10 @@ void core_print_test_status(struct unit_fw *fw)
core_msg(fw, "\n");
for_record_in_test_list(failing_tests, rec) {
core_msg(fw, " %s.%s\n",
core_msg(fw, " %s.%s(%s)\n",
rec->mod->name,
rec->test->name);
rec->test->fn_name,
rec->test->case_name);
}
dump_test_log(fw, &fw->results->passing, &fw->results->failing);

View File

@@ -79,7 +79,7 @@ def build_results_dict(results):
#Iterate through the results and group them by unit name
for result in results:
unit = result['unit']
test = result['test']
test = result['case']
if unit not in test_dict:
test_dict[unit] = {}
if test in test_dict[unit]:
@@ -101,7 +101,7 @@ def regen():
test_count = 0
for unit, tests in sorted(test_dict.items(), key=lambda kv: kv[0], reverse=False):
for test in sorted(tests.items()):
entry = {"unit": unit, "test": test[0], 'test_level': test[1]['test_level']}
entry = {"unit": unit, "test": test[1]['test'], 'case': test[1]['case'], 'test_level': test[1]['test_level']}
if test[1]['uid'] != "":
entry['uid'] = test[1]['uid']
entry['vc'] = test[1]['vc']
@@ -155,7 +155,7 @@ def check(test_level, html = False):
#First make sure that all required tests were run and PASSED.
for reqd_test in reqd_tests:
unit = reqd_test['unit']
test = reqd_test['test']
test = reqd_test['case']
error = ""
status = False
skipped = False
@@ -186,7 +186,7 @@ def check(test_level, html = False):
#test to the required list.
for result in results:
unit = result['unit']
test = result['test']
test = result['case']
if unit not in req_dict:
log += ("WARNING: Tested unit %s is not in required tests. Use testlist.py --regen\n" % unit)
elif test not in req_dict[unit]: