gpu: nvgpu: unit: add test levels

Add -t/--test-level option for the unit test framework. This
correlates with the test plan levels in GVS. L0 tests are a subset of
the L1 tests. Currently, only test levels 0 and 1 are supported.

The test output has been updated to display skipped tests. Skipped
tests are not included in the test dump.

JIRA NVGPU-2251

Change-Id: Icc2ff19a81529be8526e89f70983e96040390e00
Signed-off-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2085280
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Philip Elcan
2019-03-29 11:59:04 -04:00
committed by mobile promotions
parent f7860833f1
commit c0d5a715bd
25 changed files with 293 additions and 218 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -39,11 +39,12 @@ static struct option core_opts[] = {
{ "unit-load-path", 1, NULL, 'L' },
{ "num-threads", 1, NULL, 'j' },
{ "test-level", 1, NULL, 't' },
{ NULL, 0, NULL, 0 }
};
static const char *core_opts_str = "hvqCnQL:j:";
static const char *core_opts_str = "hvqCnQL:j:t:";
void core_print_help(struct unit_fw *fw)
{
@@ -70,6 +71,8 @@ void core_print_help(struct unit_fw *fw)
" Path to where the unit test libraries reside.\n",
" -j, --num-threads <COUNT>\n",
" Number of threads to use while running all tests.\n",
" -t, --test-level <LEVEL>\n",
" Test plan level. 0=L0, 1=L1. default: 1\n",
"\n",
"Note: mandatory arguments to long arguments are mandatory for short\n",
"arguments as well.\n",
@@ -87,6 +90,7 @@ static void set_arg_defaults(struct unit_fw_args *args)
{
args->unit_load_path = DEFAULT_ARG_UNIT_LOAD_PATH;
args->thread_count = 1;
args->test_lvl = TEST_PLAN_MAX;
}
/*
@@ -151,6 +155,13 @@ int core_parse_args(struct unit_fw *fw, int argc, char **argv)
case 'Q':
args->is_qnx = true;
break;
case 't':
args->test_lvl = strtol(optarg, NULL, 10);
if (args->test_lvl > TEST_PLAN_MAX) {
core_err(fw, "Invalid test plan level\n");
return -1;
}
break;
case '?':
args->help = true;
return -1;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -85,6 +85,12 @@ static void *core_exec_module(void *module_param)
int test_status;
thread_local_test = t;
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);
continue;
}
core_msg(module->fw, "Running %s.%s\n", module->name,
t->name);
@@ -92,11 +98,11 @@ static void *core_exec_module(void *module_param)
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 FAILED!\n",
module->name, t->name);
core_add_test_record(module->fw, module, t,
test_status == UNIT_SUCCESS);
test_status == UNIT_SUCCESS ? PASSED : FAILED);
}
module->fw->nvgpu.nvgpu_posix_cleanup(g);

View File

@@ -76,7 +76,7 @@ static void add_record(struct unit_test_list *list,
int core_add_test_record(struct unit_fw *fw,
struct unit_module *mod,
struct unit_module_test *test,
bool success)
enum result_enum result)
{
struct unit_test_record *tr;
int err = 0;
@@ -98,17 +98,23 @@ int core_add_test_record(struct unit_fw *fw,
tr->mod = mod;
tr->test = test;
tr->status = success;
tr->status = (result == PASSED);
tr->next = NULL;
if (success)
add_record(&fw->results->passing, tr);
else
add_record(&fw->results->failing, tr);
fw->results->nr_tests += 1;
if (success)
switch (result) {
case PASSED:
add_record(&fw->results->passing, tr);
fw->results->nr_passing += 1;
break;
case FAILED:
add_record(&fw->results->failing, tr);
break;
case SKIPPED:
add_record(&fw->results->skipped, tr);
fw->results->nr_skipped += 1;
break;
}
done:
pthread_mutex_unlock(&mutex_results);
@@ -152,6 +158,7 @@ static void dump_test_log(struct unit_fw *fw, struct unit_test_list
void core_print_test_status(struct unit_fw *fw)
{
struct unit_test_list *failing_tests = &fw->results->failing;
struct unit_test_list *skipped_tests = &fw->results->skipped;
struct unit_test_record *rec;
/*
@@ -161,10 +168,21 @@ void core_print_test_status(struct unit_fw *fw)
core_msg(fw, "Test results:\n");
core_msg(fw, "-------------\n");
core_msg(fw, "\n");
core_msg(fw, " Skipped: %d\n", fw->results->nr_skipped);
core_msg(fw, " Passing: %d\n", fw->results->nr_passing);
core_msg(fw, " Failing: %d\n",
fw->results->nr_tests - fw->results->nr_passing);
fw->results->nr_tests - fw->results->nr_passing -
fw->results->nr_skipped);
core_msg(fw, " Total: %d\n", fw->results->nr_tests);
core_msg(fw, "\n");
core_msg(fw, "Skipped tests:\n");
core_msg(fw, "\n");
for_record_in_test_list(skipped_tests, rec) {
core_msg(fw, " %s.%s\n",
rec->mod->name,
rec->test->name);
}
core_msg(fw, "\n");
core_msg(fw, "Failing tests:\n");
core_msg(fw, "\n");