gpu: nvgpu: unit: add test case for no SM detected

Set a stub that returns 0 instead of number of SM detected.
Ensure nvgpu_gr_fs_state_init() triggers a BUG and returns error.

Jira NVGPU-4778

Change-Id: I53ce36152a7f4bfe061ed9b5a532aa3b6995825a
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2277157
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Deepak Nibade
2020-01-09 16:33:07 +05:30
committed by Alex Waterman
parent 12bc49a078
commit 04285893f7
2 changed files with 21 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -40,10 +40,16 @@
#include "../nvgpu-gr.h"
#include "nvgpu-gr-fs-state.h"
static u32 gr_get_number_of_sm(struct gk20a *g)
{
return 0;
}
int test_gr_fs_state_error_injection(struct unit_module *m,
struct gk20a *g, void *args)
{
int err;
struct gpu_ops gops = g->ops;
struct nvgpu_gr_config *config = nvgpu_gr_get_config_ptr(g);
struct nvgpu_posix_fault_inj *kmem_fi =
nvgpu_kmem_get_fault_injection();
@@ -69,6 +75,16 @@ int test_gr_fs_state_error_injection(struct unit_module *m,
return UNIT_FAIL;
}
/* No SM is detected - failing case */
g->ops.gr.init.get_no_of_sm = gr_get_number_of_sm;
err = EXPECT_BUG(nvgpu_gr_fs_state_init(g, config));
if (err == 0) {
return UNIT_FAIL;
}
/* Restore gops */
g->ops = gops;
return UNIT_SUCCESS;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -50,6 +50,9 @@ struct unit_module;
* functions called from #nvgpu_gr_fs_state_init.
* - Call #nvgpu_gr_fs_state_init and ensure that function returns
* error.
* - Set stub function for g->ops.gr.init.get_no_of_sm() which returns 0,
* meaning no SM was detected. nvgpu_gr_fs_state_init() should return
* error, and also a BUG is detected.
*
* - Positive test.
* - Disable all fault injections.