From 6b8aaf3bb81bf4689562db4d9d122be9860e1963 Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Thu, 5 Sep 2019 16:29:47 -0700 Subject: [PATCH] gpu: nvgpu: SWUTS for enabled Add preprocessor directives for nvgpu-enabled.h header. Jira NVGPU-3943 Change-Id: Ieab43fc49bafcd74a907b9dd1f175b693754f559 Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/2191262 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- userspace/units/enabled/nvgpu-enabled.c | 44 ++++--------------------- userspace/units/enabled/nvgpu-enabled.h | 8 +++-- 2 files changed, 12 insertions(+), 40 deletions(-) diff --git a/userspace/units/enabled/nvgpu-enabled.c b/userspace/units/enabled/nvgpu-enabled.c index f61d5c552..c861952ea 100644 --- a/userspace/units/enabled/nvgpu-enabled.c +++ b/userspace/units/enabled/nvgpu-enabled.c @@ -27,22 +27,11 @@ #include #include +#include "nvgpu-enabled.h" + static unsigned long *original_enabled_flags; -/* - * Test nvgpu_init_enabled_flags(): - * - * 1. With memory failure, check that init fails with -ENOMEM - * 2. Init works in regular scenario - * - * This test should be first to execute. Newly, inited enabled_flags will be - * used by rest of the tests in this module. - * - * Note: Since, enabled_flags are allocated during gk20a init, we store - * original allocated memory address in test_init_free_parameters structure. - * This pointer should be restored before exiting this module. - */ -static int test_nvgpu_init_enabled_flags(struct unit_module *m, +int test_nvgpu_init_enabled_flags(struct unit_module *m, struct gk20a *g, void *args) { int err; @@ -77,13 +66,7 @@ static int test_nvgpu_init_enabled_flags(struct unit_module *m, return UNIT_SUCCESS; } -/* - * Test nvgpu_is_enabled(): - * - * As enabled_flags inited(using kzalloc) by previous test, all flags should - * be disabled (set to 0). -*/ -static int test_nvgpu_enabled_flags_false_check(struct unit_module *m, +int test_nvgpu_enabled_flags_false_check(struct unit_module *m, struct gk20a *g, void *args) { u32 i; @@ -100,16 +83,7 @@ static int test_nvgpu_enabled_flags_false_check(struct unit_module *m, return UNIT_SUCCESS; } -/* - * Test nvgpu_set_enabled(): - * - * 1. Set given flag, check that flag is enabled - * 2. Reset given flag, check that flag is disabled - * - * Flag status is checked using nvgpu_is_enabled() function. This function is - * verified in previous test. - */ -static int test_nvgpu_set_enabled(struct unit_module *m, +int test_nvgpu_set_enabled(struct unit_module *m, struct gk20a *g, void *args) { u32 i; @@ -134,13 +108,7 @@ static int test_nvgpu_set_enabled(struct unit_module *m, return UNIT_SUCCESS; } -/* - * Test nvgpu_free_enabled_flags(): Free memory allocated in init test. - * - * Note: Not many alternatives to verify that memory is actually freed as - * pages are cached and accessible until replaced. - */ -static int test_nvgpu_free_enabled_flags(struct unit_module *m, +int test_nvgpu_free_enabled_flags(struct unit_module *m, struct gk20a *g, void *args) { nvgpu_free_enabled_flags(g); diff --git a/userspace/units/enabled/nvgpu-enabled.h b/userspace/units/enabled/nvgpu-enabled.h index c4b6d5704..7f752878d 100644 --- a/userspace/units/enabled/nvgpu-enabled.h +++ b/userspace/units/enabled/nvgpu-enabled.h @@ -20,6 +20,9 @@ * DEALINGS IN THE SOFTWARE. */ +#ifndef UNIT_NVGPU_ENABLED_H +#define UNIT_NVGPU_ENABLED_H + struct gk20a; struct unit_module; @@ -62,8 +65,8 @@ int test_nvgpu_init_enabled_flags(struct unit_module *m, struct gk20a *g, * * Steps: * - Check flag value - * - Iterate over each flag - * - Check if flag value is false + * - As flags are allocated for unit test, flag value is expected to be false + * - Iterate over each flag and check if flag value is false * * Output: Returns SUCCESS if the steps above were executed successfully. FAIL * otherwise. @@ -111,3 +114,4 @@ int test_nvgpu_set_enabled(struct unit_module *m, struct gk20a *g, void *args); */ int test_nvgpu_free_enabled_flags(struct unit_module *m, struct gk20a *g, void *args); +#endif /* UNIT_NVGPU_ENABLED_H */