[dpdk-dev] [PATCH v17 09/13] app/test: add unit tests for thread lifetime management
Narcisa Ana Maria Vasile
navasile at linux.microsoft.com
Wed Nov 10 04:01:38 CET 2021
From: Narcisa Vasile <navasile at microsoft.com>
As a new API for threading is introduced,
a set of unit tests have been added to test the new interface.
Verify that threads are created and cleaned up correctly.
Signed-off-by: Narcisa Vasile <navasile at microsoft.com>
---
app/test/test_threads.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/app/test/test_threads.c b/app/test/test_threads.c
index 53e5892793..9fcae34179 100644
--- a/app/test/test_threads.c
+++ b/app/test/test_threads.c
@@ -167,6 +167,34 @@ test_thread_attributes_priority(void)
return ret;
}
+static void *
+thread_loop_return(void *arg)
+{
+ RTE_SET_USED(arg);
+ return NULL;
+}
+
+static int
+test_thread_detach(void)
+{
+ rte_thread_t threads_ids[THREADS_COUNT];
+ size_t i;
+ int ret = 0;
+
+ for (i = 0; i < THREADS_COUNT; ++i) {
+ ret = rte_thread_create(&threads_ids[i], NULL,
+ thread_loop_return, NULL);
+ RTE_TEST_ASSERT(ret == 0, "Failed to create threads!");
+ }
+
+ for (i = 0; i < THREADS_COUNT; ++i) {
+ ret = rte_thread_detach(threads_ids[i]);
+ RTE_TEST_ASSERT(ret == 0, "Failed to detach thread!");
+ }
+
+ return ret;
+}
+
static struct unit_test_suite threads_test_suite = {
.suite_name = "threads autotest",
.setup = NULL,
@@ -175,6 +203,7 @@ static struct unit_test_suite threads_test_suite = {
TEST_CASE(test_thread_self),
TEST_CASE(test_thread_attributes_affinity),
TEST_CASE(test_thread_attributes_priority),
+ TEST_CASE(test_thread_detach),
TEST_CASES_END()
}
};
--
2.31.0.vfs.0.1
More information about the dev
mailing list