Remove deprecated check macros

check 0.15 seems to have broken them so now seems as
good a time as any to update.
This commit is contained in:
Christine Caulfield 2020-07-29 15:10:04 +01:00
parent b43959c656
commit 8e7d236a12
2 changed files with 613 additions and 1 deletions

View File

@ -0,0 +1,606 @@
From: Christine Caulfield <ccaulfie@redhat.com>
diff --git a/tests/check_array.c b/tests/check_array.c
index e86cd44..1abfd73 100644
--- a/tests/check_array.c
+++ b/tests/check_array.c
@@ -44,15 +44,15 @@ START_TEST(test_array_limits)
struct test_my_st *st;
a = qb_array_create(INT_MAX, sizeof(struct test_my_st));
- fail_unless(a == NULL);
+ ck_assert(a == NULL);
a = qb_array_create(-56, sizeof(struct test_my_st));
- fail_unless(a == NULL);
+ ck_assert(a == NULL);
a = qb_array_create(67, 0);
- fail_unless(a == NULL);
+ ck_assert(a == NULL);
/* working array */
a = qb_array_create(10, sizeof(struct test_my_st));
- fail_if(a == NULL);
+ ck_assert(a != NULL);
/* out-of-bounds */
res = qb_array_index(a, 10, (void**)&st);
@@ -129,7 +129,7 @@ START_TEST(test_array_static_memory)
/* confirm the pointer is the same after a grow */
res = qb_array_index(a, 99, (void**)&st);
ck_assert_int_eq(res, 0);
- fail_unless(st == st_old);
+ ck_assert(st == st_old);
qb_array_free(a);
}
diff --git a/tests/check_ipc.c b/tests/check_ipc.c
index 859c922..345c2af 100644
--- a/tests/check_ipc.c
+++ b/tests/check_ipc.c
@@ -278,7 +278,7 @@ pipe_reader(int fd, int revents, void *data) {
rbytes_sum += rbytes;
}
if (rbytes_sum > 0) {
- fail_if(buf[0] == '\0'); /* avoid dead store elimination */
+ ck_assert(buf[0] != '\0'); /* avoid dead store elimination */
qb_log(LOG_DEBUG, "read %zd bytes", rbytes_sum);
sleep(1);
}
@@ -420,7 +420,7 @@ s1_msg_process_fn(qb_ipcs_connection_t *c,
} else if (req_pt->id == IPC_MSG_REQ_SELF_FEED) {
if (pipe(global_pipefd) != 0) {
perror("pipefd");
- fail_if(1);
+ ck_assert(0);
}
fcntl(global_pipefd[0], F_SETFL, O_NONBLOCK);
fcntl(global_pipefd[1], F_SETFL, O_NONBLOCK);
@@ -429,7 +429,7 @@ s1_msg_process_fn(qb_ipcs_connection_t *c,
GSource *source_r, *source_w;
source_r = g_source_new(&gio_source_funcs, sizeof(GSource));
source_w = g_source_new(&gio_source_funcs, sizeof(GSource));
- fail_if(source_r == NULL || source_w == NULL);
+ ck_assert(source_r != NULL && source_w != NULL);
g_source_set_priority(source_r, conv_prio_libqb2glib(QB_LOOP_HIGH));
g_source_set_priority(source_w, conv_prio_libqb2glib(QB_LOOP_HIGH));
g_source_set_can_recurse(source_r, FALSE);
@@ -441,7 +441,7 @@ s1_msg_process_fn(qb_ipcs_connection_t *c,
g_source_attach(source_r, NULL);
g_source_attach(source_w, NULL);
#else
- fail_if(1);
+ ck_assert(0);
#endif
} else {
qb_loop_poll_add(my_loop, QB_LOOP_HIGH, global_pipefd[1],
@@ -759,7 +759,7 @@ NEW_PROCESS_RUNNER(run_ipc_server, ready_signaller, signaller_data, data)
s1 = qb_ipcs_create(ipc_name, 4, ipc_type, &sh);
- fail_if(s1 == 0);
+ ck_assert(s1 != 0);
if (global_loop_prio != QB_LOOP_MED) {
qb_ipcs_request_rate_limit(s1,
@@ -775,9 +775,9 @@ NEW_PROCESS_RUNNER(run_ipc_server, ready_signaller, signaller_data, data)
};
glib_loop = g_main_loop_new(NULL, FALSE);
gio_map = qb_array_create_2(16, sizeof(struct gio_to_qb_poll), 1);
- fail_if (gio_map == NULL);
+ ck_assert(gio_map != NULL);
#else
- fail_if(1);
+ ck_assert(0);
#endif
} else {
ph = (struct qb_ipcs_poll_handlers) {
@@ -936,7 +936,7 @@ verify_graceful_stop(pid_t pid)
rc = WEXITSTATUS(status);
ck_assert_int_eq(rc, 0);
} else {
- fail_if(rc == 0);
+ ck_assert(rc != 0);
}
return 0;
@@ -1020,7 +1020,7 @@ test_ipc_txrx_timeout(void)
uint32_t max_size = MAX_MSG_SIZE;
pid = run_function_in_new_process("server", run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
do {
conn = qb_ipcc_connect(ipc_name, max_size);
@@ -1031,7 +1031,7 @@ test_ipc_txrx_timeout(void)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
/* The dispatch response will only come over
* the event channel, we want to verify the receive times
@@ -1068,7 +1068,7 @@ test_ipc_txrx(void)
uint32_t max_size = MAX_MSG_SIZE;
pid = run_function_in_new_process("server", run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
do {
conn = qb_ipcc_connect(ipc_name, max_size);
@@ -1079,7 +1079,7 @@ test_ipc_txrx(void)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
size = QB_MIN(sizeof(struct qb_ipc_request_header), 64);
for (j = 1; j < 19; j++) {
@@ -1118,7 +1118,7 @@ test_ipc_exit(void)
uint32_t max_size = MAX_MSG_SIZE;
pid = run_function_in_new_process("server", run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
do {
conn = qb_ipcc_connect(ipc_name, max_size);
@@ -1129,7 +1129,7 @@ test_ipc_exit(void)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
req_header.id = IPC_MSG_REQ_TX_RX;
req_header.size = sizeof(struct qb_ipc_request_header);
@@ -1295,7 +1295,7 @@ NEW_PROCESS_RUNNER(client_dispatch, ready_signaller, signaller_data, data)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
if (ready_signaller != NULL) {
ready_signaller(signaller_data);
@@ -1324,7 +1324,7 @@ test_ipc_dispatch(void)
struct dispatch_data data;
pid = run_function_in_new_process(NULL, run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
data = (struct dispatch_data){.server_pid = pid,
.msg_type = IPC_MSG_REQ_DISPATCH,
.repetitions = 1};
@@ -1434,7 +1434,7 @@ test_ipc_stress_connections(void)
qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_TRUE);
pid = run_function_in_new_process("server", run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
for (connections = 1; connections < NUM_STRESS_CONNECTIONS; connections++) {
if (conn) {
@@ -1450,7 +1450,7 @@ test_ipc_stress_connections(void)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
if (((connections+1) % 1000) == 0) {
qb_log(LOG_INFO, "%d ipc connections made", connections+1);
@@ -1481,7 +1481,7 @@ test_ipc_bulk_events(void)
uint32_t max_size = MAX_MSG_SIZE;
pid = run_function_in_new_process("server", run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
do {
conn = qb_ipcc_connect(ipc_name, max_size);
@@ -1492,7 +1492,7 @@ test_ipc_bulk_events(void)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
events_received = 0;
cl = qb_loop_create();
@@ -1546,7 +1546,7 @@ test_ipc_stress_test(void)
enforce_server_buffer = 1;
pid = run_function_in_new_process("server", run_ipc_server, NULL);
enforce_server_buffer = 0;
- fail_if(pid == -1);
+ ck_assert(pid != -1);
do {
conn = qb_ipcc_connect(ipc_name, client_buf_size);
@@ -1557,7 +1557,7 @@ test_ipc_stress_test(void)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
real_buf_size = qb_ipcc_get_buffer_size(conn);
ck_assert_int_eq(real_buf_size, max_size);
@@ -1655,14 +1655,14 @@ START_TEST(test_ipc_dispatch_us_native_prio_dlock)
server_pid = run_function_in_new_process("server", run_ipc_server,
NULL);
- fail_if(server_pid == -1);
+ ck_assert(server_pid != -1);
data = (struct dispatch_data){.server_pid = server_pid,
.msg_type = IPC_MSG_REQ_SELF_FEED,
.repetitions = 1};
alphaclient_pid = run_function_in_new_process("alphaclient",
client_dispatch,
(void *) &data);
- fail_if(alphaclient_pid == -1);
+ ck_assert(alphaclient_pid != -1);
//sleep(1);
sched_yield();
@@ -1695,14 +1695,14 @@ START_TEST(test_ipc_dispatch_us_glib_prio_dlock)
server_pid = run_function_in_new_process("server", run_ipc_server,
NULL);
- fail_if(server_pid == -1);
+ ck_assert(server_pid != -1);
data = (struct dispatch_data){.server_pid = server_pid,
.msg_type = IPC_MSG_REQ_SELF_FEED,
.repetitions = 1};
alphaclient_pid = run_function_in_new_process("alphaclient",
client_dispatch,
(void *) &data);
- fail_if(alphaclient_pid == -1);
+ ck_assert(alphaclient_pid != -1);
//sleep(1);
sched_yield();
@@ -1733,7 +1733,7 @@ test_ipc_event_on_created(void)
num_bulk_events = 1;
pid = run_function_in_new_process("server", run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
do {
conn = qb_ipcc_connect(ipc_name, max_size);
@@ -1744,7 +1744,7 @@ test_ipc_event_on_created(void)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
events_received = 0;
cl = qb_loop_create();
@@ -1787,7 +1787,7 @@ test_ipc_disconnect_after_created(void)
uint32_t max_size = MAX_MSG_SIZE;
pid = run_function_in_new_process("server", run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
do {
conn = qb_ipcc_connect(ipc_name, max_size);
@@ -1798,7 +1798,7 @@ test_ipc_disconnect_after_created(void)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
ck_assert_int_eq(QB_TRUE, qb_ipcc_is_connected(conn));
@@ -1844,7 +1844,7 @@ test_ipc_server_fail(void)
uint32_t max_size = MAX_MSG_SIZE;
pid = run_function_in_new_process("server", run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
do {
conn = qb_ipcc_connect(ipc_name, max_size);
@@ -1855,7 +1855,7 @@ test_ipc_server_fail(void)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
request_server_exit();
if (_fi_unlink_inject_failure == QB_TRUE) {
@@ -1933,7 +1933,7 @@ START_TEST(test_ipc_server_perms)
max_size = MAX_MSG_SIZE;
pid = run_function_in_new_process("server", run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
do {
conn = qb_ipcc_connect(ipc_name, max_size);
@@ -1944,7 +1944,7 @@ START_TEST(test_ipc_server_perms)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
/* Check perms - uses illegal access to libqb internals */
@@ -1990,14 +1990,14 @@ START_TEST(test_ipc_dispatch_shm_native_prio_dlock)
server_pid = run_function_in_new_process("server", run_ipc_server,
NULL);
- fail_if(server_pid == -1);
+ ck_assert(server_pid != -1);
data = (struct dispatch_data){.server_pid = server_pid,
.msg_type = IPC_MSG_REQ_SELF_FEED,
.repetitions = 1};
alphaclient_pid = run_function_in_new_process("alphaclient",
client_dispatch,
(void *) &data);
- fail_if(alphaclient_pid == -1);
+ ck_assert(alphaclient_pid != -1);
//sleep(1);
sched_yield();
@@ -2030,14 +2030,14 @@ START_TEST(test_ipc_dispatch_shm_glib_prio_dlock)
server_pid = run_function_in_new_process("server", run_ipc_server,
NULL);
- fail_if(server_pid == -1);
+ ck_assert(server_pid != -1);
data = (struct dispatch_data){.server_pid = server_pid,
.msg_type = IPC_MSG_REQ_SELF_FEED,
.repetitions = 1};
alphaclient_pid = run_function_in_new_process("alphaclient",
client_dispatch,
(void *) &data);
- fail_if(alphaclient_pid == -1);
+ ck_assert(alphaclient_pid != -1);
//sleep(1);
sched_yield();
@@ -2122,7 +2122,7 @@ test_ipc_service_ref_count(void)
reference_count_test = QB_TRUE;
pid = run_function_in_new_process("server", run_ipc_server, NULL);
- fail_if(pid == -1);
+ ck_assert(pid != -1);
do {
conn = qb_ipcc_connect(ipc_name, max_size);
@@ -2133,7 +2133,7 @@ test_ipc_service_ref_count(void)
c++;
}
} while (conn == NULL && c < 5);
- fail_if(conn == NULL);
+ ck_assert(conn != NULL);
sleep(5);
@@ -2175,7 +2175,7 @@ static void test_max_dgram_size(void)
QB_LOG_FILTER_FILE, "*", LOG_TRACE);
init = qb_ipcc_verify_dgram_max_msg_size(1000000);
- fail_if(init <= 0);
+ ck_assert(init > 0);
for (i = 0; i < 100; i++) {
int try = qb_ipcc_verify_dgram_max_msg_size(1000000);
#if 0
diff --git a/tests/check_loop.c b/tests/check_loop.c
index 81cc2ba..c017c2c 100644
--- a/tests/check_loop.c
+++ b/tests/check_loop.c
@@ -148,7 +148,7 @@ START_TEST(test_loop_job_input)
ck_assert_int_eq(res, -EINVAL);
l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
res = qb_loop_job_add(NULL, QB_LOOP_LOW, NULL, job_2);
ck_assert_int_eq(res, 0);
@@ -164,7 +164,7 @@ START_TEST(test_loop_job_1)
{
int32_t res;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
res = qb_loop_job_add(l, QB_LOOP_LOW, NULL, job_1);
ck_assert_int_eq(res, 0);
@@ -181,7 +181,7 @@ START_TEST(test_loop_job_4)
{
int32_t res;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
res = qb_loop_job_add(l, QB_LOOP_LOW, l, job_1_r);
ck_assert_int_eq(res, 0);
@@ -198,13 +198,13 @@ START_TEST(test_loop_job_nuts)
{
int32_t res;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
res = qb_loop_job_add(l, QB_LOOP_LOW, l, job_1_add_nuts);
ck_assert_int_eq(res, 0);
qb_loop_run(l);
- fail_if(job_1_run_count < 500);
+ ck_assert(job_1_run_count >= 500);
qb_loop_destroy(l);
}
END_TEST
@@ -213,7 +213,7 @@ START_TEST(test_loop_job_order)
{
int32_t res;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
job_1_run_count = 0;
@@ -267,10 +267,10 @@ START_TEST(test_job_rate_limit)
{
int32_t res;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
rl_sw = qb_util_stopwatch_create();
- fail_if(rl_sw == NULL);
+ ck_assert(rl_sw != NULL);
qb_util_stopwatch_start(rl_sw);
@@ -303,7 +303,7 @@ START_TEST(test_job_add_del)
{
int32_t res;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
res = qb_loop_job_add(l, QB_LOOP_MED, l, job_1);
ck_assert_int_eq(res, 0);
@@ -374,7 +374,7 @@ START_TEST(test_loop_timer_input)
ck_assert_int_eq(res, -EINVAL);
l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
res = qb_loop_timer_add(NULL, QB_LOOP_LOW, 5*QB_TIME_NS_IN_MSEC, NULL, job_2, &test_th);
ck_assert_int_eq(res, 0);
@@ -414,7 +414,7 @@ START_TEST(test_loop_timer_basic)
{
int32_t res;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
res = qb_loop_timer_add(l, QB_LOOP_LOW, 5*QB_TIME_NS_IN_MSEC, l, one_shot_tmo, &test_th);
ck_assert_int_eq(res, 0);
@@ -503,7 +503,7 @@ START_TEST(test_loop_timer_precision)
struct qb_stop_watch sw[11];
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
for (i = 0; i < 10; i++) {
tmo = ((1 + i * 9) * QB_TIME_NS_IN_MSEC) + 500000;
@@ -567,7 +567,7 @@ START_TEST(test_loop_timer_expire_leak)
qb_loop_timer_handle th;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
expire_leak_counter = 0;
for (i = 0; i < 300; i++) {
@@ -605,7 +605,7 @@ START_TEST(test_loop_sig_handling)
{
qb_loop_signal_handle handle;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
qb_loop_signal_add(l, QB_LOOP_HIGH, SIGINT,
l, sig_handler, &handle);
@@ -638,7 +638,7 @@ START_TEST(test_loop_dont_override_other_signals)
qb_loop_signal_handle handle;
this_l = qb_loop_create();
- fail_if(this_l == NULL);
+ ck_assert(this_l != NULL);
signal(SIGUSR1, handle_nonqb_signal);
@@ -659,7 +659,7 @@ START_TEST(test_loop_sig_only_get_one)
int res;
qb_loop_signal_handle handle;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
/* make sure we only get one call to the handler
* don't assume we are going to exit the loop.
@@ -708,7 +708,7 @@ START_TEST(test_loop_sig_delete)
{
int res;
qb_loop_t *l = qb_loop_create();
- fail_if(l == NULL);
+ ck_assert(l != NULL);
/* make sure we can remove a signal job from the job queue.
*/
diff --git a/tests/check_rb.c b/tests/check_rb.c
index 498cc71..7b6c01d 100644
--- a/tests/check_rb.c
+++ b/tests/check_rb.c
@@ -45,7 +45,7 @@ START_TEST(test_ring_buffer1)
ssize_t avail;
rb = qb_rb_open("test1", 200, QB_RB_FLAG_CREATE, 0);
- fail_if(rb == NULL);
+ ck_assert(rb != NULL);
for (b = 0; b < 3; b++) {
memcpy(&hdr, my_buf, sizeof(struct qb_ipc_request_header));
@@ -100,7 +100,7 @@ START_TEST(test_ring_buffer2)
ssize_t l;
t = qb_rb_open("test2", 200 * sizeof(int64_t), QB_RB_FLAG_CREATE, 0);
- fail_if(t == NULL);
+ ck_assert(t != NULL);
for (i = 0; i < 200; i++) {
l = qb_rb_chunk_write(t, &v, sizeof(v));
ck_assert_int_eq(l, sizeof(v));
@@ -108,7 +108,7 @@ START_TEST(test_ring_buffer2)
for (i = 0; i < 100; i++) {
l = qb_rb_chunk_peek(t, (void **)&new_data, 0);
ck_assert_int_eq(l, sizeof(v));
- fail_unless(v == *new_data);
+ ck_assert(v == *new_data);
qb_rb_chunk_reclaim(t);
}
for (i = 0; i < 100; i++) {
@@ -122,7 +122,7 @@ START_TEST(test_ring_buffer2)
break;
}
ck_assert_int_eq(l, sizeof(v));
- fail_unless(v == *new_data);
+ ck_assert(v == *new_data);
qb_rb_chunk_reclaim(t);
}
qb_rb_close(t);
@@ -142,7 +142,7 @@ START_TEST(test_ring_buffer3)
size_t len = strlen(v) + 1;
t = qb_rb_open("test3", 10, QB_RB_FLAG_CREATE | QB_RB_FLAG_OVERWRITE, 0);
- fail_if(t == NULL);
+ ck_assert(t != NULL);
for (i = 0; i < 9000; i++) {
l = qb_rb_chunk_write(t, v, len);
ck_assert_int_eq(l, len);
@@ -169,7 +169,7 @@ START_TEST(test_ring_buffer4)
ssize_t l;
t = qb_rb_open("test4", 10, QB_RB_FLAG_CREATE | QB_RB_FLAG_OVERWRITE, 0);
- fail_if(t == NULL);
+ ck_assert(t != NULL);
for (i = 0; i < 2000; i++) {
l = qb_rb_chunk_write(t, data, strlen(data));
ck_assert_int_eq(l, strlen(data));

View File

@ -2,13 +2,15 @@
Name: libqb
Version: 2.0.1
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Library providing high performance logging, tracing, ipc, and poll
License: LGPLv2+
URL: https://github.com/ClusterLabs/libqb
Source0: https://github.com/ClusterLabs/libqb/releases/download/v%{version}/%{name}-%{version}.tar.xz
Patch1: libqb-2.0.1-remove-deprecated-check-macros.patch
BuildRequires: autoconf automake libtool
BuildRequires: check-devel
BuildRequires: doxygen
@ -83,6 +85,10 @@ This package contains a program to create nicely-formatted man pages from Doxyge
%changelog
* Wed Jul 29 2020 Christine Caulfield <ccaulfie@redhat.com> 2.0.1-2
- Replace deprecated check macros fail_if() and fail_unless() with ck_assert()
see check BZ: bz1850198
* Wed Jul 29 2020 Christine Caulfield <ccaulfie@redhat.com> 2.0.1-1
- Rebase to version 2.0.1