mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 18:16:01 +03:00
gpu: nvgpu: add bvec tests for utils
Add boundary value tests for common utils unit. JIRA NVGPU-6395 Change-Id: I4442f339c0238e7ee8a44277ca5f53db9c71f367 Signed-off-by: ajesh <akv@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2542636 (cherry picked from commit 125d73582d57b673b155ada6ce7430401d56dbc3) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2548579 Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Rajesh Devaraj <rdevaraj@nvidia.com> Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2019-2021, 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"),
|
||||
@@ -108,6 +108,55 @@ int test_nvgpu_set_enabled(struct unit_module *m,
|
||||
return UNIT_SUCCESS;
|
||||
}
|
||||
|
||||
int test_nvgpu_enabled_bvec(struct unit_module *m,
|
||||
struct gk20a *g, void *args)
|
||||
{
|
||||
u32 n = 0;
|
||||
|
||||
nvgpu_set_enabled(g, n, true);
|
||||
if (!nvgpu_is_enabled(g, n)) {
|
||||
g->enabled_flags = original_enabled_flags;
|
||||
unit_return_fail(m, "enabled_flag not set for %u\n", n);
|
||||
}
|
||||
|
||||
n = NVGPU_MAX_ENABLED_BITS - 1;
|
||||
nvgpu_set_enabled(g, n, true);
|
||||
if (!nvgpu_is_enabled(g, n)) {
|
||||
g->enabled_flags = original_enabled_flags;
|
||||
unit_return_fail(m, "enabled_flag not set for %u\n", n);
|
||||
}
|
||||
|
||||
n = NVGPU_MAX_ENABLED_BITS/2;
|
||||
nvgpu_set_enabled(g, n, true);
|
||||
if (!nvgpu_is_enabled(g, n)) {
|
||||
g->enabled_flags = original_enabled_flags;
|
||||
unit_return_fail(m, "enabled_flag not set for %u\n", n);
|
||||
}
|
||||
|
||||
n = NVGPU_MAX_ENABLED_BITS;
|
||||
nvgpu_set_enabled(g, n, true);
|
||||
if (nvgpu_is_enabled(g, n)) {
|
||||
g->enabled_flags = original_enabled_flags;
|
||||
unit_return_fail(m, "enabled_flag set for %u\n", n);
|
||||
}
|
||||
|
||||
n = NVGPU_MAX_ENABLED_BITS + 1;
|
||||
nvgpu_set_enabled(g, n, true);
|
||||
if (nvgpu_is_enabled(g, n)) {
|
||||
g->enabled_flags = original_enabled_flags;
|
||||
unit_return_fail(m, "enabled_flag set for %u\n", n);
|
||||
}
|
||||
|
||||
n = UINT32_MAX;
|
||||
nvgpu_set_enabled(g, n, true);
|
||||
if (nvgpu_is_enabled(g, n)) {
|
||||
g->enabled_flags = original_enabled_flags;
|
||||
unit_return_fail(m, "enabled_flag set for %u\n", n);
|
||||
}
|
||||
|
||||
return UNIT_SUCCESS;
|
||||
}
|
||||
|
||||
int test_nvgpu_free_enabled_flags(struct unit_module *m,
|
||||
struct gk20a *g, void *args)
|
||||
{
|
||||
@@ -124,8 +173,9 @@ struct unit_module_test enabled_tests[] = {
|
||||
|
||||
UNIT_TEST(enabled_flags_false_check, test_nvgpu_enabled_flags_false_check, NULL, 0),
|
||||
UNIT_TEST(set_enabled, test_nvgpu_set_enabled, NULL, 0),
|
||||
UNIT_TEST(bvec_enabled, test_nvgpu_enabled_bvec, NULL, 0),
|
||||
|
||||
UNIT_TEST(free, test_nvgpu_free_enabled_flags, NULL, 0),
|
||||
};
|
||||
|
||||
UNIT_MODULE(enabled, enabled_tests, UNIT_PRIO_NVGPU_TEST);
|
||||
UNIT_MODULE(enabled, enabled_tests, UNIT_PRIO_NVGPU_TEST);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2019-2021, 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"),
|
||||
@@ -101,6 +101,49 @@ int test_nvgpu_enabled_flags_false_check(struct unit_module *m,
|
||||
*/
|
||||
int test_nvgpu_set_enabled(struct unit_module *m, struct gk20a *g, void *args);
|
||||
|
||||
/**
|
||||
* Test specification for: test_nvgpu_enabled_bvec
|
||||
*
|
||||
* Description: Boundary check for flag setting and checking.
|
||||
*
|
||||
* Test Type: Boundary value
|
||||
*
|
||||
* Targets: nvgpu_is_enabled, nvgpu_set_enabled
|
||||
*
|
||||
* Input: test_nvgpu_init_enabled_flags
|
||||
*
|
||||
* Equivalence classes:
|
||||
* Variable: flag
|
||||
* - Valid : { 0 - (NVGPU_MAX_ENABLED_BITS - 1) }
|
||||
* - Invalid : { NVGPU_MAX_ENABLED_BITS - UINT32_MAX }
|
||||
*
|
||||
* Steps:
|
||||
* - Set and check flag for bit position 0. The set API nvgpu_set_enabled
|
||||
* should set the value and the check API nvgpu_is_enabled should return 1.
|
||||
* - Set and check flag for bit position NVGPU_MAX_ENABLED_BITS - 1. The set
|
||||
* API nvgpu_set_enabled should set the value and the check API
|
||||
* nvgpu_is_enabled should return 1.
|
||||
* - Set and check flag for bit position NVGPU_MAX_ENABLED_BITS/2. The set API
|
||||
* nvgpu_set_enabled should set the value and the check API nvgpu_is_enabled
|
||||
* should return 1.
|
||||
* - Try to set and check flag for bit position NVGPU_MAX_ENABLED_BITS. The
|
||||
* set API nvgpu_set_enabled should return without doing any operation and
|
||||
* the check API nvgpu_is_enabled should return 0 indicating an error for
|
||||
* flag boundary value.
|
||||
* - Try to set and check flag for bit position NVGPU_MAX_ENABLED_BITS + 1. The
|
||||
* set API nvgpu_set_enabled should return without doing any operation and
|
||||
* the check API nvgpu_is_enabled should return 0 indicating an error for
|
||||
* flag boundary value.
|
||||
* - Try to set and check flag for bit position UINT32_MAX. The set API
|
||||
* nvgpu_set_enabled should return without doing any operation and
|
||||
* the check API nvgpu_is_enabled should return 0 indicating an error for
|
||||
* flag boundary value.
|
||||
*
|
||||
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
|
||||
* otherwise.
|
||||
*/
|
||||
int test_nvgpu_enabled_bvec(struct unit_module *m, struct gk20a *g, void *args);
|
||||
|
||||
/**
|
||||
* Test specification for: test_nvgpu_free_enabled_flags
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user