mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 09:57:08 +03:00
gpu: nvgpu: Add more test coverage for common.netlist
Add more line and branch coverage in unit test for common.netlist unit Jira NVGPU-4920 Change-Id: I6991a584b22b1d3724b665dc2a04a30f172d5c11 Signed-off-by: vinodg <vinodg@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2286762 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
@@ -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
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <unit/unit.h>
|
#include <unit/unit.h>
|
||||||
|
|
||||||
#include <nvgpu/gk20a.h>
|
#include <nvgpu/gk20a.h>
|
||||||
|
#include <nvgpu/posix/posix-fault-injection.h>
|
||||||
#include <nvgpu/posix/io.h>
|
#include <nvgpu/posix/io.h>
|
||||||
#include <nvgpu/hal_init.h>
|
#include <nvgpu/hal_init.h>
|
||||||
#include <nvgpu/enabled.h>
|
#include <nvgpu/enabled.h>
|
||||||
@@ -208,10 +209,29 @@ int test_netlist_query_tests(struct unit_module *m,
|
|||||||
return UNIT_SUCCESS;
|
return UNIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_netlist_alloc_failure(struct gk20a *g)
|
||||||
|
{
|
||||||
|
int err, i;
|
||||||
|
struct nvgpu_posix_fault_inj *kmem_fi =
|
||||||
|
nvgpu_kmem_get_fault_injection();
|
||||||
|
|
||||||
|
for (i = 0; i < 12; i++) {
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, true, i);
|
||||||
|
err = nvgpu_netlist_init_ctx_vars(g);
|
||||||
|
if (err == 0) {
|
||||||
|
return UNIT_FAIL;
|
||||||
|
}
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, false, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return UNIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int test_netlist_negative_tests(struct unit_module *m,
|
int test_netlist_negative_tests(struct unit_module *m,
|
||||||
struct gk20a *g, void *args)
|
struct gk20a *g, void *args)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
struct nvgpu_netlist_vars *netlist_vars = g->netlist_vars;
|
||||||
|
|
||||||
err = nvgpu_netlist_init_ctx_vars(g);
|
err = nvgpu_netlist_init_ctx_vars(g);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
@@ -219,7 +239,18 @@ int test_netlist_negative_tests(struct unit_module *m,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* unload netlist info */
|
/* unload netlist info */
|
||||||
|
/* with NULL pointer */
|
||||||
|
g->netlist_vars = NULL;
|
||||||
nvgpu_netlist_deinit_ctx_vars(g);
|
nvgpu_netlist_deinit_ctx_vars(g);
|
||||||
|
/* restore valid pointer */
|
||||||
|
g->netlist_vars = netlist_vars;
|
||||||
|
nvgpu_netlist_deinit_ctx_vars(g);
|
||||||
|
|
||||||
|
err = test_netlist_alloc_failure(g);
|
||||||
|
if (err != 0) {
|
||||||
|
unit_return_fail(m, "nvgpu_netlist_init_ctx_vars_fw failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* Set up HAL for invalid netlist checks */
|
/* Set up HAL for invalid netlist checks */
|
||||||
g->ops.netlist.is_fw_defined = test_netlist_fw_not_defined;
|
g->ops.netlist.is_fw_defined = test_netlist_fw_not_defined;
|
||||||
g->ops.gr.falcon.get_fecs_ctx_state_store_major_rev_id =
|
g->ops.gr.falcon.get_fecs_ctx_state_store_major_rev_id =
|
||||||
@@ -228,6 +259,7 @@ int test_netlist_negative_tests(struct unit_module *m,
|
|||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
unit_return_fail(m, "nvgpu_netlist_init_ctx_vars_fw failed\n");
|
unit_return_fail(m, "nvgpu_netlist_init_ctx_vars_fw failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore orginal HALs */
|
/* Restore orginal HALs */
|
||||||
g->ops.netlist.is_fw_defined = gv11b_netlist_is_firmware_defined;
|
g->ops.netlist.is_fw_defined = gv11b_netlist_is_firmware_defined;
|
||||||
g->ops.gr.falcon.get_fecs_ctx_state_store_major_rev_id =
|
g->ops.gr.falcon.get_fecs_ctx_state_store_major_rev_id =
|
||||||
|
|||||||
@@ -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
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -38,6 +38,14 @@
|
|||||||
*
|
*
|
||||||
* Test Type: Feature
|
* Test Type: Feature
|
||||||
*
|
*
|
||||||
|
* Targets: nvgpu_netlist_init_ctx_vars,
|
||||||
|
* gv11b_netlist_is_firmware_defined,
|
||||||
|
* gv11b_netlist_get_name,
|
||||||
|
* nvgpu_netlist_alloc_u32_list,
|
||||||
|
* nvgpu_netlist_alloc_aiv_list,
|
||||||
|
* nvgpu_netlist_alloc_av_list,
|
||||||
|
* nvgpu_netlist_alloc_av64_list
|
||||||
|
*
|
||||||
* Input: None
|
* Input: None
|
||||||
*
|
*
|
||||||
* Steps:
|
* Steps:
|
||||||
@@ -64,6 +72,21 @@ int test_netlist_init_support(struct unit_module *m,
|
|||||||
*
|
*
|
||||||
* Test Type: Feature
|
* Test Type: Feature
|
||||||
*
|
*
|
||||||
|
* Targets: nvgpu_netlist_get_sw_non_ctx_load_av_list,
|
||||||
|
* nvgpu_netlist_get_sw_ctx_load_aiv_list,
|
||||||
|
* nvgpu_netlist_get_sw_method_init_av_list,
|
||||||
|
* nvgpu_netlist_get_sw_bundle_init_av_list,
|
||||||
|
* nvgpu_netlist_get_sw_veid_bundle_init_av_list,
|
||||||
|
* nvgpu_netlist_get_sw_bundle64_init_av64_list,
|
||||||
|
* nvgpu_netlist_get_fecs_inst_count,
|
||||||
|
* nvgpu_netlist_get_fecs_data_count,
|
||||||
|
* nvgpu_netlist_get_gpccs_inst_count,
|
||||||
|
* nvgpu_netlist_get_gpccs_data_count,
|
||||||
|
* nvgpu_netlist_get_fecs_inst_list,
|
||||||
|
* nvgpu_netlist_get_fecs_data_list,
|
||||||
|
* nvgpu_netlist_get_gpccs_inst_list,
|
||||||
|
* nvgpu_netlist_get_gpccs_data_list
|
||||||
|
*
|
||||||
* Input: None
|
* Input: None
|
||||||
*
|
*
|
||||||
* Steps:
|
* Steps:
|
||||||
@@ -94,13 +117,17 @@ int test_netlist_query_tests(struct unit_module *m,
|
|||||||
*
|
*
|
||||||
* Description: This test covers negative paths in netlist init.
|
* Description: This test covers negative paths in netlist init.
|
||||||
*
|
*
|
||||||
* Test Type: Feature
|
* Test Type: Feature, Error Injection
|
||||||
|
*
|
||||||
|
* Targets: nvgpu_netlist_init_ctx_vars,
|
||||||
|
* nvgpu_netlist_deinit_ctx_vars
|
||||||
*
|
*
|
||||||
* Input: None
|
* Input: None
|
||||||
*
|
*
|
||||||
* Steps:
|
* Steps:
|
||||||
* - Call nvgpu_netlist_init_ctx_vars after already initilized netlist
|
* - Call nvgpu_netlist_init_ctx_vars after already initilized netlist
|
||||||
* - Call nvgpu_netlist_deinit_ctx_vars
|
* - Call nvgpu_netlist_deinit_ctx_vars
|
||||||
|
* - Call nvgpu_netlist_init_ctx_vars injecting allocation failures.
|
||||||
* - Set HALs with no netlist defined and invalid netlist check
|
* - Set HALs with no netlist defined and invalid netlist check
|
||||||
* - Call nvgpu_netlist_init_ctx_vars with above test HALs
|
* - Call nvgpu_netlist_init_ctx_vars with above test HALs
|
||||||
* - Restore orginals HALs
|
* - Restore orginals HALs
|
||||||
@@ -119,6 +146,8 @@ int test_netlist_negative_tests(struct unit_module *m,
|
|||||||
*
|
*
|
||||||
* Test Type: Feature
|
* Test Type: Feature
|
||||||
*
|
*
|
||||||
|
* Targets: nvgpu_netlist_deinit_ctx_vars
|
||||||
|
*
|
||||||
* Input: None
|
* Input: None
|
||||||
*
|
*
|
||||||
* Steps:
|
* Steps:
|
||||||
|
|||||||
Reference in New Issue
Block a user