Replace custom isc_boolean_t with C standard bool type
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
@@ -37,7 +38,7 @@
|
||||
static isc_mutex_t lock;
|
||||
int counter = 0;
|
||||
static int active[10];
|
||||
static isc_boolean_t done = ISC_FALSE;
|
||||
static bool done = false;
|
||||
|
||||
#ifdef ISC_PLATFORM_USETHREADS
|
||||
static isc_condition_t cv;
|
||||
@@ -84,7 +85,7 @@ ATF_TC_BODY(create_task, tc) {
|
||||
|
||||
UNUSED(tc);
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE, 0);
|
||||
result = isc_test_begin(NULL, true, 0);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_task_create(taskmgr, 0, &task);
|
||||
@@ -115,7 +116,7 @@ ATF_TC_BODY(all_events, tc) {
|
||||
result = isc_mutex_init(&lock);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE, 0);
|
||||
result = isc_test_begin(NULL, true, 0);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_task_create(taskmgr, 0, &task);
|
||||
@@ -171,7 +172,7 @@ ATF_TC_BODY(privileged_events, tc) {
|
||||
result = isc_mutex_init(&lock);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE, 0);
|
||||
result = isc_test_begin(NULL, true, 0);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
#ifdef ISC_PLATFORM_USETHREADS
|
||||
@@ -186,7 +187,7 @@ ATF_TC_BODY(privileged_events, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
isc_task_setname(task1, "privileged", NULL);
|
||||
ATF_CHECK(!isc_task_privilege(task1));
|
||||
isc_task_setprivilege(task1, ISC_TRUE);
|
||||
isc_task_setprivilege(task1, true);
|
||||
ATF_CHECK(isc_task_privilege(task1));
|
||||
|
||||
result = isc_task_create(taskmgr, 0, &task2);
|
||||
@@ -266,7 +267,7 @@ ATF_TC_BODY(privileged_events, tc) {
|
||||
|
||||
ATF_CHECK_EQ(counter, 6);
|
||||
|
||||
isc_task_setprivilege(task1, ISC_FALSE);
|
||||
isc_task_setprivilege(task1, false);
|
||||
ATF_CHECK(!isc_task_privilege(task1));
|
||||
|
||||
ATF_CHECK_EQ(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_normal);
|
||||
@@ -300,7 +301,7 @@ ATF_TC_BODY(privilege_drop, tc) {
|
||||
result = isc_mutex_init(&lock);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE, 0);
|
||||
result = isc_test_begin(NULL, true, 0);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
#ifdef ISC_PLATFORM_USETHREADS
|
||||
@@ -315,7 +316,7 @@ ATF_TC_BODY(privilege_drop, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
isc_task_setname(task1, "privileged", NULL);
|
||||
ATF_CHECK(!isc_task_privilege(task1));
|
||||
isc_task_setprivilege(task1, ISC_TRUE);
|
||||
isc_task_setprivilege(task1, true);
|
||||
ATF_CHECK(isc_task_privilege(task1));
|
||||
|
||||
result = isc_task_create(taskmgr, 0, &task2);
|
||||
@@ -474,7 +475,7 @@ ATF_TC_BODY(basic, tc) {
|
||||
|
||||
UNUSED(tc);
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE, 2);
|
||||
result = isc_test_begin(NULL, true, 2);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_task_create(taskmgr, 0, &task1);
|
||||
@@ -586,7 +587,7 @@ exclusive_cb(isc_task_t *task, isc_event_t *event) {
|
||||
}
|
||||
|
||||
isc_task_endexclusive(task);
|
||||
done = ISC_TRUE;
|
||||
done = true;
|
||||
} else {
|
||||
active[taskno]++;
|
||||
(void) spin(10000000);
|
||||
@@ -614,7 +615,7 @@ ATF_TC_BODY(task_exclusive, tc) {
|
||||
|
||||
UNUSED(tc);
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE, 4);
|
||||
result = isc_test_begin(NULL, true, 4);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
@@ -660,7 +661,7 @@ maxtask_shutdown(isc_task_t *task, isc_event_t *event) {
|
||||
isc_task_destroy((isc_task_t**) &event->ev_arg);
|
||||
} else {
|
||||
LOCK(&lock);
|
||||
done = ISC_TRUE;
|
||||
done = true;
|
||||
SIGNAL(&cv);
|
||||
UNLOCK(&lock);
|
||||
|
||||
@@ -806,11 +807,11 @@ ATF_TC_BODY(shutdown, tc) {
|
||||
int i;
|
||||
|
||||
nevents = nsdevents = 0;
|
||||
done = ISC_FALSE;
|
||||
done = false;
|
||||
|
||||
event_type = 3;
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE, 4);
|
||||
result = isc_test_begin(NULL, true, 4);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_mutex_init(&lock);
|
||||
@@ -857,7 +858,7 @@ ATF_TC_BODY(shutdown, tc) {
|
||||
/*
|
||||
* Now we free the task by signaling cv.
|
||||
*/
|
||||
done = ISC_TRUE;
|
||||
done = true;
|
||||
SIGNAL(&cv);
|
||||
UNLOCK(&lock);
|
||||
|
||||
@@ -905,7 +906,7 @@ ATF_TC_BODY(post_shutdown, tc) {
|
||||
isc_event_t *event;
|
||||
isc_task_t *task;
|
||||
|
||||
done = ISC_FALSE;
|
||||
done = false;
|
||||
event_type = 4;
|
||||
|
||||
result = isc_mutex_init(&lock);
|
||||
@@ -914,7 +915,7 @@ ATF_TC_BODY(post_shutdown, tc) {
|
||||
result = isc_condition_init(&cv);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE, 2);
|
||||
result = isc_test_begin(NULL, true, 2);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
LOCK(&lock);
|
||||
@@ -939,7 +940,7 @@ ATF_TC_BODY(post_shutdown, tc) {
|
||||
/*
|
||||
* Release the task.
|
||||
*/
|
||||
done = ISC_TRUE;
|
||||
done = true;
|
||||
|
||||
SIGNAL(&cv);
|
||||
UNLOCK(&lock);
|
||||
@@ -960,14 +961,14 @@ ATF_TC_BODY(post_shutdown, tc) {
|
||||
#define TAGCNT 5
|
||||
#define NEVENTS (SENDERCNT * TYPECNT * TAGCNT)
|
||||
|
||||
static isc_boolean_t testrange;
|
||||
static bool testrange;
|
||||
static void *purge_sender;
|
||||
static isc_eventtype_t purge_type_first;
|
||||
static isc_eventtype_t purge_type_last;
|
||||
static void *purge_tag;
|
||||
static int eventcnt;
|
||||
|
||||
isc_boolean_t started = ISC_FALSE;
|
||||
bool started = false;
|
||||
|
||||
static void
|
||||
pg_event1(isc_task_t *task, isc_event_t *event) {
|
||||
@@ -984,30 +985,30 @@ pg_event1(isc_task_t *task, isc_event_t *event) {
|
||||
|
||||
static void
|
||||
pg_event2(isc_task_t *task, isc_event_t *event) {
|
||||
isc_boolean_t sender_match = ISC_FALSE;
|
||||
isc_boolean_t type_match = ISC_FALSE;
|
||||
isc_boolean_t tag_match = ISC_FALSE;
|
||||
bool sender_match = false;
|
||||
bool type_match = false;
|
||||
bool tag_match = false;
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
if ((purge_sender == NULL) || (purge_sender == event->ev_sender)) {
|
||||
sender_match = ISC_TRUE;
|
||||
sender_match = true;
|
||||
}
|
||||
|
||||
if (testrange) {
|
||||
if ((purge_type_first <= event->ev_type) &&
|
||||
(event->ev_type <= purge_type_last))
|
||||
{
|
||||
type_match = ISC_TRUE;
|
||||
type_match = true;
|
||||
}
|
||||
} else {
|
||||
if (purge_type_first == event->ev_type) {
|
||||
type_match = ISC_TRUE;
|
||||
type_match = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((purge_tag == NULL) || (purge_tag == event->ev_tag)) {
|
||||
tag_match = ISC_TRUE;
|
||||
tag_match = true;
|
||||
}
|
||||
|
||||
if (sender_match && type_match && tag_match) {
|
||||
@@ -1033,7 +1034,7 @@ pg_sde(isc_task_t *task, isc_event_t *event) {
|
||||
UNUSED(task);
|
||||
|
||||
LOCK(&lock);
|
||||
done = ISC_TRUE;
|
||||
done = true;
|
||||
SIGNAL(&cv);
|
||||
UNLOCK(&lock);
|
||||
|
||||
@@ -1051,11 +1052,11 @@ test_purge(int sender, int type, int tag, int exp_purged) {
|
||||
int sender_cnt, type_cnt, tag_cnt, event_cnt, i;
|
||||
int purged = 0;
|
||||
|
||||
started = ISC_FALSE;
|
||||
done = ISC_FALSE;
|
||||
started = false;
|
||||
done = false;
|
||||
eventcnt = 0;
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE, 2);
|
||||
result = isc_test_begin(NULL, true, 2);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_mutex_init(&lock);
|
||||
@@ -1146,7 +1147,7 @@ test_purge(int sender, int type, int tag, int exp_purged) {
|
||||
* Unblock the task, allowing event processing.
|
||||
*/
|
||||
LOCK(&lock);
|
||||
started = ISC_TRUE;
|
||||
started = true;
|
||||
SIGNAL(&cv);
|
||||
|
||||
isc_task_shutdown(task);
|
||||
@@ -1191,7 +1192,7 @@ ATF_TC_BODY(purge, tc) {
|
||||
purge_type_first = 4;
|
||||
purge_type_last = 4;
|
||||
purge_tag = (void *)8;
|
||||
testrange = ISC_FALSE;
|
||||
testrange = false;
|
||||
test_purge(1, 4, 7, 1);
|
||||
|
||||
/* Try purging on all senders. */
|
||||
@@ -1200,7 +1201,7 @@ ATF_TC_BODY(purge, tc) {
|
||||
purge_type_first = 4;
|
||||
purge_type_last = 4;
|
||||
purge_tag = (void *)8;
|
||||
testrange = ISC_FALSE;
|
||||
testrange = false;
|
||||
test_purge(1, 4, 7, 3);
|
||||
|
||||
/* Try purging on all senders, specified type, all tags. */
|
||||
@@ -1209,7 +1210,7 @@ ATF_TC_BODY(purge, tc) {
|
||||
purge_type_first = 4;
|
||||
purge_type_last = 4;
|
||||
purge_tag = NULL;
|
||||
testrange = ISC_FALSE;
|
||||
testrange = false;
|
||||
test_purge(1, 4, 7, 15);
|
||||
|
||||
/* Try purging on a specified tag, no such type. */
|
||||
@@ -1218,7 +1219,7 @@ ATF_TC_BODY(purge, tc) {
|
||||
purge_type_first = 99;
|
||||
purge_type_last = 99;
|
||||
purge_tag = (void *)8;
|
||||
testrange = ISC_FALSE;
|
||||
testrange = false;
|
||||
test_purge(1, 4, 7, 0);
|
||||
|
||||
/*
|
||||
@@ -1229,7 +1230,7 @@ ATF_TC_BODY(purge, tc) {
|
||||
purge_type_first = 5;
|
||||
purge_type_last = 5;
|
||||
purge_tag = NULL;
|
||||
testrange = ISC_FALSE;
|
||||
testrange = false;
|
||||
test_purge(1, 4, 7, 5);
|
||||
}
|
||||
|
||||
@@ -1252,7 +1253,7 @@ ATF_TC_BODY(purgerange, tc) {
|
||||
purge_type_first = 4;
|
||||
purge_type_last = 5;
|
||||
purge_tag = (void *)8;
|
||||
testrange = ISC_TRUE;
|
||||
testrange = true;
|
||||
test_purge(1, 4, 7, 1);
|
||||
|
||||
/* Try purging on all senders. */
|
||||
@@ -1261,7 +1262,7 @@ ATF_TC_BODY(purgerange, tc) {
|
||||
purge_type_first = 4;
|
||||
purge_type_last = 5;
|
||||
purge_tag = (void *)8;
|
||||
testrange = ISC_TRUE;
|
||||
testrange = true;
|
||||
test_purge(1, 4, 7, 5);
|
||||
|
||||
/* Try purging on all senders, specified type, all tags. */
|
||||
@@ -1270,7 +1271,7 @@ ATF_TC_BODY(purgerange, tc) {
|
||||
purge_type_first = 5;
|
||||
purge_type_last = 6;
|
||||
purge_tag = NULL;
|
||||
testrange = ISC_TRUE;
|
||||
testrange = true;
|
||||
test_purge(1, 4, 7, 28);
|
||||
|
||||
/* Try purging on a specified tag, no such type. */
|
||||
@@ -1279,7 +1280,7 @@ ATF_TC_BODY(purgerange, tc) {
|
||||
purge_type_first = 99;
|
||||
purge_type_last = 101;
|
||||
purge_tag = (void *)8;
|
||||
testrange = ISC_TRUE;
|
||||
testrange = true;
|
||||
test_purge(1, 4, 7, 0);
|
||||
|
||||
/* Try purging on specified sender, type, all tags. */
|
||||
@@ -1288,7 +1289,7 @@ ATF_TC_BODY(purgerange, tc) {
|
||||
purge_type_first = 5;
|
||||
purge_type_last = 6;
|
||||
purge_tag = NULL;
|
||||
testrange = ISC_TRUE;
|
||||
testrange = true;
|
||||
test_purge(1, 4, 7, 10);
|
||||
}
|
||||
|
||||
@@ -1322,7 +1323,7 @@ pge_sde(isc_task_t *task, isc_event_t *event) {
|
||||
UNUSED(task);
|
||||
|
||||
LOCK(&lock);
|
||||
done = ISC_TRUE;
|
||||
done = true;
|
||||
SIGNAL(&cv);
|
||||
UNLOCK(&lock);
|
||||
|
||||
@@ -1330,18 +1331,18 @@ pge_sde(isc_task_t *task, isc_event_t *event) {
|
||||
}
|
||||
|
||||
static void
|
||||
try_purgeevent(isc_boolean_t purgeable) {
|
||||
try_purgeevent(bool purgeable) {
|
||||
isc_result_t result;
|
||||
isc_task_t *task = NULL;
|
||||
isc_boolean_t purged;
|
||||
bool purged;
|
||||
isc_event_t *event1 = NULL;
|
||||
isc_event_t *event2 = NULL;
|
||||
isc_event_t *event2_clone = NULL;;
|
||||
isc_time_t now;
|
||||
isc_interval_t interval;
|
||||
|
||||
started = ISC_FALSE;
|
||||
done = ISC_FALSE;
|
||||
started = false;
|
||||
done = false;
|
||||
eventcnt = 0;
|
||||
|
||||
result = isc_mutex_init(&lock);
|
||||
@@ -1350,7 +1351,7 @@ try_purgeevent(isc_boolean_t purgeable) {
|
||||
result = isc_condition_init(&cv);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_test_begin(NULL, ISC_TRUE, 2);
|
||||
result = isc_test_begin(NULL, true, 2);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_task_create(taskmgr, 0, &task);
|
||||
@@ -1388,7 +1389,7 @@ try_purgeevent(isc_boolean_t purgeable) {
|
||||
* Unblock the task, allowing event processing.
|
||||
*/
|
||||
LOCK(&lock);
|
||||
started = ISC_TRUE;
|
||||
started = true;
|
||||
SIGNAL(&cv);
|
||||
|
||||
isc_task_shutdown(task);
|
||||
@@ -1420,7 +1421,7 @@ try_purgeevent(isc_boolean_t purgeable) {
|
||||
* Purge event test:
|
||||
* When the event is marked as purgeable, a call to
|
||||
* isc_task_purgeevent(task, event) purges the event 'event' from the
|
||||
* task's queue and returns ISC_TRUE.
|
||||
* task's queue and returns true.
|
||||
*/
|
||||
|
||||
ATF_TC(purgeevent);
|
||||
@@ -1428,14 +1429,14 @@ ATF_TC_HEAD(purgeevent, tc) {
|
||||
atf_tc_set_md_var(tc, "descr", "purge-event");
|
||||
}
|
||||
ATF_TC_BODY(purgeevent, tc) {
|
||||
try_purgeevent(ISC_TRUE);
|
||||
try_purgeevent(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Purge event not purgeable test:
|
||||
* When the event is not marked as purgable, a call to
|
||||
* isc_task_purgeevent(task, event) does not purge the event
|
||||
* 'event' from the task's queue and returns ISC_FALSE.
|
||||
* 'event' from the task's queue and returns false.
|
||||
*/
|
||||
|
||||
ATF_TC(purgeevent_notpurge);
|
||||
@@ -1443,7 +1444,7 @@ ATF_TC_HEAD(purgeevent_notpurge, tc) {
|
||||
atf_tc_set_md_var(tc, "descr", "purge-event");
|
||||
}
|
||||
ATF_TC_BODY(purgeevent_notpurge, tc) {
|
||||
try_purgeevent(ISC_FALSE);
|
||||
try_purgeevent(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user