From 70915d8d604965fddf79cb68c0de5b32ed2ab104 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Wed, 27 Jun 2018 14:45:12 -0700 Subject: gpu: nvgpu: unit: Sort unit tests by priority Sort unit tests by their priority before running said unit tests. There are three available priorities: UNIT_PRIO_SELF_TEST UNIT_PRIO_POSIX_TEST UNIT_PRIO_NVGPU_TEST Which correspond to the types of testing expected to be run. In general unit tests should always just use UNIT_PRIO_NVGPU_TEST but in the case of tests for the POSIX API layer or the unit test framework the other two priorities are provided. The reason for this is that it doesn't make much sense to run a bunch of unit tests if the environment itself or the POSIX API layer is broken. By placing these tests at the front of the list of tests to run an engineer will easily be able to see if there are core problems versus nvgpu problems. This also lets users fine grain control of test order by adding or subtracting to UNIT_PRIO_NVGPU_TEST but one must be very careful about how they do this. JIRA NVGPU-525 Change-Id: I12a5b798e998f34e4d1168bb3696c579460f20b1 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1741953 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- userspace/src/module.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'userspace/src') diff --git a/userspace/src/module.c b/userspace/src/module.c index c111c6cb..779c52d3 100644 --- a/userspace/src/module.c +++ b/userspace/src/module.c @@ -99,6 +99,23 @@ static struct unit_module *load_one_module(struct unit_fw *fw, return mod; } +static int cmp_module_prio(const void *__mod_a, const void *__mod_b) +{ + const struct unit_module *mod_a = __mod_a; + const struct unit_module *mod_b = __mod_b; + + return mod_a->prio > mod_b->prio; +} + +/* + * Sort the module list according to prio. + */ +static void sort_modules_by_prio(struct unit_module **modules, int nr) +{ + qsort(modules, (size_t)nr, sizeof(struct unit_module *), + cmp_module_prio); +} + /* * Load all the modules we can from the module load path. Return the list of * loaded module as an array of pointers to modules. The returned list of @@ -159,6 +176,9 @@ struct unit_module **core_load_modules(struct unit_fw *fw) } modules[i] = NULL; + + sort_modules_by_prio(modules, i); + return modules; err: -- cgit v1.2.2