[PATCH] unit tests: replace deprecated BOOST_MESSAGE with BOOST_TEST_MESSAGE

6 views
Skip to first unread message

Waldemar Kozaczuk

unread,
Nov 28, 2019, 12:43:06 AM11/28/19
to osv...@googlegroups.com, Waldemar Kozaczuk
This patch resolves compilations errors with newer versions
of boost.

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
tests/tst-poll.cc | 36 ++++++++++++++++++------------------
tests/tst-tcp-listen.cc | 14 +++++++-------
tests/tst-timer-set.cc | 18 +++++++++---------
3 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/tests/tst-poll.cc b/tests/tst-poll.cc
index 108a93a9..16a2b8b0 100644
--- a/tests/tst-poll.cc
+++ b/tests/tst-poll.cc
@@ -29,13 +29,13 @@ BOOST_AUTO_TEST_CASE(test_polling_on_negative_fd_yields_no_events)
pfd.events = POLLIN;
}

- BOOST_MESSAGE("test 1 file case");
+ BOOST_TEST_MESSAGE("test 1 file case");
pfd_array[0].revents = POLLIN;
BOOST_REQUIRE(poll(pfd_array, 1, 0) == 0);
BOOST_REQUIRE(pfd_array[0].revents == 0);


- BOOST_MESSAGE("test many files case");
+ BOOST_TEST_MESSAGE("test many files case");
pfd_array[0].revents = POLLIN;
pfd_array[1].revents = POLLIN;
BOOST_REQUIRE(poll(pfd_array, 2, 0) == 0);
@@ -52,12 +52,12 @@ BOOST_AUTO_TEST_CASE(test_polling_on_invalid_fd_yields_pollnval_event)
pfd.events = POLLIN;
}

- BOOST_MESSAGE("test 1 file case");
+ BOOST_TEST_MESSAGE("test 1 file case");
pfd_array[0].revents = 0;
BOOST_REQUIRE(poll(pfd_array, 1, 0) == 1);
BOOST_REQUIRE(pfd_array[0].revents == POLLNVAL);

- BOOST_MESSAGE("test many files case");
+ BOOST_TEST_MESSAGE("test many files case");
pfd_array[0].revents = 0;
pfd_array[1].revents = 0;
BOOST_REQUIRE(poll(pfd_array, 2, 0) == 2);
@@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(test_polling_on_one_socket)
raddr.sin_port = htons(LISTEN_PORT);

std::this_thread::sleep_for(std::chrono::milliseconds(50));
- BOOST_MESSAGE("connecting...");
+ BOOST_TEST_MESSAGE("connecting...");
auto ret = connect(s, (struct sockaddr *)&raddr, sizeof(raddr));
BOOST_REQUIRE(ret == 0 || errno == EINPROGRESS);

@@ -101,29 +101,29 @@ BOOST_AUTO_TEST_CASE(test_polling_on_one_socket)
pfd.events = POLLOUT;
BOOST_REQUIRE(poll(&pfd, 1, -1) == 1);

- BOOST_MESSAGE("conected...");
+ BOOST_TEST_MESSAGE("conected...");

can_write.await();

- BOOST_MESSAGE("writing...");
+ BOOST_TEST_MESSAGE("writing...");
BOOST_REQUIRE(write(s, "!", 1) == 1);

can_read.await();

- BOOST_MESSAGE("reading...");
+ BOOST_TEST_MESSAGE("reading...");

char buf[16];
do {} while (read(s, buf, sizeof(buf)) > 0);

- BOOST_MESSAGE("done...");
+ BOOST_TEST_MESSAGE("done...");

can_close.await();

- BOOST_MESSAGE("closing...");
+ BOOST_TEST_MESSAGE("closing...");
close(s);
});

- BOOST_MESSAGE("checking that poll will return POLLIN when accept() is ready");
+ BOOST_TEST_MESSAGE("checking that poll will return POLLIN when accept() is ready");
struct pollfd pfd;
pfd.fd = s;
pfd.events = POLLIN;
@@ -137,19 +137,19 @@ BOOST_AUTO_TEST_CASE(test_polling_on_one_socket)
pfd.events = POLLOUT;
BOOST_REQUIRE(poll(&pfd, 1, 500) == 1);

- BOOST_MESSAGE("checking that poll will not return POLLIN when nothing to read");
+ BOOST_TEST_MESSAGE("checking that poll will not return POLLIN when nothing to read");
pfd.events = POLLIN;
BOOST_REQUIRE(poll(&pfd, 1, 0) == 0);
BOOST_REQUIRE(pfd.revents == 0);

can_write.count_down();

- BOOST_MESSAGE("checking that poll will return POLLIN when read() is ready");
+ BOOST_TEST_MESSAGE("checking that poll will return POLLIN when read() is ready");
pfd.events = POLLIN;
BOOST_REQUIRE(poll(&pfd, 1, 500) == 1);
BOOST_REQUIRE(pfd.revents == POLLIN);

- BOOST_MESSAGE("checking that poll will return both POLLIN and POLLOUT");
+ BOOST_TEST_MESSAGE("checking that poll will return both POLLIN and POLLOUT");
pfd.events = POLLIN | POLLOUT;
BOOST_REQUIRE(poll(&pfd, 1, 0) == 1);
BOOST_REQUIRE(pfd.revents == (POLLIN | POLLOUT));
@@ -157,24 +157,24 @@ BOOST_AUTO_TEST_CASE(test_polling_on_one_socket)
char buf[16];
BOOST_REQUIRE(read(client_socket, buf, 1) == 1);

- BOOST_MESSAGE("checking no events after read");
+ BOOST_TEST_MESSAGE("checking no events after read");
pfd.events = POLLIN;
BOOST_REQUIRE(poll(&pfd, 1, 0) == 0);
BOOST_REQUIRE(pfd.revents == 0);

- BOOST_MESSAGE("filling up socket buffer...");
+ BOOST_TEST_MESSAGE("filling up socket buffer...");
do {} while (write(client_socket, buf, sizeof(buf)) > 0);

can_read.count_down();

- BOOST_MESSAGE("checking socket is unblocked for write");
+ BOOST_TEST_MESSAGE("checking socket is unblocked for write");
pfd.events = POLLOUT;
BOOST_REQUIRE(poll(&pfd, 1, 500) == 1);
BOOST_REQUIRE(pfd.revents == POLLOUT);

can_close.count_down();

- BOOST_MESSAGE("checking that poll will return POLLIN when close() is ready");
+ BOOST_TEST_MESSAGE("checking that poll will return POLLIN when close() is ready");
pfd.events = POLLIN;
BOOST_REQUIRE(poll(&pfd, 1, 500) == 1);
BOOST_REQUIRE(pfd.revents == POLLIN);
diff --git a/tests/tst-tcp-listen.cc b/tests/tst-tcp-listen.cc
index b6874451..6e44b56b 100644
--- a/tests/tst-tcp-listen.cc
+++ b/tests/tst-tcp-listen.cc
@@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE(test_connections_get_accepted_even_when_backlog_gets_overfl
BOOST_REQUIRE(bind(listen_s, (struct sockaddr *) &laddr, sizeof(laddr)) == 0);
BOOST_REQUIRE(listen(listen_s, backlog_size) == 0);

- BOOST_MESSAGE("listening...");
+ BOOST_TEST_MESSAGE("listening...");

for (int i = 0; i < n_connections; i++) {
int s = socket(AF_INET, SOCK_STREAM, 0);
@@ -76,23 +76,23 @@ BOOST_AUTO_TEST_CASE(test_connections_get_accepted_even_when_backlog_gets_overfl
inet_aton("127.0.0.1", &raddr.sin_addr);
raddr.sin_port = htons(LISTEN_PORT);

- BOOST_MESSAGE("connecting...");
+ BOOST_TEST_MESSAGE("connecting...");

BOOST_REQUIRE(connect(s, (struct sockaddr *)&raddr, sizeof(raddr)) == 0);
sockets_to_close.push_back(s);
}

- BOOST_MESSAGE("starting to accept...");
+ BOOST_TEST_MESSAGE("starting to accept...");

for (int i = 0; i < n_connections; i++) {
int client_s = accept_with_timeout(listen_s, 3);
BOOST_REQUIRE(client_s >= 0);
- BOOST_MESSAGE("accepted");
+ BOOST_TEST_MESSAGE("accepted");

sockets_to_close.push_back(client_s);
}

- BOOST_MESSAGE("closing...");
+ BOOST_TEST_MESSAGE("closing...");

for (auto& fd : sockets_to_close) {
close(fd);
@@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(test_clients_are_not_reset_when_backlog_is_full_and_they_wr

BOOST_REQUIRE(listen(listen_s, backlog_size) == 0);

- BOOST_MESSAGE("listening...");
+ BOOST_TEST_MESSAGE("listening...");

std::vector<std::thread*> threads;

@@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(test_clients_are_not_reset_when_backlog_is_full_and_they_wr

for (int i = 0; i < n_connections; i++) {
int client_s = accept_with_timeout(listen_s, 3);
- BOOST_MESSAGE("accepted");
+ BOOST_TEST_MESSAGE("accepted");

threads.push_back(new std::thread([client_s] {
auto close_at = _clock::now() + std::chrono::milliseconds(50);
diff --git a/tests/tst-timer-set.cc b/tests/tst-timer-set.cc
index 30a74d04..ec3b94c6 100644
--- a/tests/tst-timer-set.cc
+++ b/tests/tst-timer-set.cc
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(test_typical_timer_insertion_and_expiry)
test_timer t2(m2);
test_timer t3(m4);

- BOOST_MESSAGE("Expire when no timers inserted yet");
+ BOOST_TEST_MESSAGE("Expire when no timers inserted yet");
_timers.expire(m3);
BOOST_REQUIRE(_timers.pop_expired() == nullptr);
BOOST_REQUIRE(_timers.get_next_timeout() == Clock::time_point::max());
@@ -94,12 +94,12 @@ BOOST_AUTO_TEST_CASE(test_typical_timer_insertion_and_expiry)
BOOST_REQUIRE_EQUAL(_timers.insert(t3), false);
BOOST_REQUIRE_EQUAL(_timers.insert(t1), true);

- BOOST_MESSAGE("Expiring now should yield the first two timers");
+ BOOST_TEST_MESSAGE("Expiring now should yield the first two timers");
_timers.expire(m3);
BOOST_REQUIRE(get_expired(_timers) == timer_ptr_set({&t1, &t2}));
BOOST_REQUIRE(_timers.get_next_timeout() == m4);

- BOOST_MESSAGE("Expiring at the same moment again yields no timers");
+ BOOST_TEST_MESSAGE("Expiring at the same moment again yields no timers");
_timers.expire(m3);
BOOST_REQUIRE(_timers.pop_expired() == nullptr);
BOOST_REQUIRE(_timers.get_next_timeout() == m4);
@@ -110,12 +110,12 @@ BOOST_AUTO_TEST_CASE(test_typical_timer_insertion_and_expiry)
BOOST_REQUIRE_EQUAL(_timers.insert(t5), false);
BOOST_REQUIRE_EQUAL(_timers.insert(t4), false);

- BOOST_MESSAGE("Expire two timers at the same time point");
+ BOOST_TEST_MESSAGE("Expire two timers at the same time point");
_timers.expire(m4);
BOOST_REQUIRE(get_expired(_timers) == timer_ptr_set({&t3, &t4}));
BOOST_REQUIRE(_timers.get_next_timeout() == m5);

- BOOST_MESSAGE("Expire last timer");
+ BOOST_TEST_MESSAGE("Expire last timer");
_timers.expire(m6);
BOOST_REQUIRE(get_expired(_timers) == timer_ptr_set({&t5}));
BOOST_REQUIRE(_timers.get_next_timeout() == Clock::time_point::max());
@@ -137,12 +137,12 @@ BOOST_AUTO_TEST_CASE(test_next_timeout_is_updated_correctly_after_expiry_when_th
_timers.insert(t1);
_timers.insert(t3);

- BOOST_MESSAGE("Expiring in a way that there should be still active timers in higher buckets");
+ BOOST_TEST_MESSAGE("Expiring in a way that there should be still active timers in higher buckets");
_timers.expire(m1);
BOOST_REQUIRE(get_expired(_timers) == timer_ptr_set({&t1}));
BOOST_REQUIRE(_timers.get_next_timeout() == m3);

- BOOST_MESSAGE("Checking that it is signalled that timer 2 is now the earliest timer");
+ BOOST_TEST_MESSAGE("Checking that it is signalled that timer 2 is now the earliest timer");
BOOST_REQUIRE_EQUAL(_timers.insert(t2), true);

_timers.clear();
@@ -236,12 +236,12 @@ BOOST_AUTO_TEST_CASE(test_expiry_when_some_timers_remain_in_the_expired_bucket)
_timers.insert(t4);
_timers.insert(t5);

- BOOST_MESSAGE("timers t1-t6 share a bucket, expire only some");
+ BOOST_TEST_MESSAGE("timers t1-t6 share a bucket, expire only some");
_timers.expire(m4);
BOOST_REQUIRE(get_expired(_timers) == timer_ptr_set({&t1, &t2}));
BOOST_REQUIRE(_timers.get_next_timeout() == m5);

- BOOST_MESSAGE("now check if the remaining timers will expire when we expire after their bucket");
+ BOOST_TEST_MESSAGE("now check if the remaining timers will expire when we expire after their bucket");
_timers.expire(m7);
BOOST_REQUIRE(get_expired(_timers) == timer_ptr_set({&t3, &t4}));
BOOST_REQUIRE(_timers.get_next_timeout() == m8);
--
2.20.1

Commit Bot

unread,
Nov 28, 2019, 3:00:16 AM11/28/19
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

unit tests: replace deprecated BOOST_MESSAGE with BOOST_TEST_MESSAGE

This patch resolves compilations errors with newer versions
of boost.

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
Message-Id: <20191128054258.1...@gmail.com>

---
diff --git a/tests/tst-poll.cc b/tests/tst-poll.cc
@@ -137,44 +137,44 @@ BOOST_AUTO_TEST_CASE(test_polling_on_one_socket)
pfd.events = POLLOUT;
BOOST_REQUIRE(poll(&pfd, 1, 500) == 1);

- BOOST_MESSAGE("checking that poll will not return POLLIN when nothing
to read");
+ BOOST_TEST_MESSAGE("checking that poll will not return POLLIN when
nothing to read");
pfd.events = POLLIN;
BOOST_REQUIRE(poll(&pfd, 1, 0) == 0);
BOOST_REQUIRE(pfd.revents == 0);

can_write.count_down();

- BOOST_MESSAGE("checking that poll will return POLLIN when read() is
ready");
+ BOOST_TEST_MESSAGE("checking that poll will return POLLIN when read()
is ready");
pfd.events = POLLIN;
BOOST_REQUIRE(poll(&pfd, 1, 500) == 1);
BOOST_REQUIRE(pfd.revents == POLLIN);

- BOOST_MESSAGE("checking that poll will return both POLLIN and
POLLOUT");
+ BOOST_TEST_MESSAGE("checking that poll will return both POLLIN and
POLLOUT");
pfd.events = POLLIN | POLLOUT;
BOOST_REQUIRE(poll(&pfd, 1, 0) == 1);
BOOST_REQUIRE(pfd.revents == (POLLIN | POLLOUT));

Reply all
Reply to author
Forward
0 new messages