mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: unit: add test for common.utils.string
Add unit test for the common.utils.string unit. JIRA NVGPU-4826 Change-Id: I4bfca346fb2202f9572199590f33a0461443fbc9 Signed-off-by: Philip Elcan <pelcan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2275456 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
0b0c4e6bd4
commit
f2e2b29194
116
userspace/units/interface/string/nvgpu-string.h
Normal file
116
userspace/units/interface/string/nvgpu-string.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 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"),
|
||||
* 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_STRING_H
|
||||
#define UNIT_STRING_H
|
||||
|
||||
struct gk20a;
|
||||
struct unit_module;
|
||||
|
||||
/** @addtogroup SWUTS-interface-string
|
||||
* @{
|
||||
*
|
||||
* Software Unit Test Specification for worker unit
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Test specification for: test_memcpy_memcmp
|
||||
*
|
||||
* Description: Test functionality of the utility functions nvgpu_memcpy and
|
||||
* nvgpu_memcmp.
|
||||
*
|
||||
* Test Type: Feature, Error guessing, Boundary values
|
||||
*
|
||||
* Targets: nvgpu_memcpy, nvgpu_memcmp
|
||||
*
|
||||
* Input: None.
|
||||
*
|
||||
* Steps:
|
||||
* - Initialize source array to the values 1-10.
|
||||
* - Initialize destination array to all 0's.
|
||||
* - Call nvgpu_memcpy with the source & destination arrays, passing the full
|
||||
* length.
|
||||
* - Call nvgpu_memcmp with the source & destination arrays, passing the full
|
||||
* length. Verify it returns a match.
|
||||
* - Re-init destination to 0.
|
||||
* - Call nvgpu_memcpy with the source & destination arrays, passing length-1.
|
||||
* - Call nvgpu_memcmp with the source & destination arrays, passing length-1.
|
||||
* Verify it returns a match.
|
||||
* - Verify the final element of the destination array is still 0.
|
||||
* - Call nvgpu_memcmp with the source & destination arrays, passing length.
|
||||
* Verify it returns a non-match.
|
||||
* - Call nvgpu_memcmp with a length 0. Verify a match is returned.
|
||||
*
|
||||
* Output: Returns PASS if expected result is met, FAIL otherwise.
|
||||
*/
|
||||
int test_memcpy_memcmp(struct unit_module *m, struct gk20a *g, void *args);
|
||||
|
||||
/**
|
||||
* Test specification for: test_strnadd_u32
|
||||
*
|
||||
* Description: Test functionality of the utility function test_strnadd_u32.
|
||||
*
|
||||
* Test Type: Feature, Error guessing, Boundary values
|
||||
*
|
||||
* Targets: nvgpu_strnadd_u32
|
||||
*
|
||||
* Input: None.
|
||||
*
|
||||
* Steps:
|
||||
* - Call nvgpu_strnadd_u32 with invalid radices. Verify 0 is returned.
|
||||
* - Call nvgpu_strnadd_u32 with an insufficient string size for the requested.
|
||||
* number. Verify 0 is returned.
|
||||
* - Call nvgpu_strnadd_u32 with a decimal value of 1000. Verify returned size
|
||||
* is 4 and the string contains "1000".
|
||||
* - Call nvgpu_strnadd_u32 with a hexidecimal value of 0xdeadbeef. Verify
|
||||
* returned size is 8 and the string contains "deadbeef".
|
||||
*
|
||||
* Output: Returns PASS if expected result is met, FAIL otherwise.
|
||||
*/
|
||||
int test_strnadd_u32(struct unit_module *m, struct gk20a *g, void *args);
|
||||
|
||||
/**
|
||||
* Test specification for: test_mem_is_word_aligned
|
||||
*
|
||||
* Description: Test functionality of the utility function
|
||||
* nvgpu_mem_is_word_aligned.
|
||||
*
|
||||
* Test Type: Feature, Error guessing, Boundary values
|
||||
*
|
||||
* Targets: nvgpu_mem_is_word_aligned
|
||||
*
|
||||
* Input: None.
|
||||
*
|
||||
* Steps:
|
||||
* - Call nvgpu_mem_is_word_aligned with various addresses and verify the
|
||||
* correct value is returned.
|
||||
*
|
||||
* Output: Returns PASS if expected result is met, FAIL otherwise.
|
||||
*/
|
||||
int test_mem_is_word_aligned(struct unit_module *m, struct gk20a *g, void *args);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* UNIT_STRING_H */
|
||||
Reference in New Issue
Block a user