[v3,2/2] test/eal: add a test for rte_ctrl_thread_create

Message ID 20210830163413.31576-2-honnappa.nagarahalli@arm.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series [v3,1/2] eal: simplify the implementation of rte_ctrl_thread_create |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/Intel-compilation fail Compilation issues
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing fail Testing issues
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Honnappa Nagarahalli Aug. 30, 2021, 4:34 p.m. UTC
  Add a testcase to test launching of control threads.

Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 app/test/test_lcores.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
  

Comments

Stephen Hemminger Aug. 30, 2021, 4:41 p.m. UTC | #1
On Mon, 30 Aug 2021 11:34:13 -0500
Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> wrote:

> +static int
> +test_crtl_thread(void)

Is this a typo? Did you mean test_ctrl_thread?
  
Honnappa Nagarahalli Aug. 30, 2021, 4:42 p.m. UTC | #2
<snip>

> 
> On Mon, 30 Aug 2021 11:34:13 -0500
> Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> wrote:
> 
> > +static int
> > +test_crtl_thread(void)
> 
> Is this a typo? Did you mean test_ctrl_thread?
Yes, thanks
  

Patch

diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c
index 19a7ab9fce..738148f339 100644
--- a/app/test/test_lcores.c
+++ b/app/test/test_lcores.c
@@ -340,6 +340,44 @@  test_non_eal_lcores_callback(unsigned int eal_threads_count)
 	return -1;
 }
 
+static void *ctrl_thread_loop(void *arg)
+{
+	struct thread_context *t = arg;
+
+	printf("Control thread running successfully\n");
+
+	/* Set the thread state to DONE */
+	t->state = DONE;
+
+	return NULL;
+}
+
+static int
+test_crtl_thread(void)
+{
+	struct thread_context ctrl_thread_context;
+	struct thread_context *t;
+
+	/* Create one control thread */
+	t = &ctrl_thread_context;
+	t->state = INIT;
+	if (rte_ctrl_thread_create(&t->id, "test_ctrl_threads",
+					NULL, ctrl_thread_loop, t) != 0)
+		return -1;
+
+	/* Wait till the control thread exits.
+	 * This also acts as the barrier such that the memory operations
+	 * in control thread are visible to this thread.
+	 */
+	pthread_join(t->id, NULL);
+
+	/* Check if the control thread set the correct state */
+	if (t->state != DONE)
+		return -1;
+
+	return 0;
+}
+
 static int
 test_lcores(void)
 {
@@ -367,6 +405,9 @@  test_lcores(void)
 	if (test_non_eal_lcores_callback(eal_threads_count) < 0)
 		return TEST_FAILED;
 
+	if (test_crtl_thread() < 0)
+		return TEST_FAILED;
+
 	return TEST_SUCCESS;
 }