Blob Blame History Raw
From 38445f372fa494f541e566568a022c58c2e0a1e3 Mon Sep 17 00:00:00 2001
From: Petr Mensik <pemensik@redhat.com>
Date: Mon, 30 Nov 2020 21:53:43 +0100
Subject: [PATCH] Pass task_test also with threads disabled

Condition cv is declared only when threads are used. Use it only in that
case. Test compiles and passes without thread support also.
---
 lib/isc/tests/task_test.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/isc/tests/task_test.c b/lib/isc/tests/task_test.c
index 151a9ea..c1c2005 100644
--- a/lib/isc/tests/task_test.c
+++ b/lib/isc/tests/task_test.c
@@ -61,8 +61,10 @@ _setup(void **state) {
 	result = isc_mutex_init(&lock);
 	assert_int_equal(result, ISC_R_SUCCESS);
 
+#ifdef ISC_PLATFORM_USETHREADS
 	result = isc_condition_init(&cv);
 	assert_int_equal(result, ISC_R_SUCCESS);
+#endif
 
 	result = isc_test_begin(NULL, true, 0);
 	assert_int_equal(result, ISC_R_SUCCESS);
@@ -79,8 +81,10 @@ _setup2(void **state) {
 	result = isc_mutex_init(&lock);
 	assert_int_equal(result, ISC_R_SUCCESS);
 
+#ifdef ISC_PLATFORM_USETHREADS
 	result = isc_condition_init(&cv);
 	assert_int_equal(result, ISC_R_SUCCESS);
+#endif
 
 	/* Two worker threads */
 	result = isc_test_begin(NULL, true, 2);
@@ -98,8 +102,10 @@ _setup4(void **state) {
 	result = isc_mutex_init(&lock);
 	assert_int_equal(result, ISC_R_SUCCESS);
 
+#ifdef ISC_PLATFORM_USETHREADS
 	result = isc_condition_init(&cv);
 	assert_int_equal(result, ISC_R_SUCCESS);
+#endif
 
 	/* Four worker threads */
 	result = isc_test_begin(NULL, true, 4);
@@ -113,7 +119,9 @@ _teardown(void **state) {
 	UNUSED(state);
 
 	isc_test_end();
+#ifdef ISC_PLATFORM_USETHREADS
 	isc_condition_destroy(&cv);
+#endif
 
 	return (0);
 }
-- 
2.26.2