mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: add unit tests for pbdma_status
Add unit tests for: - nvgpu_pbdma_status_is_chsw_switch - nvgpu_pbdma_status_is_chsw_load - nvgpu_pbdma_status_is_chsw_save - nvgpu_pbdma_status_is_chsw_valid - nvgpu_pbdma_status_is_id_type_tsg - nvgpu_pbdma_status_is_next_id_type_tsg Jira NVGPU-3490 Change-Id: Iaf032b7a39483d1378945b269f16be8349dd6d7b Signed-off-by: Thomas Fleury <tfleury@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2241818 GVS: Gerrit_Virtual_Submit Reviewed-by: Philip Elcan <pelcan@nvidia.com> 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:
committed by
Alex Waterman
parent
162b93f435
commit
8ca378e1c0
@@ -30,6 +30,7 @@
|
||||
#include <nvgpu/types.h>
|
||||
#include <nvgpu/bitops.h>
|
||||
#include <nvgpu/pbdma.h>
|
||||
#include <nvgpu/pbdma_status.h>
|
||||
#include <nvgpu/gk20a.h>
|
||||
#include <nvgpu/fifo.h>
|
||||
#include <nvgpu/engines.h>
|
||||
@@ -201,10 +202,54 @@ done:
|
||||
}
|
||||
|
||||
|
||||
int test_pbdma_status(struct unit_module *m,
|
||||
struct gk20a *g, void *args)
|
||||
{
|
||||
int ret = UNIT_FAIL;
|
||||
struct nvgpu_pbdma_status_info pbdma_status;
|
||||
|
||||
memset(&pbdma_status, 0, sizeof(pbdma_status));
|
||||
for (pbdma_status.chsw_status = NVGPU_PBDMA_CHSW_STATUS_INVALID;
|
||||
pbdma_status.chsw_status <= NVGPU_PBDMA_CHSW_STATUS_SWITCH;
|
||||
pbdma_status.chsw_status++)
|
||||
{
|
||||
assert(nvgpu_pbdma_status_is_chsw_switch(&pbdma_status) ==
|
||||
(pbdma_status.chsw_status == NVGPU_PBDMA_CHSW_STATUS_SWITCH));
|
||||
assert(nvgpu_pbdma_status_is_chsw_load(&pbdma_status) ==
|
||||
(pbdma_status.chsw_status == NVGPU_PBDMA_CHSW_STATUS_LOAD));
|
||||
assert(nvgpu_pbdma_status_is_chsw_save(&pbdma_status) ==
|
||||
(pbdma_status.chsw_status == NVGPU_PBDMA_CHSW_STATUS_SAVE));
|
||||
assert(nvgpu_pbdma_status_is_chsw_valid(&pbdma_status) ==
|
||||
(pbdma_status.chsw_status == NVGPU_PBDMA_CHSW_STATUS_VALID));
|
||||
}
|
||||
|
||||
pbdma_status.id_type = PBDMA_STATUS_ID_TYPE_CHID;
|
||||
assert(nvgpu_pbdma_status_is_id_type_tsg(&pbdma_status) == false);
|
||||
pbdma_status.id_type = PBDMA_STATUS_ID_TYPE_TSGID;
|
||||
assert(nvgpu_pbdma_status_is_id_type_tsg(&pbdma_status) == true);
|
||||
pbdma_status.id_type = PBDMA_STATUS_ID_TYPE_INVALID;
|
||||
assert(nvgpu_pbdma_status_is_id_type_tsg(&pbdma_status) == false);
|
||||
|
||||
pbdma_status.next_id_type = PBDMA_STATUS_ID_TYPE_CHID;
|
||||
assert(nvgpu_pbdma_status_is_next_id_type_tsg(&pbdma_status) == false);
|
||||
pbdma_status.next_id_type = PBDMA_STATUS_ID_TYPE_TSGID;
|
||||
assert(nvgpu_pbdma_status_is_next_id_type_tsg(&pbdma_status) == true);
|
||||
pbdma_status.next_id_type = PBDMA_STATUS_ID_TYPE_INVALID;
|
||||
assert(nvgpu_pbdma_status_is_next_id_type_tsg(&pbdma_status) == false);
|
||||
|
||||
ret = UNIT_SUCCESS;
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct unit_module_test nvgpu_pbdma_tests[] = {
|
||||
UNIT_TEST(setup_sw, test_pbdma_setup_sw, &unit_ctx, 0),
|
||||
UNIT_TEST(init_support, test_fifo_init_support, &unit_ctx, 0),
|
||||
UNIT_TEST(pbdma_find_for_runlist, test_pbdma_find_for_runlist, &unit_ctx, 0),
|
||||
UNIT_TEST(pbdma_status, test_pbdma_status, &unit_ctx, 0),
|
||||
UNIT_TEST(remove_support, test_fifo_remove_support, &unit_ctx, 0),
|
||||
};
|
||||
|
||||
|
||||
@@ -81,6 +81,33 @@ int test_pbdma_setup_sw(struct unit_module *m,
|
||||
int test_pbdma_find_for_runlist(struct unit_module *m,
|
||||
struct gk20a *g, void *args);
|
||||
|
||||
/**
|
||||
* Test specification for: test_pbdma_status
|
||||
*
|
||||
* Description: Branch coverage for nvgpu_pbdma_status_* functions.
|
||||
*
|
||||
* Test Type: Feature based
|
||||
*
|
||||
* Input: test_fifo_init_support() run for this GPU.
|
||||
*
|
||||
* Steps:
|
||||
* - Build fake struct nvgpu_pbdma_status_info.
|
||||
* - Check that nvgpu_pbdma_status_is_chsw_switch is true when
|
||||
* chsw status is NVGPU_PBDMA_CHSW_STATUS_SWITCH, false otherwise.
|
||||
* - Check that nvgpu_pbdma_status_is_chsw_load is true when
|
||||
* chsw status is NVGPU_PBDMA_CHSW_STATUS_LOAD, false otherwise.
|
||||
* - Check that nvgpu_pbdma_status_is_chsw_save is true when
|
||||
* chsw status is NVGPU_PBDMA_CHSW_STATUS_SAVE, false otherwise.
|
||||
* - Check that nvgpu_pbdma_status_is_chsw_valid is true when
|
||||
* id_type is PBDMA_STATUS_ID_TYPE_TSGID, false otherwise.
|
||||
* - Check that nvgpu_pbdma_status_is_next_id_type_tsg is true when
|
||||
* next_id_type is PBDMA_STATUS_NEXT_ID_TYPE_TSGID, false otherwise.
|
||||
*
|
||||
* Output: Returns PASS if all branches gave expected results. FAIL otherwise.
|
||||
*/
|
||||
int test_pbdma_status(struct unit_module *m,
|
||||
struct gk20a *g, void *args);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user