From a0dede3a85af0238a71ac5200d5f9ae1e56be6a5 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Mon, 13 Jan 2020 14:19:09 +0530 Subject: [PATCH] gpu: nvgpu: unit: add negative coverage with tpc_count set to 0 Add negative testing coverage for below functions by setting tpc_count to 0. g->ops.gr.init.get_attrib_cb_size g->ops.gr.init.get_alpha_cb_size Jira NVGPU-4778 Change-Id: I105888b20bee2a991d35dc17f17854d22085a67a Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2279899 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Vinod Gopalakrishnakurup Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- userspace/units/gr/init/nvgpu-gr-init-hal-gv11b.c | 8 ++++++++ userspace/units/gr/init/nvgpu-gr-init-hal-gv11b.h | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/userspace/units/gr/init/nvgpu-gr-init-hal-gv11b.c b/userspace/units/gr/init/nvgpu-gr-init-hal-gv11b.c index d06db78a6..9ba44a13e 100644 --- a/userspace/units/gr/init/nvgpu-gr-init-hal-gv11b.c +++ b/userspace/units/gr/init/nvgpu-gr-init-hal-gv11b.c @@ -828,6 +828,14 @@ int test_gr_init_hal_error_injection(struct unit_module *m, unit_return_fail(m, "expected size not set"); } + /* + * Trigger these HALs with tpc_count = 0, only for code coverage. + * We are not interested in return values since tpc_count cannot be + * 0 in any practical case. + */ + EXPECT_BUG(g->ops.gr.init.get_attrib_cb_size(g, 0)); + EXPECT_BUG(g->ops.gr.init.get_alpha_cb_size(g, 0)); + /* cleanup */ nvgpu_gr_ctx_free_patch_ctx(g, vm, gr_ctx); nvgpu_free_gr_ctx_struct(g, gr_ctx); diff --git a/userspace/units/gr/init/nvgpu-gr-init-hal-gv11b.h b/userspace/units/gr/init/nvgpu-gr-init-hal-gv11b.h index ad882e712..99f440d0f 100644 --- a/userspace/units/gr/init/nvgpu-gr-init-hal-gv11b.h +++ b/userspace/units/gr/init/nvgpu-gr-init-hal-gv11b.h @@ -258,6 +258,10 @@ int test_gr_init_hal_config_error_injection(struct unit_module *m, * * Targets: gops_gr_init.commit_global_pagepool, * gp10b_gr_init_commit_global_pagepool + * gops_gr_init.get_attrib_cb_size, + * gv11b_gr_init_get_attrib_cb_size, + * gops_gr_init.get_alpha_cb_size, + * gv11b_gr_init_get_alpha_cb_size * * Input: gr_init_setup, gr_init_prepare, gr_init_support must have * been executed successfully. @@ -268,6 +272,9 @@ int test_gr_init_hal_config_error_injection(struct unit_module *m, * - Call g->ops.gr.init.commit_global_pagepool with global_ctx flag set * to false and with arbitrary size. * - Read back size from register and ensure correct size is set. + * - Call g->ops.gr.init.get_attrib_cb_size and g->ops.gr.init.get_alpha_cb_size + * with tpc_count = 0 for code coverage. Ensure that a BUG() is triggered. + * We are not interested in return value since tpc_count can never be 0. * - Cleanup temporary resources. * * Output: Returns PASS if the steps above were executed successfully. FAIL