mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
Open source GPL/LGPL release
This commit is contained in:
78
userspace/include/unit/args.h
Normal file
78
userspace/include/unit/args.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020, 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __UNIT_ARGS_H__
|
||||
#define __UNIT_ARGS_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/*
|
||||
* Allow defaults to be changed at compile time.
|
||||
*/
|
||||
#define __stringify(x) #x
|
||||
#define stringify(x) __stringify(x)
|
||||
|
||||
#ifndef __DEFAULT_ARG_DRIVER_LOAD_PATH
|
||||
#if defined(__NVGPU_POSIX__)
|
||||
#define __DEFAULT_ARG_DRIVER_LOAD_PATH ./build/libnvgpu-drv-igpu.so
|
||||
#else
|
||||
#define __DEFAULT_ARG_DRIVER_LOAD_PATH ./libnvgpu-drv-igpu.so
|
||||
#endif
|
||||
#endif
|
||||
#define DEFAULT_ARG_DRIVER_LOAD_PATH stringify(__DEFAULT_ARG_DRIVER_LOAD_PATH)
|
||||
|
||||
#ifndef __DEFAULT_ARG_UNIT_LOAD_PATH
|
||||
#define __DEFAULT_ARG_UNIT_LOAD_PATH build/units
|
||||
#endif
|
||||
#define DEFAULT_ARG_UNIT_LOAD_PATH stringify(__DEFAULT_ARG_UNIT_LOAD_PATH)
|
||||
#define TEST_PLAN_MAX 1
|
||||
|
||||
struct unit_fw;
|
||||
|
||||
struct unit_fw_args {
|
||||
bool help;
|
||||
int verbose_lvl;
|
||||
bool no_color;
|
||||
int thread_count;
|
||||
bool nvtest;
|
||||
bool is_qnx;
|
||||
unsigned int test_lvl;
|
||||
bool debug;
|
||||
const char *binary_name;
|
||||
|
||||
const char *driver_load_path;
|
||||
|
||||
const char *unit_name;
|
||||
const char *unit_load_path;
|
||||
const char *unit_to_run;
|
||||
const char *required_tests_file;
|
||||
};
|
||||
|
||||
int core_parse_args(struct unit_fw *fw, int argc, char **argv);
|
||||
void core_print_help(struct unit_fw *fw);
|
||||
|
||||
/*
|
||||
* Convenience for getting the args struct pointer.
|
||||
*/
|
||||
#define args(fw) ((fw)->args)
|
||||
|
||||
#endif
|
||||
69
userspace/include/unit/core.h
Normal file
69
userspace/include/unit/core.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __UNIT_CORE_H__
|
||||
#define __UNIT_CORE_H__
|
||||
|
||||
struct unit_fw_args;
|
||||
struct unit_modules;
|
||||
struct unit_results;
|
||||
|
||||
struct gk20a;
|
||||
struct nvgpu_posix_fault_inj_container;
|
||||
|
||||
/*
|
||||
* The core unit testing framework data structure. Keeps track of global state
|
||||
* for the unit test app.
|
||||
*/
|
||||
struct unit_fw {
|
||||
struct unit_fw_args *args;
|
||||
|
||||
struct unit_module **modules;
|
||||
|
||||
struct unit_results *results;
|
||||
|
||||
/*
|
||||
* driver library interface. Currently the only two directly referenced
|
||||
* functions are:
|
||||
*
|
||||
* nvgpu_posix_probe()
|
||||
* nvgpu_posix_cleanup()
|
||||
*
|
||||
* There will get populated so that we can call them before/after each
|
||||
* module.
|
||||
*/
|
||||
void *nvgpu_so;
|
||||
struct {
|
||||
struct gk20a *(*nvgpu_posix_probe)(void);
|
||||
void (*nvgpu_posix_cleanup)(struct gk20a *g);
|
||||
void (*nvgpu_posix_init_fault_injection)
|
||||
(struct nvgpu_posix_fault_inj_container *c);
|
||||
void (*nvgpu_posix_init_fault_injection_qnx)
|
||||
(struct nvgpu_posix_fault_inj_container *c);
|
||||
} nvgpu;
|
||||
void *nvgpu_qnx_ut;
|
||||
};
|
||||
|
||||
int core_load_nvgpu(struct unit_fw *fw);
|
||||
int core_exec(struct unit_fw *fw);
|
||||
int verbose_lvl(struct unit_module *module);
|
||||
#endif
|
||||
103
userspace/include/unit/io.h
Normal file
103
userspace/include/unit/io.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __UNIT_IO_H__
|
||||
#define __UNIT_IO_H__
|
||||
|
||||
struct unit_fw;
|
||||
struct unit_module;
|
||||
|
||||
/*
|
||||
* necessary for args(fw) macro. IO will always, in general, depend on args
|
||||
* since the args will specify where IO should be directed to.
|
||||
*/
|
||||
#include <unit/args.h>
|
||||
|
||||
#define core_msg(fw, msg, ...) \
|
||||
core_vbs(fw, 0, msg, ##__VA_ARGS__)
|
||||
#define core_msg_color(fw, color, msg, ...) \
|
||||
core_vbs_color(fw, color, 0, msg, ##__VA_ARGS__)
|
||||
|
||||
#define core_vbs_color(fw, color, lvl, msg, ...) \
|
||||
do { \
|
||||
if ((lvl) > args(fw)->verbose_lvl) \
|
||||
continue; \
|
||||
\
|
||||
/* Print if verbosity level is high enough. */ \
|
||||
__core_print_stdout(fw, color, msg, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#define core_vbs(fw, lvl, msg, ...) \
|
||||
core_vbs_color(fw, NULL, lvl, msg, ##__VA_ARGS__)
|
||||
|
||||
#define core_err(fw, msg, ...) \
|
||||
__core_print_stderr(fw, "(%s:%d) " msg, \
|
||||
__func__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Output macro for unit tests to use.
|
||||
*/
|
||||
#define unit_info(unit, msg, ...) \
|
||||
__unit_info_color(unit, NULL, msg, ##__VA_ARGS__)
|
||||
#define unit_err(unit, msg, ...) \
|
||||
__unit_info_color(unit, C_RED, msg, ##__VA_ARGS__)
|
||||
|
||||
|
||||
/*
|
||||
* helper to check a condition, output and error if condition is false
|
||||
* and execute bail_out_code
|
||||
*/
|
||||
#define unit_assert(cond, bail_out_code) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
unit_err(m, "%s:%d (" #cond ") is false\n", \
|
||||
__func__, __LINE__); \
|
||||
bail_out_code; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Don't go overboard with these!!!
|
||||
*/
|
||||
#define C_RED "\x1B[31m"
|
||||
#define C_GREEN "\x1B[32m"
|
||||
#define C_YELLOW "\x1B[33m"
|
||||
#define C_BLUE "\x1B[34m"
|
||||
#define C_MAGENTA "\x1B[35m"
|
||||
#define C_CYAN "\x1B[36m"
|
||||
#define C_WHITE "\x1B[37m"
|
||||
#define C_RESET "\x1B[0m"
|
||||
|
||||
/*
|
||||
* Printing functions. Do not use these directly. Instead use the provided
|
||||
* macros.
|
||||
*/
|
||||
__attribute__((format (printf, 3, 4)))
|
||||
void __core_print_stdout(struct unit_fw *fw, const char *color,
|
||||
const char *fmt, ...);
|
||||
__attribute__((format (printf, 2, 3)))
|
||||
void __core_print_stderr(struct unit_fw *fw, const char *fmt, ...);
|
||||
__attribute__((format (printf, 3, 4)))
|
||||
void __unit_info_color(struct unit_module *unit, const char *color,
|
||||
const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
31
userspace/include/unit/module.h
Normal file
31
userspace/include/unit/module.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __UNIT_MODULE_H__
|
||||
#define __UNIT_MODULE_H__
|
||||
|
||||
struct unit_fw;
|
||||
struct unit_module;
|
||||
|
||||
struct unit_module **core_load_modules(struct unit_fw *fw);
|
||||
|
||||
#endif
|
||||
31
userspace/include/unit/required_tests.h
Normal file
31
userspace/include/unit/required_tests.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __REQUIRED_TESTS_H__
|
||||
#define __REQUIRED_TESTS_H__
|
||||
|
||||
#define MAX_LINE_SIZE 256
|
||||
|
||||
int parse_req_file(struct unit_fw *fw, const char *ini_file);
|
||||
int check_executed_tests(struct unit_fw *fw);
|
||||
|
||||
#endif
|
||||
78
userspace/include/unit/results.h
Normal file
78
userspace/include/unit/results.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __UNIT_RESULTS_H__
|
||||
#define __UNIT_RESULTS_H__
|
||||
|
||||
/*
|
||||
* Keep track of the the results of a set of unit tests. This is effectively
|
||||
* just a single linked list of records for each test.
|
||||
*/
|
||||
|
||||
struct unit_test_record {
|
||||
/*
|
||||
* Let's us determine the name of the test.
|
||||
*/
|
||||
struct unit_module *mod;
|
||||
struct unit_module_test *test;
|
||||
|
||||
/*
|
||||
* True for pass, false for fail.
|
||||
*/
|
||||
bool status;
|
||||
|
||||
struct unit_test_record *next;
|
||||
};
|
||||
|
||||
struct unit_test_list {
|
||||
struct unit_test_record *head;
|
||||
struct unit_test_record *last;
|
||||
};
|
||||
|
||||
enum result_enum {
|
||||
PASSED,
|
||||
FAILED,
|
||||
SKIPPED,
|
||||
};
|
||||
|
||||
struct unit_results {
|
||||
struct unit_test_list passing;
|
||||
struct unit_test_list failing;
|
||||
struct unit_test_list skipped;
|
||||
|
||||
int nr_tests;
|
||||
int nr_passing;
|
||||
int nr_skipped;
|
||||
};
|
||||
|
||||
#define for_record_in_test_list(__test_list, __test) \
|
||||
for ((__test) = (__test_list)->head; \
|
||||
(__test) != NULL; \
|
||||
(__test) = (__test)->next)
|
||||
|
||||
int core_add_test_record(struct unit_fw *fw,
|
||||
struct unit_module *mod,
|
||||
struct unit_module_test *test,
|
||||
enum result_enum result);
|
||||
void core_print_test_status(struct unit_fw *fw);
|
||||
|
||||
#endif
|
||||
42
userspace/include/unit/unit-requirement-ids.h
Normal file
42
userspace/include/unit/unit-requirement-ids.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __UNIT_UNIT_REQUIREMENT_IDS_H__
|
||||
#define __UNIT_UNIT_REQUIREMENT_IDS_H__
|
||||
|
||||
/*
|
||||
* Unit requirement test specification unique IDs.
|
||||
*/
|
||||
#define PD_CACHE_REQ1_UID "6439202"
|
||||
#define PD_CACHE_REQ2_UID "6898078"
|
||||
#define PD_CACHE_REQ3_UID "6957786"
|
||||
#define PD_CACHE_REQ4_UID "6962424"
|
||||
#define PD_CACHE_REQ5_UID "6963067"
|
||||
#define PD_CACHE_REQ6_UID "6962548"
|
||||
#define PD_CACHE_REQ7_UID "7138651"
|
||||
#define PD_CACHE_REQ8_UID "6962610"
|
||||
|
||||
#define PAGE_TABLE_REQ1_UID "6439094"
|
||||
|
||||
#define VM_REQ1_UID "6434840"
|
||||
|
||||
#endif
|
||||
192
userspace/include/unit/unit.h
Normal file
192
userspace/include/unit/unit.h
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __UNIT_UNIT_H__
|
||||
#define __UNIT_UNIT_H__
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
struct gk20a;
|
||||
|
||||
struct unit_module;
|
||||
typedef int (*module_test_fn)(struct unit_module *m,
|
||||
struct gk20a *g, void *args);
|
||||
|
||||
#define UNIT_SUCCESS 0
|
||||
#define UNIT_FAIL -1
|
||||
|
||||
struct unit_module_test {
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
unsigned int test_lvl;
|
||||
|
||||
/*
|
||||
* A void pointer to arbitrary arguments. Lets the same unit test
|
||||
* function perform multiple tests. This gets passed into the
|
||||
* module_test_fn as @args.
|
||||
*/
|
||||
void *args;
|
||||
|
||||
/*
|
||||
* Linkage to JAMA test specification. An example would be:
|
||||
*
|
||||
* .requirement = "NVGPU-RQCD-68"
|
||||
* .verification_criteria = "C1"
|
||||
*
|
||||
* This would link to C1 verification criteria of the pd_cache
|
||||
* requirement NVGPU-RQCD-68.
|
||||
*
|
||||
* This is an optional field for any given unit test. But a unit
|
||||
* test module must satisfy the necessary VC for all requirements
|
||||
* within that unit.
|
||||
*/
|
||||
struct {
|
||||
/*
|
||||
* Requirement linkage: this should point to the unique ID
|
||||
* of the test specification.
|
||||
*/
|
||||
const char *unique_id;
|
||||
|
||||
/*
|
||||
* The particular verification criteria that this is
|
||||
* satisfying.
|
||||
*/
|
||||
const char *verification_criteria;
|
||||
|
||||
/*
|
||||
* Specific requirement this test provides coverage for.
|
||||
*/
|
||||
const char *requirement;
|
||||
} jama;
|
||||
};
|
||||
|
||||
/*
|
||||
* Interface to the unit test framework module loader. Each unit test module
|
||||
* will have exactly one of these.
|
||||
*/
|
||||
struct unit_module {
|
||||
/*
|
||||
* Name of the module.
|
||||
*/
|
||||
const char *name;
|
||||
|
||||
/*
|
||||
* NULL terminated list of tests within the module.
|
||||
*/
|
||||
struct unit_module_test *tests;
|
||||
unsigned long nr_tests;
|
||||
|
||||
/*
|
||||
* Run priority. Currently 3 defined:
|
||||
*
|
||||
* UNIT_PRIO_SELF_TEST
|
||||
* UNIT_PRIO_POSIX_TEST
|
||||
* UNIT_PRIO_NVGPU_TEST
|
||||
*
|
||||
* These let us run environment and POSIX API wrapper tests before the
|
||||
* rest of the unit tests run.
|
||||
*/
|
||||
unsigned int prio;
|
||||
|
||||
/*
|
||||
* For the core FW to use. Not for modules!!!
|
||||
*/
|
||||
void *lib_handle;
|
||||
struct unit_fw *fw;
|
||||
|
||||
pthread_t thread;
|
||||
};
|
||||
|
||||
/*
|
||||
* Zero is the higest priority. Increasing the prio value decreases priority to
|
||||
* run.
|
||||
*/
|
||||
#define UNIT_PRIO_SELF_TEST 0U
|
||||
#define UNIT_PRIO_POSIX_TEST 50U
|
||||
#define UNIT_PRIO_NVGPU_TEST 100U
|
||||
|
||||
#define UNIT_MODULE(__name, __tests, __prio) \
|
||||
struct unit_module __unit_module__ = { \
|
||||
.name = #__name, \
|
||||
.tests = __tests, \
|
||||
.nr_tests = (sizeof(__tests) / \
|
||||
sizeof(struct unit_module_test)), \
|
||||
.prio = __prio, \
|
||||
.lib_handle = NULL, \
|
||||
.fw = NULL, \
|
||||
}
|
||||
|
||||
#define UNIT_TEST(__name, __fn, __args, __test_lvl) \
|
||||
{ \
|
||||
.fn_name = #__fn, \
|
||||
.case_name = #__name, \
|
||||
.fn = __fn, \
|
||||
.args = __args, \
|
||||
.test_lvl = __test_lvl, \
|
||||
.jama.requirement = "", \
|
||||
.jama.unique_id = "", \
|
||||
.jama.verification_criteria = "", \
|
||||
}
|
||||
|
||||
/*
|
||||
* Use this for a unit test that satisfies or contributes to satisfying a
|
||||
* verification criteria for a given requirement.
|
||||
*/
|
||||
#define UNIT_TEST_REQ(__req, __uid, __vc, __name, __fn, __args, __test_lvl) \
|
||||
{ \
|
||||
.fn_name = #__fn, \
|
||||
.case_name = #__name, \
|
||||
.fn = __fn, \
|
||||
.args = __args, \
|
||||
.test_lvl = __test_lvl, \
|
||||
.jama.requirement = __req, \
|
||||
.jama.unique_id = __uid, \
|
||||
.jama.verification_criteria = __vc, \
|
||||
}
|
||||
|
||||
#define unit_return_fail(m, msg, ...) \
|
||||
do { \
|
||||
unit_err(m, "%s():%d " msg, \
|
||||
__func__, __LINE__, ##__VA_ARGS__); \
|
||||
return UNIT_FAIL; \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user