mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: unit: add negative tests for common.gr.fs_state
Add negative tests that inject memory allocation failures and verify error handling path in common.gr.fs_state unit. Jira NVGPU-4373 Change-Id: If8774a60ffc951bd2c9978196268c20e10188026 Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2247846 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Alex Waterman
parent
04adc71304
commit
d58e14e4d0
@@ -94,6 +94,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/gr/falcon
|
|||||||
NV_REPOSITORY_COMPONENTS += userspace/units/gr/config
|
NV_REPOSITORY_COMPONENTS += userspace/units/gr/config
|
||||||
NV_REPOSITORY_COMPONENTS += userspace/units/gr/init
|
NV_REPOSITORY_COMPONENTS += userspace/units/gr/init
|
||||||
NV_REPOSITORY_COMPONENTS += userspace/units/gr/setup
|
NV_REPOSITORY_COMPONENTS += userspace/units/gr/setup
|
||||||
|
NV_REPOSITORY_COMPONENTS += userspace/units/gr/fs_state
|
||||||
NV_REPOSITORY_COMPONENTS += userspace/units/gr/intr
|
NV_REPOSITORY_COMPONENTS += userspace/units/gr/intr
|
||||||
NV_REPOSITORY_COMPONENTS += userspace/units/acr
|
NV_REPOSITORY_COMPONENTS += userspace/units/acr
|
||||||
NV_REPOSITORY_COMPONENTS += userspace/units/cg
|
NV_REPOSITORY_COMPONENTS += userspace/units/cg
|
||||||
|
|||||||
@@ -223,6 +223,8 @@ nvgpu_gr_config_set_gpc_tpc_mask
|
|||||||
nvgpu_gr_config_get_gpc_tpc_mask
|
nvgpu_gr_config_get_gpc_tpc_mask
|
||||||
nvgpu_gr_obj_ctx_is_golden_image_ready
|
nvgpu_gr_obj_ctx_is_golden_image_ready
|
||||||
nvgpu_gr_ctx_get_tsgid
|
nvgpu_gr_ctx_get_tsgid
|
||||||
|
nvgpu_gr_get_config_ptr
|
||||||
|
nvgpu_gr_fs_state_init
|
||||||
nvgpu_hr_timestamp
|
nvgpu_hr_timestamp
|
||||||
nvgpu_init_ltc_support
|
nvgpu_init_ltc_support
|
||||||
nvgpu_ltc_ecc_free
|
nvgpu_ltc_ecc_free
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ UNITS := \
|
|||||||
$(UNIT_SRC)/gr/falcon \
|
$(UNIT_SRC)/gr/falcon \
|
||||||
$(UNIT_SRC)/gr/config \
|
$(UNIT_SRC)/gr/config \
|
||||||
$(UNIT_SRC)/gr/init \
|
$(UNIT_SRC)/gr/init \
|
||||||
|
$(UNIT_SRC)/gr/fs_state \
|
||||||
$(UNIT_SRC)/gr/intr \
|
$(UNIT_SRC)/gr/intr \
|
||||||
$(UNIT_SRC)/gr/setup \
|
$(UNIT_SRC)/gr/setup \
|
||||||
$(UNIT_SRC)/acr \
|
$(UNIT_SRC)/acr \
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
* - @ref SWUTS-gr-setup
|
* - @ref SWUTS-gr-setup
|
||||||
* - @ref SWUTS-gr-intr
|
* - @ref SWUTS-gr-intr
|
||||||
* - @ref SWUTS-gr-falcon
|
* - @ref SWUTS-gr-falcon
|
||||||
|
* - @ref SWUTS-gr-fs-state
|
||||||
* - @ref SWUTS-gr-config
|
* - @ref SWUTS-gr-config
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,4 +51,5 @@ INPUT += ../../../userspace/units/gr/nvgpu-gr.h
|
|||||||
INPUT += ../../../userspace/units/gr/setup/nvgpu-gr-setup.h
|
INPUT += ../../../userspace/units/gr/setup/nvgpu-gr-setup.h
|
||||||
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-intr.h
|
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-intr.h
|
||||||
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-falcon.h
|
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-falcon.h
|
||||||
|
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-fs-state.h
|
||||||
INPUT += ../../../userspace/units/gr/config/nvgpu-gr-config.h
|
INPUT += ../../../userspace/units/gr/config/nvgpu-gr-config.h
|
||||||
|
|||||||
@@ -1577,6 +1577,24 @@
|
|||||||
"unit": "nvgpu_gr_setup",
|
"unit": "nvgpu_gr_setup",
|
||||||
"test_level": 0
|
"test_level": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"test": "test_gr_init_setup_ready",
|
||||||
|
"case": "gr_fs_state_setup",
|
||||||
|
"unit": "nvgpu_gr_fs_state",
|
||||||
|
"test_level": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "test_gr_fs_state_error_injection",
|
||||||
|
"case": "gr_fs_state_error_injection",
|
||||||
|
"unit": "nvgpu_gr_fs_state",
|
||||||
|
"test_level": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "test_gr_init_setup_cleanup",
|
||||||
|
"case": "gr_fs_state_cleanup",
|
||||||
|
"unit": "nvgpu_gr_fs_state",
|
||||||
|
"test_level": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"test": "test_nvgpu_mem_create_from_phys",
|
"test": "test_nvgpu_mem_create_from_phys",
|
||||||
"case": "mem_create_from_phys",
|
"case": "mem_create_from_phys",
|
||||||
|
|||||||
33
userspace/units/gr/fs_state/Makefile
Normal file
33
userspace/units/gr/fs_state/Makefile
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Copyright (c) 2019, 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"),
|
||||||
|
# to deal in the Software without restriction, including without limitation
|
||||||
|
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
# and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
# Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
.SUFFIXES:
|
||||||
|
|
||||||
|
OBJS = nvgpu-gr-fs-state.o
|
||||||
|
MODULE = nvgpu-gr-fs-state
|
||||||
|
|
||||||
|
LIB_PATHS += -lnvgpu-gr
|
||||||
|
include ../../Makefile.units
|
||||||
|
|
||||||
|
lib$(MODULE).so: nvgpu-gr
|
||||||
|
|
||||||
|
nvgpu-gr:
|
||||||
|
$(MAKE) -C ..
|
||||||
|
|
||||||
35
userspace/units/gr/fs_state/Makefile.interface.tmk
Normal file
35
userspace/units/gr/fs_state/Makefile.interface.tmk
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
################################### tell Emacs this is a -*- makefile-gmake -*-
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019, 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"),
|
||||||
|
# to deal in the Software without restriction, including without limitation
|
||||||
|
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
# and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
# Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
# tmake for SW Mobile component makefile
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
NVGPU_UNIT_NAME=nvgpu-gr-fs-state
|
||||||
|
|
||||||
|
include $(NV_COMPONENT_DIR)/../../Makefile.units.common.interface.tmk
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# indent-tabs-mode: t
|
||||||
|
# tab-width: 8
|
||||||
|
# End:
|
||||||
|
# vi: set tabstop=8 noexpandtab:
|
||||||
40
userspace/units/gr/fs_state/Makefile.tmk
Normal file
40
userspace/units/gr/fs_state/Makefile.tmk
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
################################### tell Emacs this is a -*- makefile-gmake -*-
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019, 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"),
|
||||||
|
# to deal in the Software without restriction, including without limitation
|
||||||
|
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
# and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
# Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
# tmake for SW Mobile component makefile
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
NVGPU_UNIT_NAME = nvgpu-gr-fs-state
|
||||||
|
NVGPU_UNIT_SRCS = nvgpu-gr-fs-state.c
|
||||||
|
|
||||||
|
NVGPU_UNIT_INTERFACE_DIRS := \
|
||||||
|
$(NV_COMPONENT_DIR)/.. \
|
||||||
|
$(NV_SOURCE)/kernel/nvgpu/drivers/gpu/nvgpu
|
||||||
|
|
||||||
|
include $(NV_COMPONENT_DIR)/../../Makefile.units.common.tmk
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# indent-tabs-mode: t
|
||||||
|
# tab-width: 8
|
||||||
|
# End:
|
||||||
|
# vi: set tabstop=8 noexpandtab:
|
||||||
81
userspace/units/gr/fs_state/nvgpu-gr-fs-state.c
Normal file
81
userspace/units/gr/fs_state/nvgpu-gr-fs-state.c
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, 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"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <unit/unit.h>
|
||||||
|
#include <unit/io.h>
|
||||||
|
|
||||||
|
#include <nvgpu/posix/io.h>
|
||||||
|
#include <nvgpu/gk20a.h>
|
||||||
|
#include <nvgpu/gr/gr.h>
|
||||||
|
#include <nvgpu/gr/config.h>
|
||||||
|
#include <nvgpu/gr/fs_state.h>
|
||||||
|
#include <nvgpu/gr/gr_utils.h>
|
||||||
|
|
||||||
|
#include <nvgpu/posix/posix-fault-injection.h>
|
||||||
|
|
||||||
|
#include "common/gr/gr_priv.h"
|
||||||
|
|
||||||
|
#include "../nvgpu-gr.h"
|
||||||
|
#include "nvgpu-gr-fs-state.h"
|
||||||
|
|
||||||
|
int test_gr_fs_state_error_injection(struct unit_module *m,
|
||||||
|
struct gk20a *g, void *args)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
struct nvgpu_gr_config *config = nvgpu_gr_get_config_ptr(g);
|
||||||
|
struct nvgpu_posix_fault_inj *kmem_fi =
|
||||||
|
nvgpu_kmem_get_fault_injection();
|
||||||
|
|
||||||
|
/* Fail g->ops.gr.config.init_sm_id_table() */
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, true, 1);
|
||||||
|
err = nvgpu_gr_fs_state_init(g, config);
|
||||||
|
if (err == 0) {
|
||||||
|
return UNIT_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fail gr_load_sm_id_config() */
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, true, 13);
|
||||||
|
err = nvgpu_gr_fs_state_init(g, config);
|
||||||
|
if (err == 0) {
|
||||||
|
return UNIT_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Passing case */
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, false, 0);
|
||||||
|
err = nvgpu_gr_fs_state_init(g, config);
|
||||||
|
if (err != 0) {
|
||||||
|
return UNIT_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return UNIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct unit_module_test nvgpu_gr_fs_state_tests[] = {
|
||||||
|
UNIT_TEST(gr_fs_state_setup, test_gr_init_setup_ready, NULL, 0),
|
||||||
|
UNIT_TEST(gr_fs_state_error_injection, test_gr_fs_state_error_injection, NULL, 0),
|
||||||
|
UNIT_TEST(gr_fs_state_cleanup, test_gr_init_setup_cleanup, NULL, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
UNIT_MODULE(nvgpu_gr_fs_state, nvgpu_gr_fs_state_tests, UNIT_PRIO_NVGPU_TEST);
|
||||||
70
userspace/units/gr/fs_state/nvgpu-gr-fs-state.h
Normal file
70
userspace/units/gr/fs_state/nvgpu-gr-fs-state.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, 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"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef UNIT_NVGPU_GR_FS_STATE_H
|
||||||
|
#define UNIT_NVGPU_GR_FS_STATE_H
|
||||||
|
|
||||||
|
#include <nvgpu/types.h>
|
||||||
|
|
||||||
|
struct gk20a;
|
||||||
|
struct unit_module;
|
||||||
|
|
||||||
|
/** @addtogroup SWUTS-gr-fs-state
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* Software Unit Test Specification for common.gr.fs_state
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test specification for: test_gr_fs_state_error_injection.
|
||||||
|
*
|
||||||
|
* Description: Verify error handling in #nvgpu_gr_fs_state_init()
|
||||||
|
*
|
||||||
|
* Test Type: Feature based, Error guessing.
|
||||||
|
*
|
||||||
|
* Targets: #nvgpu_gr_fs_state_init.
|
||||||
|
*
|
||||||
|
* Input: gr_fs_state_setup must have been executed successfully.
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* - Negative tests.
|
||||||
|
* - Inject faults to trigger memory allocation failures in various
|
||||||
|
* functions called from #nvgpu_gr_fs_state_init.
|
||||||
|
* - Call #nvgpu_gr_fs_state_init and ensure that function returns
|
||||||
|
* error.
|
||||||
|
*
|
||||||
|
* - Positive test.
|
||||||
|
* - Disable all fault injections.
|
||||||
|
* - Call #nvgpu_gr_fs_state_init and ensure that function returns
|
||||||
|
* success.
|
||||||
|
*
|
||||||
|
* Output: Returns PASS if the steps above were executed successfully. FAIL
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
int test_gr_fs_state_error_injection(struct unit_module *m,
|
||||||
|
struct gk20a *g, void *args);
|
||||||
|
|
||||||
|
#endif /* UNIT_NVGPU_GR_FS_STATE_H */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
Reference in New Issue
Block a user