From 5137e51da80c83e0d55c201f98a8072c07183b9c Mon Sep 17 00:00:00 2001 From: Nicolas Benech Date: Wed, 12 Feb 2020 19:31:36 -0500 Subject: [PATCH] gpu: nvgpu: unit: increase commom.mm test coverage This patch adds some corner cases tests to increase coverage. JIRA NVGPU-4413 Change-Id: I77ed2f1cc4e31336f4815468be80b880f015dde7 Signed-off-by: Nicolas Benech Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2293848 Tested-by: mobile promotions Reviewed-by: mobile promotions --- userspace/units/mm/vm/vm.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/userspace/units/mm/vm/vm.c b/userspace/units/mm/vm/vm.c index eba9e17fc..f6c804956 100644 --- a/userspace/units/mm/vm/vm.c +++ b/userspace/units/mm/vm/vm.c @@ -157,6 +157,12 @@ static int hal_vm_as_alloc_share_error(struct gk20a *g, struct vm_gk20a *vm) return -1; } +/* Dummy HAL for vm_as_alloc_share that always succeeds */ +static int hal_vm_as_alloc_share_success(struct gk20a *g, struct vm_gk20a *vm) +{ + return 0; +} + /* Initialize test environment */ static int init_test_env(struct unit_module *m, struct gk20a *g) { @@ -583,6 +589,12 @@ static int map_buffer(struct unit_module *m, ret = UNIT_FAIL; goto free_vm_area; } + /* For branch coverage */ + if (nvgpu_vm_area_find(vm, 0) != NULL) { + unit_err(m, "nvgpu_vm_area_find did not fail as expected\n"); + ret = UNIT_FAIL; + goto free_vm_area; + } } } @@ -970,7 +982,7 @@ int test_init_error_paths(struct unit_module *m, struct gk20a *g, void *__args) g->ops.mm.gmmu.get_default_big_page_size(), low_hole, kernel_reserved, aperture_size, big_pages, true, true, __func__); - g->ops.mm.vm_as_alloc_share = NULL; + g->ops.mm.vm_as_alloc_share = hal_vm_as_alloc_share_success; if (ret != -1) { unit_err(m, "nvgpu_vm_do_init did not fail as expected (5).\n"); ret = UNIT_FAIL;