mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: add test for thread unit
Add test as part of Thread UT to increase the branch coverage. Jira NVGPU-4478 Change-Id: I774e9677fde51d33505081d33193c93ef25617a9 Signed-off-by: ajesh <akv@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2291448 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Rajesh Devaraj <rdevaraj@nvidia.com> Reviewed-by: Philip Elcan <pelcan@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
@@ -50,6 +50,10 @@ static int test_thread_fn(void *args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data->use_return) {
|
||||||
|
return (data->use_return);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +80,9 @@ int test_thread_cycle(struct unit_module *m, struct gk20a *g, void *args)
|
|||||||
|
|
||||||
if (test_args->use_priority == false) {
|
if (test_args->use_priority == false) {
|
||||||
if (test_args->use_name == true) {
|
if (test_args->use_name == true) {
|
||||||
|
if (test_args->ret_err == true) {
|
||||||
|
test_data.use_return = 1;
|
||||||
|
}
|
||||||
ret = nvgpu_thread_create(&test_thread, &test_data,
|
ret = nvgpu_thread_create(&test_thread, &test_data,
|
||||||
test_thread_fn,
|
test_thread_fn,
|
||||||
"test_thread");
|
"test_thread");
|
||||||
@@ -156,6 +163,7 @@ int test_thread_cycle(struct unit_module *m, struct gk20a *g, void *args)
|
|||||||
struct unit_module_test posix_thread_tests[] = {
|
struct unit_module_test posix_thread_tests[] = {
|
||||||
UNIT_TEST(create, test_thread_cycle, &create_normal, 0),
|
UNIT_TEST(create, test_thread_cycle, &create_normal, 0),
|
||||||
UNIT_TEST(create_noname, test_thread_cycle, &create_normal_noname, 0),
|
UNIT_TEST(create_noname, test_thread_cycle, &create_normal_noname, 0),
|
||||||
|
UNIT_TEST(create_noname_errret, test_thread_cycle, &create_normal_errret, 0),
|
||||||
UNIT_TEST(create_priority, test_thread_cycle, &create_priority, 0),
|
UNIT_TEST(create_priority, test_thread_cycle, &create_priority, 0),
|
||||||
UNIT_TEST(create_priority_noname, test_thread_cycle, &create_priority_noname, 0),
|
UNIT_TEST(create_priority_noname, test_thread_cycle, &create_priority_noname, 0),
|
||||||
UNIT_TEST(cycle, test_thread_cycle, &check_stop, 0),
|
UNIT_TEST(cycle, test_thread_cycle, &check_stop, 0),
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ struct test_thread_args {
|
|||||||
bool stop_graceful;
|
bool stop_graceful;
|
||||||
bool use_name;
|
bool use_name;
|
||||||
bool stop_repeat;
|
bool stop_repeat;
|
||||||
|
bool ret_err;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args create_normal = {
|
static struct test_thread_args create_normal = {
|
||||||
@@ -46,7 +47,8 @@ static struct test_thread_args create_normal = {
|
|||||||
.check_stop = false,
|
.check_stop = false,
|
||||||
.stop_graceful = false,
|
.stop_graceful = false,
|
||||||
.use_name = true,
|
.use_name = true,
|
||||||
.stop_repeat = false
|
.stop_repeat = false,
|
||||||
|
.ret_err = false
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args create_normal_noname = {
|
static struct test_thread_args create_normal_noname = {
|
||||||
@@ -54,7 +56,17 @@ static struct test_thread_args create_normal_noname = {
|
|||||||
.check_stop = false,
|
.check_stop = false,
|
||||||
.stop_graceful = false,
|
.stop_graceful = false,
|
||||||
.use_name = false,
|
.use_name = false,
|
||||||
.stop_repeat = false
|
.stop_repeat = false,
|
||||||
|
.ret_err = false
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct test_thread_args create_normal_errret = {
|
||||||
|
.use_priority = false,
|
||||||
|
.check_stop = false,
|
||||||
|
.stop_graceful = false,
|
||||||
|
.use_name = true,
|
||||||
|
.stop_repeat = false,
|
||||||
|
.ret_err = true
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args create_priority = {
|
static struct test_thread_args create_priority = {
|
||||||
@@ -62,7 +74,8 @@ static struct test_thread_args create_priority = {
|
|||||||
.check_stop = false,
|
.check_stop = false,
|
||||||
.stop_graceful = false,
|
.stop_graceful = false,
|
||||||
.use_name = true,
|
.use_name = true,
|
||||||
.stop_repeat = false
|
.stop_repeat = false,
|
||||||
|
.ret_err = false
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args create_priority_noname = {
|
static struct test_thread_args create_priority_noname = {
|
||||||
@@ -70,7 +83,8 @@ static struct test_thread_args create_priority_noname = {
|
|||||||
.check_stop = false,
|
.check_stop = false,
|
||||||
.stop_graceful = false,
|
.stop_graceful = false,
|
||||||
.use_name = false,
|
.use_name = false,
|
||||||
.stop_repeat = false
|
.stop_repeat = false,
|
||||||
|
.ret_err = false
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args check_stop = {
|
static struct test_thread_args check_stop = {
|
||||||
@@ -78,7 +92,8 @@ static struct test_thread_args check_stop = {
|
|||||||
.check_stop = true,
|
.check_stop = true,
|
||||||
.stop_graceful = false,
|
.stop_graceful = false,
|
||||||
.use_name = true,
|
.use_name = true,
|
||||||
.stop_repeat = false
|
.stop_repeat = false,
|
||||||
|
.ret_err = false
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args stop_graceful = {
|
static struct test_thread_args stop_graceful = {
|
||||||
@@ -86,7 +101,8 @@ static struct test_thread_args stop_graceful = {
|
|||||||
.check_stop = true,
|
.check_stop = true,
|
||||||
.stop_graceful = true,
|
.stop_graceful = true,
|
||||||
.use_name = true,
|
.use_name = true,
|
||||||
.stop_repeat = false
|
.stop_repeat = false,
|
||||||
|
.ret_err = false
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args stop_graceful_repeat = {
|
static struct test_thread_args stop_graceful_repeat = {
|
||||||
@@ -94,7 +110,8 @@ static struct test_thread_args stop_graceful_repeat = {
|
|||||||
.check_stop = true,
|
.check_stop = true,
|
||||||
.stop_graceful = true,
|
.stop_graceful = true,
|
||||||
.use_name = true,
|
.use_name = true,
|
||||||
.stop_repeat = true
|
.stop_repeat = true,
|
||||||
|
.ret_err = false
|
||||||
};
|
};
|
||||||
|
|
||||||
struct unit_test_thread_data {
|
struct unit_test_thread_data {
|
||||||
@@ -103,6 +120,7 @@ struct unit_test_thread_data {
|
|||||||
int thread_priority;
|
int thread_priority;
|
||||||
int check_stop;
|
int check_stop;
|
||||||
int callback_invoked;
|
int callback_invoked;
|
||||||
|
int use_return;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nvgpu_thread test_thread;
|
struct nvgpu_thread test_thread;
|
||||||
|
|||||||
Reference in New Issue
Block a user