From 7601d1c620891ce2373e5c10ea0dcc75a66f52d1 Mon Sep 17 00:00:00 2001 From: Philip Elcan Date: Thu, 9 Jan 2020 13:05:02 -0500 Subject: [PATCH] gpu: nvgpu: unit: add static_analysis unit test Add unit test for common.utils static_analysis unit. JIRA NVGPU-4825 Change-Id: Id103ab101bbca8424dd7f0d136f1101ddf4bc2b5 Signed-off-by: Philip Elcan Reviewed-on: https://git-master.nvidia.com/r/2276814 Reviewed-by: mobile promotions Tested-by: mobile promotions --- Makefile.umbrella.tmk | 1 + userspace/Makefile.sources | 1 + userspace/required_tests.json | 12 + .../units/interface/static_analysis/Makefile | 26 ++ .../static_analysis/Makefile.interface.tmk | 23 ++ .../interface/static_analysis/Makefile.tmk | 24 ++ .../static_analysis/static_analysis.c | 274 ++++++++++++++++++ .../static_analysis/static_analysis.h | 91 ++++++ 8 files changed, 452 insertions(+) create mode 100644 userspace/units/interface/static_analysis/Makefile create mode 100644 userspace/units/interface/static_analysis/Makefile.interface.tmk create mode 100644 userspace/units/interface/static_analysis/Makefile.tmk create mode 100644 userspace/units/interface/static_analysis/static_analysis.c create mode 100644 userspace/units/interface/static_analysis/static_analysis.h diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index a9b84f56d..2db5408c2 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -51,6 +51,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/interface/bsearch NV_REPOSITORY_COMPONENTS += userspace/units/interface/lock NV_REPOSITORY_COMPONENTS += userspace/units/interface/atomic NV_REPOSITORY_COMPONENTS += userspace/units/interface/rbtree +NV_REPOSITORY_COMPONENTS += userspace/units/interface/static_analysis NV_REPOSITORY_COMPONENTS += userspace/units/interface/worker NV_REPOSITORY_COMPONENTS += userspace/units/bus NV_REPOSITORY_COMPONENTS += userspace/units/pramin diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index d09495d35..2f47181ca 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -64,6 +64,7 @@ UNITS := \ $(UNIT_SRC)/interface/lock \ $(UNIT_SRC)/interface/atomic \ $(UNIT_SRC)/interface/rbtree \ + $(UNIT_SRC)/interface/static_analysis \ $(UNIT_SRC)/interface/worker \ $(UNIT_SRC)/mc \ $(UNIT_SRC)/mm/nvgpu_sgt \ diff --git a/userspace/required_tests.json b/userspace/required_tests.json index ee323776b..abb80213f 100644 --- a/userspace/required_tests.json +++ b/userspace/required_tests.json @@ -4549,5 +4549,17 @@ "case": "init", "unit": "worker", "test_level": 0 + }, + { + "test": "test_arithmetic", + "case": "arithmetic", + "unit": "static_analysis", + "test_level": 0 + }, + { + "test": "test_cast", + "case": "cast", + "unit": "static_analysis", + "test_level": 0 } ] diff --git a/userspace/units/interface/static_analysis/Makefile b/userspace/units/interface/static_analysis/Makefile new file mode 100644 index 000000000..5e2b53544 --- /dev/null +++ b/userspace/units/interface/static_analysis/Makefile @@ -0,0 +1,26 @@ +# 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. + +.SUFFIXES: + +OBJS = static_analysis.o +MODULE = static_analysis + +include ../../Makefile.units diff --git a/userspace/units/interface/static_analysis/Makefile.interface.tmk b/userspace/units/interface/static_analysis/Makefile.interface.tmk new file mode 100644 index 000000000..1d51fc63c --- /dev/null +++ b/userspace/units/interface/static_analysis/Makefile.interface.tmk @@ -0,0 +1,23 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2020, NVIDIA CORPORATION. All Rights Reserved. +# +# NVIDIA CORPORATION and its licensors retain all intellectual property +# and proprietary rights in and to this software, related documentation +# and any modifications thereto. Any use, reproduction, disclosure or +# distribution of this software and related documentation without an express +# license agreement from NVIDIA CORPORATION is strictly prohibited. +# +# tmake for SW Mobile component makefile +# +############################################################################### + +NVGPU_UNIT_NAME=static_analysis + +include $(NV_COMPONENT_DIR)/../../Makefile.units.common.interface.tmk + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/userspace/units/interface/static_analysis/Makefile.tmk b/userspace/units/interface/static_analysis/Makefile.tmk new file mode 100644 index 000000000..1e09f4434 --- /dev/null +++ b/userspace/units/interface/static_analysis/Makefile.tmk @@ -0,0 +1,24 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2020, NVIDIA CORPORATION. All Rights Reserved. +# +# NVIDIA CORPORATION and its licensors retain all intellectual property +# and proprietary rights in and to this software, related documentation +# and any modifications thereto. Any use, reproduction, disclosure or +# distribution of this software and related documentation without an express +# license agreement from NVIDIA CORPORATION is strictly prohibited. +# +# tmake for SW Mobile component makefile +# +############################################################################### + +NVGPU_UNIT_NAME=static_analysis +NVGPU_UNIT_SRCS=static_analysis.c + +include $(NV_COMPONENT_DIR)/../../Makefile.units.common.tmk + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/userspace/units/interface/static_analysis/static_analysis.c b/userspace/units/interface/static_analysis/static_analysis.c new file mode 100644 index 000000000..5df8e5902 --- /dev/null +++ b/userspace/units/interface/static_analysis/static_analysis.c @@ -0,0 +1,274 @@ +/* + * 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. + */ + +#include +#include +#include + +#include +#include + +#include "static_analysis.h" + +int test_arithmetic(struct unit_module *m, struct gk20a *g, void *args) +{ + int err; + + /* U8 sub */ + unit_assert(nvgpu_safe_sub_u8(1, 1) == 0, return UNIT_FAIL); + unit_assert(nvgpu_safe_sub_u8(U8_MAX, U8_MAX) == 0, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_sub_u8(0, 1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U32 add */ + unit_assert(nvgpu_safe_add_u32(U32_MAX-1, 1) == U32_MAX, + return UNIT_FAIL); + unit_assert(nvgpu_safe_add_u32(U32_MAX, 0) == U32_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_add_u32(U32_MAX, 1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S32 add */ + unit_assert(nvgpu_safe_add_s32(INT_MAX-1, 1) == INT_MAX, + return UNIT_FAIL); + unit_assert(nvgpu_safe_add_s32(INT_MAX, 0) == INT_MAX, + return UNIT_FAIL); + unit_assert(nvgpu_safe_add_s32(INT_MIN+1, -1) == INT_MIN, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_add_s32(INT_MAX, 1)); + unit_assert(err != 0, return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_add_s32(INT_MIN, -1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U32 sub */ + unit_assert(nvgpu_safe_sub_u32(1, 1) == 0, return UNIT_FAIL); + unit_assert(nvgpu_safe_sub_u32(U32_MAX, U32_MAX) == 0, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_sub_u32(0, 1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S32 sub */ + unit_assert(nvgpu_safe_sub_s32(INT_MIN+1, 1) == INT_MIN, + return UNIT_FAIL); + unit_assert(nvgpu_safe_sub_s32(INT_MAX-1, -1) == INT_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_sub_s32(INT_MIN, 1)); + unit_assert(err != 0, return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_sub_s32(INT_MAX, -1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U32 Mult */ + unit_assert(nvgpu_safe_mult_u32(0, 0) == 0, + return UNIT_FAIL); + unit_assert(nvgpu_safe_mult_u32(U32_MAX, 0) == 0, + return UNIT_FAIL); + unit_assert(nvgpu_safe_mult_u32(U32_MAX, 1) == U32_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_mult_u32(U32_MAX, 2)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U64 add */ + unit_assert(nvgpu_safe_add_u64(U64_MAX-1, 1) == U64_MAX, + return UNIT_FAIL); + unit_assert(nvgpu_safe_add_u64(U64_MAX, 0) == U64_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_add_u64(U64_MAX, 1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S64 add */ + unit_assert(nvgpu_safe_add_s64(LONG_MAX-1, 1) == LONG_MAX, + return UNIT_FAIL); + unit_assert(nvgpu_safe_add_s64(LONG_MAX, 0) == LONG_MAX, + return UNIT_FAIL); + unit_assert(nvgpu_safe_add_s64(LONG_MIN+1, -1) == LONG_MIN, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_add_s64(LONG_MAX, 1)); + unit_assert(err != 0, return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_add_s64(LONG_MIN, -1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U64 sub */ + unit_assert(nvgpu_safe_sub_u64(1, 1) == 0, return UNIT_FAIL); + unit_assert(nvgpu_safe_sub_u64(U64_MAX, U64_MAX) == 0, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_sub_u64(0, 1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S64 sub */ + unit_assert(nvgpu_safe_sub_s64(LONG_MIN+1, 1) == LONG_MIN, + return UNIT_FAIL); + unit_assert(nvgpu_safe_sub_s64(LONG_MAX-1, -1) == LONG_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_sub_s64(LONG_MIN, 1)); + unit_assert(err != 0, return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_sub_s64(LONG_MAX, -1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U64 Mult */ + unit_assert(nvgpu_safe_mult_u64(0, 0) == 0, + return UNIT_FAIL); + unit_assert(nvgpu_safe_mult_u64(U64_MAX, 0) == 0, + return UNIT_FAIL); + unit_assert(nvgpu_safe_mult_u64(U64_MAX, 1) == U64_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_mult_u64(U64_MAX, 2)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S64 Mult */ + unit_assert(nvgpu_safe_mult_s64(LONG_MAX, 1) == LONG_MAX, + return UNIT_FAIL); + unit_assert(nvgpu_safe_mult_s64(LONG_MAX, -1) == (-1 * LONG_MAX), + return UNIT_FAIL); + unit_assert(nvgpu_safe_mult_s64(-1, LONG_MAX) == (-1 * LONG_MAX), + return UNIT_FAIL); + unit_assert(nvgpu_safe_mult_s64(0, LONG_MAX) == 0, + return UNIT_FAIL); + unit_assert(nvgpu_safe_mult_s64(-1, -1) == 1, + return UNIT_FAIL); + unit_assert(nvgpu_safe_mult_s64(0, -1) == 0, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_mult_s64(LONG_MAX, 2)); + unit_assert(err != 0, return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_mult_s64(LONG_MAX, -2)); + unit_assert(err != 0, return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_mult_s64(-1*LONG_MAX, 2)); + unit_assert(err != 0, return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_mult_s64(-1*LONG_MAX, -2)); + unit_assert(err != 0, return UNIT_FAIL); + + return UNIT_SUCCESS; +} + +int test_cast(struct unit_module *m, struct gk20a *g, void *args) +{ + int err; + + /* U64 to U32 */ + unit_assert(nvgpu_safe_cast_u64_to_u32(U32_MAX) == U32_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_u64_to_u32(U64(U32_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U64 to U16 */ + unit_assert(nvgpu_safe_cast_u64_to_u16(U16_MAX) == U16_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_u64_to_u16(U64(U16_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U64 to U8 */ + unit_assert(nvgpu_safe_cast_u64_to_u8(U8_MAX) == U8_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_u64_to_u8(U64(U8_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U64 to S64 */ + unit_assert(nvgpu_safe_cast_u64_to_s64(LONG_MAX) == LONG_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_u64_to_s64(U64(LONG_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U64 to S32 */ + unit_assert(nvgpu_safe_cast_u64_to_s32(INT_MAX) == INT_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_u64_to_s32(U64(INT_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S64 to U64 */ + unit_assert(nvgpu_safe_cast_s64_to_u64(LONG_MAX) == LONG_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_s64_to_u64(-1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S64 to U32 */ + unit_assert(nvgpu_safe_cast_s64_to_u32(U32_MAX) == U32_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_s64_to_u32(-1)); + unit_assert(err != 0, return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_s64_to_u32(U64(U32_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S64 to S32 */ + unit_assert(nvgpu_safe_cast_s64_to_s32(INT_MAX) == INT_MAX, + return UNIT_FAIL); + unit_assert(nvgpu_safe_cast_s64_to_s32(INT_MIN) == INT_MIN, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_s64_to_s32(S64(INT_MIN)-1)); + unit_assert(err != 0, return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_s64_to_s32(S64(INT_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U32 to U16 */ + unit_assert(nvgpu_safe_cast_u32_to_u16(U16_MAX) == U16_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_u32_to_u16(U64(U16_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U32 to U8 */ + unit_assert(nvgpu_safe_cast_u32_to_u8(U8_MAX) == U8_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_u32_to_u8(U64(U8_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U32 to S32 */ + unit_assert(nvgpu_safe_cast_u32_to_s32(INT_MAX) == INT_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_u32_to_s32(U32(INT_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* U32 to S8 */ + unit_assert(nvgpu_safe_cast_u32_to_s8(SCHAR_MAX) == SCHAR_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_u32_to_s8(U32(SCHAR_MAX)+1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S32 to U64 */ + unit_assert(nvgpu_safe_cast_s32_to_u64(INT_MAX) == INT_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_s32_to_u64(-1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S32 to U32 */ + unit_assert(nvgpu_safe_cast_s32_to_u32(INT_MAX) == INT_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_s32_to_u32(-1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* S8 to U8 */ + unit_assert(nvgpu_safe_cast_s8_to_u8(SCHAR_MAX) == SCHAR_MAX, + return UNIT_FAIL); + err = EXPECT_BUG((void)nvgpu_safe_cast_s8_to_u8(-1)); + unit_assert(err != 0, return UNIT_FAIL); + + /* bool to U32 */ + unit_assert(nvgpu_safe_cast_bool_to_u32(false) == 0, return UNIT_FAIL); + unit_assert(nvgpu_safe_cast_bool_to_u32(true) == 1, return UNIT_FAIL); + + return UNIT_SUCCESS; +} + +struct unit_module_test static_analysis_tests[] = { + UNIT_TEST(arithmetic, test_arithmetic, NULL, 0), + UNIT_TEST(cast, test_cast, NULL, 0), +}; + +UNIT_MODULE(static_analysis, static_analysis_tests, UNIT_PRIO_NVGPU_TEST); \ No newline at end of file diff --git a/userspace/units/interface/static_analysis/static_analysis.h b/userspace/units/interface/static_analysis/static_analysis.h new file mode 100644 index 000000000..d44e006fd --- /dev/null +++ b/userspace/units/interface/static_analysis/static_analysis.h @@ -0,0 +1,91 @@ +/* + * 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_STATIC_ANALYSIS_H +#define UNIT_STATIC_ANALYSIS_H + +struct gk20a; +struct unit_module; + +/** @addtogroup SWUTS-interface-static-analysis + * @{ + * + * Software Unit Test Specification for static analysis unit + */ + +/** + * Test specification for: test_arithmetic + * + * Description: Verify functionality of static analysis safe arithmetic APIs. + * + * Test Type: Feature, Error guessing + * + * Targets: nvgpu_safe_sub_u8, nvgpu_safe_add_u32, nvgpu_safe_add_s32, + * nvgpu_safe_sub_u32, nvgpu_safe_sub_s32, nvgpu_safe_mult_u32, + * nvgpu_safe_add_u64, nvgpu_safe_add_s64, nvgpu_safe_sub_u64, + * nvgpu_safe_sub_s64, nvgpu_safe_mult_u64, nvgpu_safe_mult_s64 + * + * Input: None + * + * Steps: + * - Call the static analysis arithmetic APIs. Pass in valid values and verify + * correct return. + * - Call the static analysis arithmetic APIs. Pass in values beyond type range + * and use EXPECT_BUG() to verify BUG() is called. + * + * Output: Returns PASS if expected result is met, FAIL otherwise. + */ +int test_arithmetic(struct unit_module *m, struct gk20a *g, void *args); + +/** + * Test specification for: test_cast + * + * Description: Verify functionality of static analysis safe cast APIs. + * + * Test Type: Feature, Error guessing + * + * Targets: nvgpu_safe_cast_u64_to_u32, nvgpu_safe_cast_u64_to_u16, + * nvgpu_safe_cast_u64_to_u8, nvgpu_safe_cast_u64_to_s64, + * nvgpu_safe_cast_u64_to_s32, nvgpu_safe_cast_s64_to_u64, + * nvgpu_safe_cast_s64_to_u32, nvgpu_safe_cast_s64_to_s32, + * nvgpu_safe_cast_u32_to_u16, nvgpu_safe_cast_u32_to_u8, + * nvgpu_safe_cast_u32_to_s32, nvgpu_safe_cast_u32_to_s8, + * nvgpu_safe_cast_s32_to_u64, nvgpu_safe_cast_s32_to_u32, + * nvgpu_safe_cast_s8_to_u8, nvgpu_safe_cast_bool_to_u32 + * + * Input: None + * + * Steps: + * - Call the static analysis arithmetic APIs. Pass in valid values and verify + * correct return. + * - Call the static analysis arithmetic APIs. Pass in values beyond type range + * and use EXPECT_BUG() to verify BUG() is called. + * + * Output: Returns PASS if expected result is met, FAIL otherwise. + */ +int test_cast(struct unit_module *m, struct gk20a *g, void *args); + +/** + * @} + */ + +#endif /* UNIT_WORKER_H */