gpu: nvgpu: unit: add negative tests for common.gr.obj_ctx

Add negative tests that inject memory allocation failures and
HAL function call errors to verify error handling path in
common.gr.obj_ctx unit.

Update common.gr.setup test to cover invalid class input while
setting preemption mode.

Jira NVGPU-4457

Change-Id: I74d1ba63ba8aace6087b51fd50e2c136822d3a00
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2260939
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Deepak Nibade
2019-12-04 19:32:51 +05:30
committed by Alex Waterman
parent 34020a5999
commit fdb8046812
15 changed files with 707 additions and 0 deletions

View File

@@ -35,6 +35,26 @@
#include "global_ctx_priv.h"
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
#include <nvgpu/posix/posix-fault-injection.h>
struct nvgpu_posix_fault_inj *nvgpu_golden_ctx_verif_get_fault_injection(void)
{
struct nvgpu_posix_fault_inj_container *c =
nvgpu_posix_fault_injection_get_container();
return &c->golden_ctx_verif_fi;
}
struct nvgpu_posix_fault_inj *nvgpu_local_golden_image_get_fault_injection(void)
{
struct nvgpu_posix_fault_inj_container *c =
nvgpu_posix_fault_injection_get_container();
return &c->local_golden_image_fi;
}
#endif
struct nvgpu_gr_global_ctx_buffer_desc *
nvgpu_gr_global_ctx_desc_alloc(struct gk20a *g)
{
@@ -311,6 +331,13 @@ nvgpu_gr_global_ctx_init_local_golden_image(struct gk20a *g,
{
struct nvgpu_gr_global_ctx_local_golden_image *local_golden_image;
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
if (nvgpu_posix_fault_injection_handle_call(
nvgpu_local_golden_image_get_fault_injection())) {
return NULL;
}
#endif
local_golden_image = nvgpu_kzalloc(g, sizeof(*local_golden_image));
if (local_golden_image == NULL) {
return NULL;
@@ -345,6 +372,13 @@ bool nvgpu_gr_global_ctx_compare_golden_images(struct gk20a *g,
u32 i;
#endif
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
if (nvgpu_posix_fault_injection_handle_call(
nvgpu_golden_ctx_verif_get_fault_injection())) {
return false;
}
#endif
/*
* In case of sysmem, direct mem compare can be used.
* For vidmem, word by word comparison only works and

View File

@@ -314,6 +314,11 @@ bool nvgpu_gr_global_ctx_compare_golden_images(struct gk20a *g,
size_t size);
#endif
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
struct nvgpu_posix_fault_inj *nvgpu_golden_ctx_verif_get_fault_injection(void);
struct nvgpu_posix_fault_inj *nvgpu_local_golden_image_get_fault_injection(void);
#endif
#ifdef CONFIG_NVGPU_DEBUGGER
u32 *nvgpu_gr_global_ctx_get_local_golden_image_ptr(
struct nvgpu_gr_global_ctx_local_golden_image *local_golden_image);

View File

@@ -42,6 +42,8 @@ struct nvgpu_posix_fault_inj_container {
struct nvgpu_posix_fault_inj fread_op;
struct nvgpu_posix_fault_inj kmem_fi;
struct nvgpu_posix_fault_inj nvgpu_fi;
struct nvgpu_posix_fault_inj golden_ctx_verif_fi;
struct nvgpu_posix_fault_inj local_golden_image_fi;
struct nvgpu_posix_fault_inj dma_fi;
struct nvgpu_posix_fault_inj queue_out_fi;
struct nvgpu_posix_fault_inj timers_fi;

View File

@@ -366,6 +366,14 @@ nvgpu_gr_ctx_map_global_ctx_buffers
nvgpu_gr_ctx_patch_write_begin
nvgpu_gr_ctx_patch_write
nvgpu_gr_ctx_patch_write_end
nvgpu_golden_ctx_verif_get_fault_injection
nvgpu_local_golden_image_get_fault_injection
nvgpu_gr_obj_ctx_init
nvgpu_gr_obj_ctx_alloc
nvgpu_gr_obj_ctx_deinit
nvgpu_gr_subctx_alloc
nvgpu_gr_subctx_free
nvgpu_gr_obj_ctx_set_ctxsw_preemption_mode
nvgpu_hr_timestamp
nvgpu_init_ltc_support
nvgpu_ltc_ecc_free