mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: unit: swuts: add posix bug
Add posix bug unit to SWUTS. Jira NVGPU-4478 Change-Id: I37fb087952414d1083b268ad2bbf38def40ef189 Signed-off-by: ajesh <akv@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2280348 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
@@ -109,6 +109,7 @@
|
|||||||
* - @ref SWUTS-posix-thread
|
* - @ref SWUTS-posix-thread
|
||||||
* - @ref SWUTS-posix-timers
|
* - @ref SWUTS-posix-timers
|
||||||
* - @ref SWUTS-posix-queue
|
* - @ref SWUTS-posix-queue
|
||||||
|
* - @ref SWUTS-posix-bug
|
||||||
* - @ref SWUTS-priv_ring
|
* - @ref SWUTS-priv_ring
|
||||||
* - @ref SWUTS-ptimer
|
* - @ref SWUTS-ptimer
|
||||||
* - @ref SWUTS-sdl
|
* - @ref SWUTS-sdl
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ INPUT += ../../../userspace/units/mm/mm/mm.h
|
|||||||
INPUT += ../../../userspace/units/mm/vm/vm.h
|
INPUT += ../../../userspace/units/mm/vm/vm.h
|
||||||
INPUT += ../../../userspace/units/sync/nvgpu-sync.h
|
INPUT += ../../../userspace/units/sync/nvgpu-sync.h
|
||||||
INPUT += ../../../userspace/units/posix/bitops/posix-bitops.h
|
INPUT += ../../../userspace/units/posix/bitops/posix-bitops.h
|
||||||
|
INPUT += ../../../userspace/units/posix/bug/posix-bug.h
|
||||||
INPUT += ../../../userspace/units/posix/cond/posix-cond.h
|
INPUT += ../../../userspace/units/posix/cond/posix-cond.h
|
||||||
INPUT += ../../../userspace/units/posix/fault-injection/posix-fault-injection.h
|
INPUT += ../../../userspace/units/posix/fault-injection/posix-fault-injection.h
|
||||||
INPUT += ../../../userspace/units/posix/fault-injection/posix-fault-injection-kmem.h
|
INPUT += ../../../userspace/units/posix/fault-injection/posix-fault-injection-kmem.h
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#include <nvgpu/types.h>
|
#include <nvgpu/types.h>
|
||||||
|
|
||||||
|
#include "posix-bug.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple wrapper function to call BUG() or not. It was not strictly necessary
|
* Simple wrapper function to call BUG() or not. It was not strictly necessary
|
||||||
* to wrap the call to BUG() in a function but it better ressembles the way
|
* to wrap the call to BUG() in a function but it better ressembles the way
|
||||||
@@ -51,7 +53,7 @@ static void bug_caller(struct unit_module *m, bool call)
|
|||||||
* In the event that EXPECT_BUG is completely broken, the call to BUG() would
|
* In the event that EXPECT_BUG is completely broken, the call to BUG() would
|
||||||
* cause the unit to crash and report a failure correctly.
|
* cause the unit to crash and report a failure correctly.
|
||||||
*/
|
*/
|
||||||
static int test_expect_bug(struct unit_module *m,
|
int test_expect_bug(struct unit_module *m,
|
||||||
struct gk20a *g, void *args)
|
struct gk20a *g, void *args)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -91,7 +93,7 @@ static void other_bug_cb(void *arg)
|
|||||||
other_cb_called = true;
|
other_cb_called = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test_bug_cb(struct unit_module *m,
|
int test_bug_cb(struct unit_module *m,
|
||||||
struct gk20a *g, void *args)
|
struct gk20a *g, void *args)
|
||||||
{
|
{
|
||||||
struct nvgpu_bug_cb callback;
|
struct nvgpu_bug_cb callback;
|
||||||
@@ -136,7 +138,6 @@ static int test_bug_cb(struct unit_module *m,
|
|||||||
return UNIT_SUCCESS;
|
return UNIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct unit_module_test posix_bug_tests[] = {
|
struct unit_module_test posix_bug_tests[] = {
|
||||||
UNIT_TEST(expect_bug, test_expect_bug, NULL, 0),
|
UNIT_TEST(expect_bug, test_expect_bug, NULL, 0),
|
||||||
UNIT_TEST(bug_cb, test_bug_cb, NULL, 0),
|
UNIT_TEST(bug_cb, test_bug_cb, NULL, 0),
|
||||||
|
|||||||
89
userspace/units/posix/bug/posix-bug.h
Normal file
89
userspace/units/posix/bug/posix-bug.h
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup SWUTS-posix-bug
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* Software Unit Test Specification for posix-bug
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __UNIT_POSIX_BUG_H__
|
||||||
|
#define __UNIT_POSIX_BUG_H__
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test specification for test_expect_bug
|
||||||
|
*
|
||||||
|
* Description: Test the BUG implementation.
|
||||||
|
*
|
||||||
|
* Test Type: Feature
|
||||||
|
*
|
||||||
|
* Targets: nvgpu_posix_bug, dump_stack
|
||||||
|
*
|
||||||
|
* Inputs: None
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* 1) Use the unit test framework specific EXPECT_BUG define to call BUG.
|
||||||
|
* 2) BUG should be called as expected, but the portion of BUG implementation
|
||||||
|
* which cannot be run in unit test framework will not be executed.
|
||||||
|
* 3) EXPECT_BUG is also tested to make sure that BUG is not called where it is
|
||||||
|
* not expected.
|
||||||
|
*
|
||||||
|
* Output:
|
||||||
|
* The test returns PASS if BUG is called as expected based on the parameters
|
||||||
|
* passed and EXPECT_BUG handles it accordingly.
|
||||||
|
* The test returns FAIL if either BUG is not called as expected or if
|
||||||
|
* EXPECT_BUG indicates that a BUG call was made which was not requested by
|
||||||
|
* the test.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int test_expect_bug(struct unit_module *m, struct gk20a *g, void *args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test specification for test_bug_cb
|
||||||
|
*
|
||||||
|
* Description: Test the bug callback functionality.
|
||||||
|
*
|
||||||
|
* Test Type: Feature
|
||||||
|
*
|
||||||
|
* Targets: nvgpu_bug_register_cb, nvgpu_bug_unregister_cb
|
||||||
|
*
|
||||||
|
* Inputs: None
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* 1) Register two callbacks for BUG.
|
||||||
|
* 2) Invoke BUG and check if both the callback functions are invoked as
|
||||||
|
* expected.
|
||||||
|
* 3) Register two callbacks for BUG again.
|
||||||
|
* 4) Remove one of the registered callbacks.
|
||||||
|
* 5) Invoke BUG and confirm if the unregistered callback is not invoked.
|
||||||
|
*
|
||||||
|
* Output:
|
||||||
|
* The test returns PASS if both the callbacks are invoked in the first
|
||||||
|
* invocation of the BUG and in the second invocation, only the registered
|
||||||
|
* callback is invoked and not the unregistered callback. Otherwise, the test
|
||||||
|
* returns FAIL.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int test_bug_cb(struct unit_module *m, struct gk20a *g, void *args);
|
||||||
|
|
||||||
|
#endif /* __UNIT_POSIX_BUG_H__ */
|
||||||
Reference in New Issue
Block a user