gpu: nvgpu: add more tests for bug

Add more tests as part of Bug UT.

Jira NVGPU-4478

Change-Id: If9141ded41e9b9e97d03fa26c7404b85fa253014
Signed-off-by: ajesh <akv@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2284669
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@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:
ajesh
2020-01-24 15:08:26 +05:30
committed by Alex Waterman
parent 5589e60822
commit eac3137c60
2 changed files with 24 additions and 1 deletions

View File

@@ -47,6 +47,13 @@ static void bug_caller(struct unit_module *m, bool call)
}
}
/*
* Simple wrapper function to call BUG_ON() with condition.
*/
static void bug_on_caller(struct unit_module *m, bool cond)
{
BUG_ON(cond);
}
/*
* Test to ensure the EXPECT_BUG construct works as intended by making sure it
* behaves properly when BUG is called or not.
@@ -73,6 +80,20 @@ int test_expect_bug(struct unit_module *m,
return UNIT_FAIL;
}
if (!EXPECT_BUG(bug_on_caller(m, true))) {
unit_err(m, "BUG_ON expected to invoke BUG()\n");
return UNIT_FAIL;
} else {
unit_info(m, "BUG_ON invoked BUG() as expected\n");
}
if (!EXPECT_BUG(bug_on_caller(m, false))) {
unit_info(m, "BUG_ON() skipped BUG invocation as expected\n");
} else {
unit_err(m, "BUG_ON invoked BUG but it was not expected()\n");
return UNIT_FAIL;
}
return UNIT_SUCCESS;
}