mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +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);
|
||||
|
||||
Reference in New Issue
Block a user