mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
gpu: nvgpu: add more tests for thread
Add more tests as part of unit test for thread unit. Jira NVGPU-4478 Change-Id: Ib2464a28c73124b4e85d9e3ab19c79258d6b81fe Signed-off-by: ajesh <akv@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2275534 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Shashank Singh <shashsingh@nvidia.com> Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
* Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -75,16 +75,29 @@ 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) {
|
||||||
ret = nvgpu_thread_create(&test_thread, &test_data,
|
if (test_args->use_name == true) {
|
||||||
test_thread_fn,
|
ret = nvgpu_thread_create(&test_thread, &test_data,
|
||||||
"test_thread");
|
test_thread_fn,
|
||||||
|
"test_thread");
|
||||||
|
} else {
|
||||||
|
ret = nvgpu_thread_create(&test_thread, &test_data,
|
||||||
|
test_thread_fn,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
test_data.check_priority = 1;
|
test_data.check_priority = 1;
|
||||||
|
|
||||||
ret = nvgpu_thread_create_priority(&test_thread,
|
if (test_args->use_name == true) {
|
||||||
&test_data, test_thread_fn,
|
ret = nvgpu_thread_create_priority(&test_thread,
|
||||||
UNIT_TEST_THREAD_PRIORITY,
|
&test_data, test_thread_fn,
|
||||||
"test_thread_priority");
|
UNIT_TEST_THREAD_PRIORITY,
|
||||||
|
"test_thread_priority");
|
||||||
|
} else {
|
||||||
|
ret = nvgpu_thread_create_priority(&test_thread,
|
||||||
|
&test_data, test_thread_fn,
|
||||||
|
UNIT_TEST_THREAD_PRIORITY,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
@@ -122,6 +135,18 @@ int test_thread_cycle(struct unit_module *m, struct gk20a *g, void *args)
|
|||||||
if (!test_data.callback_invoked) {
|
if (!test_data.callback_invoked) {
|
||||||
unit_return_fail(m, "Callback not invoked\n");
|
unit_return_fail(m, "Callback not invoked\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (test_args->stop_repeat == true) {
|
||||||
|
test_data.callback_invoked = 0;
|
||||||
|
nvgpu_thread_stop_graceful(&test_thread,
|
||||||
|
test_thread_stop_graceful_callback,
|
||||||
|
&test_data);
|
||||||
|
if (test_data.callback_invoked) {
|
||||||
|
unit_return_fail(m,
|
||||||
|
"Callback invoked\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,10 +154,13 @@ 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_priority, test_thread_cycle, &create_priority, 0),
|
UNIT_TEST(create_noname, test_thread_cycle, &create_normal_noname, 0),
|
||||||
UNIT_TEST(cycle, test_thread_cycle, &check_stop, 0),
|
UNIT_TEST(create_priority, test_thread_cycle, &create_priority, 0),
|
||||||
UNIT_TEST(stop_graceful, test_thread_cycle, &stop_graceful, 0),
|
UNIT_TEST(create_priority_noname, test_thread_cycle, &create_priority_noname, 0),
|
||||||
|
UNIT_TEST(cycle, test_thread_cycle, &check_stop, 0),
|
||||||
|
UNIT_TEST(stop_graceful, test_thread_cycle, &stop_graceful, 0),
|
||||||
|
UNIT_TEST(stop_graceful_repeat, test_thread_cycle, &stop_graceful_repeat, 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
UNIT_MODULE(posix_thread, posix_thread_tests, UNIT_PRIO_POSIX_TEST);
|
UNIT_MODULE(posix_thread, posix_thread_tests, UNIT_PRIO_POSIX_TEST);
|
||||||
|
|||||||
@@ -37,30 +37,64 @@ struct test_thread_args {
|
|||||||
bool use_priority;
|
bool use_priority;
|
||||||
bool check_stop;
|
bool check_stop;
|
||||||
bool stop_graceful;
|
bool stop_graceful;
|
||||||
|
bool use_name;
|
||||||
|
bool stop_repeat;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args create_normal = {
|
static struct test_thread_args create_normal = {
|
||||||
.use_priority = false,
|
.use_priority = false,
|
||||||
.check_stop = false,
|
.check_stop = false,
|
||||||
.stop_graceful = false
|
.stop_graceful = false,
|
||||||
|
.use_name = true,
|
||||||
|
.stop_repeat = false
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct test_thread_args create_normal_noname = {
|
||||||
|
.use_priority = false,
|
||||||
|
.check_stop = false,
|
||||||
|
.stop_graceful = false,
|
||||||
|
.use_name = false,
|
||||||
|
.stop_repeat = false
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args create_priority = {
|
static struct test_thread_args create_priority = {
|
||||||
.use_priority = true,
|
.use_priority = true,
|
||||||
.check_stop = false,
|
.check_stop = false,
|
||||||
.stop_graceful = false
|
.stop_graceful = false,
|
||||||
|
.use_name = true,
|
||||||
|
.stop_repeat = false
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct test_thread_args create_priority_noname = {
|
||||||
|
.use_priority = true,
|
||||||
|
.check_stop = false,
|
||||||
|
.stop_graceful = false,
|
||||||
|
.use_name = false,
|
||||||
|
.stop_repeat = false
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args check_stop = {
|
static struct test_thread_args check_stop = {
|
||||||
.use_priority = false,
|
.use_priority = false,
|
||||||
.check_stop = true,
|
.check_stop = true,
|
||||||
.stop_graceful = false
|
.stop_graceful = false,
|
||||||
|
.use_name = true,
|
||||||
|
.stop_repeat = false
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_args stop_graceful = {
|
static struct test_thread_args stop_graceful = {
|
||||||
.use_priority = false,
|
.use_priority = false,
|
||||||
.check_stop = true,
|
.check_stop = true,
|
||||||
.stop_graceful = true
|
.stop_graceful = true,
|
||||||
|
.use_name = true,
|
||||||
|
.stop_repeat = false
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct test_thread_args stop_graceful_repeat = {
|
||||||
|
.use_priority = false,
|
||||||
|
.check_stop = true,
|
||||||
|
.stop_graceful = true,
|
||||||
|
.use_name = true,
|
||||||
|
.stop_repeat = true
|
||||||
};
|
};
|
||||||
|
|
||||||
struct unit_test_thread_data {
|
struct unit_test_thread_data {
|
||||||
|
|||||||
Reference in New Issue
Block a user