mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +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) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2020-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"),
|
||||
@@ -60,20 +60,38 @@ int test_memcpy_memcmp(struct unit_module *m, struct gk20a *g, void *args)
|
||||
|
||||
int test_strnadd_u32(struct unit_module *m, struct gk20a *g, void *args)
|
||||
{
|
||||
const size_t len = 10;
|
||||
const size_t len = 40;
|
||||
char dest[len];
|
||||
const char *max_str = "11111111111111111111111111111111";
|
||||
|
||||
/* test invalid radices */
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 10U, len, 0U) == 0,
|
||||
return UNIT_FAIL);
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 10U, len, 1U) == 0,
|
||||
return UNIT_FAIL);
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 10U, len, 17U) == 0,
|
||||
return UNIT_FAIL);
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 10U, len, 100U) == 0,
|
||||
return UNIT_FAIL);
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 10U, len, UINT32_MAX) == 0,
|
||||
return UNIT_FAIL);
|
||||
|
||||
/* test insufficient space */
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 1000U, 0, 10U) == 0,
|
||||
return UNIT_FAIL);
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 1000U, 2, 10U) == 0,
|
||||
return UNIT_FAIL);
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 1000U, 4, 10U) == 0,
|
||||
return UNIT_FAIL);
|
||||
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 1U, len, 2U) == 1,
|
||||
return UNIT_FAIL);
|
||||
unit_assert(strncmp(dest, "1", 4) == 0, return UNIT_FAIL);
|
||||
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 0xffffffff, len, 2U) == 32,
|
||||
return UNIT_FAIL);
|
||||
unit_assert(strncmp(dest, max_str, 32) == 0, return UNIT_FAIL);
|
||||
|
||||
unit_assert(nvgpu_strnadd_u32(dest, 1000U, len, 10U) == 4,
|
||||
return UNIT_FAIL);
|
||||
unit_assert(strncmp(dest, "1000", 4) == 0, return UNIT_FAIL);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2020-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"),
|
||||
@@ -76,13 +76,25 @@ int test_memcpy_memcmp(struct unit_module *m, struct gk20a *g, void *args);
|
||||
*
|
||||
* Input: None.
|
||||
*
|
||||
* Equivalence classes:
|
||||
* Variable: radix
|
||||
* - Valid: { 2 - 16 }
|
||||
* - Invalid: { 0, 1, 17 - UINT32_MAX }
|
||||
*
|
||||
* 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 invalid radix 0. Verify 0 is returned.
|
||||
* - Call nvgpu_strnadd_u32 with invalid radix 1. Verify 0 is returned.
|
||||
* - Call nvgpu_strnadd_u32 with invalid radix 17. Verify 0 is returned.
|
||||
* - Call nvgpu_strnadd_u32 with invalid radix 100. Verify 0 is returned.
|
||||
* - Call nvgpu_strnadd_u32 with invalid radix UINT32_MAX. Verify 0 is
|
||||
* returned.
|
||||
* - Call nvgpu_strnadd_u32 with insufficient string sizes. Verify 0 is
|
||||
* returned.
|
||||
* - Call nvgpu_strnadd_u32 with a binary value of 10. Verify returned size
|
||||
* is 4 and the string contains "1010".
|
||||
* - 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
|
||||
* - Call nvgpu_strnadd_u32 with a hexadecimal value of 0xdeadbeef. Verify
|
||||
* returned size is 8 and the string contains "deadbeef".
|
||||
*
|
||||
* Output: Returns PASS if expected result is met, FAIL otherwise.
|
||||
|
||||
Reference in New Issue
Block a user