summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonny Chevalier <chevalier.ronny@gmail.com>2015-01-22 22:53:42 +0100
committerRonny Chevalier <chevalier.ronny@gmail.com>2015-01-22 23:10:56 +0100
commit0c0cdb06c139b52ff103287f6909b3daa5b2dc54 (patch)
treef904cb032c43691d325b6bb19941a2c115a07416
parent714af6af8a912650f9129f8b056ed92589443060 (diff)
tests: use assert_se instead of assert
Otherwise they can be optimized away with -DNDEBUG
-rw-r--r--src/journal/test-compress-benchmark.c18
-rw-r--r--src/journal/test-compress.c4
-rw-r--r--src/journal/test-journal-flush.c7
-rw-r--r--src/journal/test-journal-interleaving.c34
-rw-r--r--src/journal/test-journal-stream.c3
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c7
-rw-r--r--src/libsystemd/sd-bus/test-bus-gvariant.c179
-rw-r--r--src/libsystemd/sd-bus/test-bus-match.c4
-rw-r--r--src/libsystemd/sd-event/test-event.c19
-rw-r--r--src/libsystemd/sd-resolve/test-resolve.c11
-rw-r--r--src/resolve/test-dns-domain.c3
-rw-r--r--src/test/test-sigbus.c2
-rw-r--r--src/test/test-util.c4
13 files changed, 148 insertions, 147 deletions
diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c
index b3bc3ec2fe..c8e5b76c6c 100644
--- a/src/journal/test-compress-benchmark.c
+++ b/src/journal/test-compress-benchmark.c
@@ -32,7 +32,7 @@ static char* make_buf(size_t count) {
size_t i;
buf = malloc(count);
- assert(buf);
+ assert_se(buf);
for (i = 0; i < count; i++)
buf[i] = 'a' + i % ('z' - 'a' + 1);
@@ -52,7 +52,7 @@ static void test_compress_decompress(const char* label,
text = make_buf(MAX_SIZE);
buf = calloc(MAX_SIZE + 1, 1);
- assert(text && buf);
+ assert_se(text && buf);
n = now(CLOCK_MONOTONIC);
@@ -62,24 +62,24 @@ static void test_compress_decompress(const char* label,
r = compress(text, i, buf, &j);
/* assume compression must be successful except for small inputs */
- assert(r == 0 || (i < 2048 && r == -ENOBUFS));
+ assert_se(r == 0 || (i < 2048 && r == -ENOBUFS));
/* check for overwrites */
- assert(buf[i] == 0);
+ assert_se(buf[i] == 0);
if (r != 0) {
skipped += i;
continue;
}
- assert(j > 0);
+ assert_se(j > 0);
if (j >= i)
log_error("%s \"compressed\" %zu -> %zu", label, i, j);
r = decompress(buf, j, &buf2, &buf2_allocated, &k, 0);
- assert(r == 0);
- assert(buf2_allocated >= k);
- assert(k == i);
+ assert_se(r == 0);
+ assert_se(buf2_allocated >= k);
+ assert_se(k == i);
- assert(memcmp(text, buf2, i) == 0);
+ assert_se(memcmp(text, buf2, i) == 0);
total += i;
compressed += j;
diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c
index 97577e827c..ae41c0c4c7 100644
--- a/src/journal/test-compress.c
+++ b/src/journal/test-compress.c
@@ -175,7 +175,7 @@ static void test_compress_stream(int compression,
assert_se(lseek(dst, 0, SEEK_SET) == 0);
r = decompress(dst, dst2, st.st_size);
- assert(r == 0);
+ assert_se(r == 0);
assert_se(asprintf(&cmd2, "diff %s %s", srcfile, pattern2) > 0);
assert_se(system(cmd2) == 0);
@@ -189,7 +189,7 @@ static void test_compress_stream(int compression,
assert_se(lseek(dst, 0, SEEK_SET) == 0);
assert_se(lseek(dst2, 0, SEEK_SET) == 0);
r = decompress(dst, dst2, st.st_size - 1);
- assert(r == -EFBIG);
+ assert_se(r == -EFBIG);
assert_se(unlink(pattern) == 0);
assert_se(unlink(pattern2) == 0);
diff --git a/src/journal/test-journal-flush.c b/src/journal/test-journal-flush.c
index 40ede4a926..914ca0b4d1 100644
--- a/src/journal/test-journal-flush.c
+++ b/src/journal/test-journal-flush.c
@@ -22,6 +22,7 @@
#include <fcntl.h>
#include "sd-journal.h"
+#include "macro.h"
#include "journal-file.h"
#include "journal-internal.h"
@@ -49,13 +50,13 @@ int main(int argc, char *argv[]) {
JournalFile *f;
f = j->current_file;
- assert(f && f->current_offset > 0);
+ assert_se(f && f->current_offset > 0);
r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
- assert(r >= 0);
+ assert_se(r >= 0);
r = journal_file_copy_entry(f, new_journal, o, f->current_offset, NULL, NULL, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
n++;
if (n > 10000)
diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c
index 23a26c43f6..3c706018e9 100644
--- a/src/journal/test-journal-interleaving.c
+++ b/src/journal/test-journal-interleaving.c
@@ -212,43 +212,43 @@ static void test_sequence_numbers(void) {
append_number(one, 1, &seqnum);
printf("seqnum=%"PRIu64"\n", seqnum);
- assert(seqnum == 1);
+ assert_se(seqnum == 1);
append_number(one, 2, &seqnum);
printf("seqnum=%"PRIu64"\n", seqnum);
- assert(seqnum == 2);
+ assert_se(seqnum == 2);
- assert(one->header->state == STATE_ONLINE);
- assert(!sd_id128_equal(one->header->file_id, one->header->machine_id));
- assert(!sd_id128_equal(one->header->file_id, one->header->boot_id));
- assert(sd_id128_equal(one->header->file_id, one->header->seqnum_id));
+ assert_se(one->header->state == STATE_ONLINE);
+ assert_se(!sd_id128_equal(one->header->file_id, one->header->machine_id));
+ assert_se(!sd_id128_equal(one->header->file_id, one->header->boot_id));
+ assert_se(sd_id128_equal(one->header->file_id, one->header->seqnum_id));
memcpy(&seqnum_id, &one->header->seqnum_id, sizeof(sd_id128_t));
assert_se(journal_file_open("two.journal", O_RDWR|O_CREAT, 0644,
true, false, NULL, NULL, one, &two) == 0);
- assert(two->header->state == STATE_ONLINE);
- assert(!sd_id128_equal(two->header->file_id, one->header->file_id));
- assert(sd_id128_equal(one->header->machine_id, one->header->machine_id));
- assert(sd_id128_equal(one->header->boot_id, one->header->boot_id));
- assert(sd_id128_equal(one->header->seqnum_id, one->header->seqnum_id));
+ assert_se(two->header->state == STATE_ONLINE);
+ assert_se(!sd_id128_equal(two->header->file_id, one->header->file_id));
+ assert_se(sd_id128_equal(one->header->machine_id, one->header->machine_id));
+ assert_se(sd_id128_equal(one->header->boot_id, one->header->boot_id));
+ assert_se(sd_id128_equal(one->header->seqnum_id, one->header->seqnum_id));
append_number(two, 3, &seqnum);
printf("seqnum=%"PRIu64"\n", seqnum);
- assert(seqnum == 3);
+ assert_se(seqnum == 3);
append_number(two, 4, &seqnum);
printf("seqnum=%"PRIu64"\n", seqnum);
- assert(seqnum == 4);
+ assert_se(seqnum == 4);
test_close(two);
append_number(one, 5, &seqnum);
printf("seqnum=%"PRIu64"\n", seqnum);
- assert(seqnum == 5);
+ assert_se(seqnum == 5);
append_number(one, 6, &seqnum);
printf("seqnum=%"PRIu64"\n", seqnum);
- assert(seqnum == 6);
+ assert_se(seqnum == 6);
test_close(one);
@@ -258,11 +258,11 @@ static void test_sequence_numbers(void) {
assert_se(journal_file_open("two.journal", O_RDWR, 0,
true, false, NULL, NULL, NULL, &two) == 0);
- assert(sd_id128_equal(two->header->seqnum_id, seqnum_id));
+ assert_se(sd_id128_equal(two->header->seqnum_id, seqnum_id));
append_number(two, 7, &seqnum);
printf("seqnum=%"PRIu64"\n", seqnum);
- assert(seqnum == 5);
+ assert_se(seqnum == 5);
/* So..., here we have the same seqnum in two files with the
* same seqnum_id. */
diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c
index 8ccd813445..3996e778e6 100644
--- a/src/journal/test-journal-stream.c
+++ b/src/journal/test-journal-stream.c
@@ -28,13 +28,14 @@
#include "journal-internal.h"
#include "util.h"
#include "log.h"
+#include "macro.h"
#define N_ENTRIES 200
static void verify_contents(sd_journal *j, unsigned skip) {
unsigned i;
- assert(j);
+ assert_se(j);
i = 0;
SD_JOURNAL_FOREACH(j) {
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index 06edd621e4..8625ee6d89 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -19,7 +19,6 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <assert.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
@@ -44,7 +43,7 @@ static int match_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
static int object_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
int r;
- assert(bus);
+ assert_se(bus);
if (sd_bus_message_is_method_error(m, NULL))
return 0;
@@ -68,7 +67,7 @@ static int server_init(sd_bus **_bus) {
int r;
const char *unique;
- assert(_bus);
+ assert_se(_bus);
r = sd_bus_open_user(&bus);
if (r < 0) {
@@ -299,7 +298,7 @@ static void* client1(void*p) {
goto finish;
}
- assert(streq(hello, "hello"));
+ assert_se(streq(hello, "hello"));
if (pipe2(pp, O_CLOEXEC|O_NONBLOCK) < 0) {
log_error_errno(errno, "Failed to allocate pipe: %m");
diff --git a/src/libsystemd/sd-bus/test-bus-gvariant.c b/src/libsystemd/sd-bus/test-bus-gvariant.c
index d700a35b0c..6992ec44de 100644
--- a/src/libsystemd/sd-bus/test-bus-gvariant.c
+++ b/src/libsystemd/sd-bus/test-bus-gvariant.c
@@ -24,6 +24,7 @@
#endif
#include "util.h"
+#include "macro.h"
#include "sd-bus.h"
#include "bus-gvariant.h"
#include "bus-util.h"
@@ -32,101 +33,101 @@
#include "bus-dump.h"
static void test_bus_gvariant_is_fixed_size(void) {
- assert(bus_gvariant_is_fixed_size("") > 0);
- assert(bus_gvariant_is_fixed_size("()") > 0);
- assert(bus_gvariant_is_fixed_size("y") > 0);
- assert(bus_gvariant_is_fixed_size("u") > 0);
- assert(bus_gvariant_is_fixed_size("b") > 0);
- assert(bus_gvariant_is_fixed_size("n") > 0);
- assert(bus_gvariant_is_fixed_size("q") > 0);
- assert(bus_gvariant_is_fixed_size("i") > 0);
- assert(bus_gvariant_is_fixed_size("t") > 0);
- assert(bus_gvariant_is_fixed_size("d") > 0);
- assert(bus_gvariant_is_fixed_size("s") == 0);
- assert(bus_gvariant_is_fixed_size("o") == 0);
- assert(bus_gvariant_is_fixed_size("g") == 0);
- assert(bus_gvariant_is_fixed_size("h") > 0);
- assert(bus_gvariant_is_fixed_size("ay") == 0);
- assert(bus_gvariant_is_fixed_size("v") == 0);
- assert(bus_gvariant_is_fixed_size("(u)") > 0);
- assert(bus_gvariant_is_fixed_size("(uuuuy)") > 0);
- assert(bus_gvariant_is_fixed_size("(uusuuy)") == 0);
- assert(bus_gvariant_is_fixed_size("a{ss}") == 0);
- assert(bus_gvariant_is_fixed_size("((u)yyy(b(iiii)))") > 0);
- assert(bus_gvariant_is_fixed_size("((u)yyy(b(iiivi)))") == 0);
+ assert_se(bus_gvariant_is_fixed_size("") > 0);
+ assert_se(bus_gvariant_is_fixed_size("()") > 0);
+ assert_se(bus_gvariant_is_fixed_size("y") > 0);
+ assert_se(bus_gvariant_is_fixed_size("u") > 0);
+ assert_se(bus_gvariant_is_fixed_size("b") > 0);
+ assert_se(bus_gvariant_is_fixed_size("n") > 0);
+ assert_se(bus_gvariant_is_fixed_size("q") > 0);
+ assert_se(bus_gvariant_is_fixed_size("i") > 0);
+ assert_se(bus_gvariant_is_fixed_size("t") > 0);
+ assert_se(bus_gvariant_is_fixed_size("d") > 0);
+ assert_se(bus_gvariant_is_fixed_size("s") == 0);
+ assert_se(bus_gvariant_is_fixed_size("o") == 0);
+ assert_se(bus_gvariant_is_fixed_size("g") == 0);
+ assert_se(bus_gvariant_is_fixed_size("h") > 0);
+ assert_se(bus_gvariant_is_fixed_size("ay") == 0);
+ assert_se(bus_gvariant_is_fixed_size("v") == 0);
+ assert_se(bus_gvariant_is_fixed_size("(u)") > 0);
+ assert_se(bus_gvariant_is_fixed_size("(uuuuy)") > 0);
+ assert_se(bus_gvariant_is_fixed_size("(uusuuy)") == 0);
+ assert_se(bus_gvariant_is_fixed_size("a{ss}") == 0);
+ assert_se(bus_gvariant_is_fixed_size("((u)yyy(b(iiii)))") > 0);
+ assert_se(bus_gvariant_is_fixed_size("((u)yyy(b(iiivi)))") == 0);
}
static void test_bus_gvariant_get_size(void) {
- assert(bus_gvariant_get_size("") == 0);
- assert(bus_gvariant_get_size("()") == 0);
- assert(bus_gvariant_get_size("y") == 1);
- assert(bus_gvariant_get_size("u") == 4);
- assert(bus_gvariant_get_size("b") == 1);
- assert(bus_gvariant_get_size("n") == 2);
- assert(bus_gvariant_get_size("q") == 2);
- assert(bus_gvariant_get_size("i") == 4);
- assert(bus_gvariant_get_size("t") == 8);
- assert(bus_gvariant_get_size("d") == 8);
- assert(bus_gvariant_get_size("s") < 0);
- assert(bus_gvariant_get_size("o") < 0);
- assert(bus_gvariant_get_size("g") < 0);
- assert(bus_gvariant_get_size("h") == 4);
- assert(bus_gvariant_get_size("ay") < 0);
- assert(bus_gvariant_get_size("v") < 0);
- assert(bus_gvariant_get_size("(u)") == 4);
- assert(bus_gvariant_get_size("(uuuuy)") == 20);
- assert(bus_gvariant_get_size("(uusuuy)") < 0);
- assert(bus_gvariant_get_size("a{ss}") < 0);
- assert(bus_gvariant_get_size("((u)yyy(b(iiii)))") == 28);
- assert(bus_gvariant_get_size("((u)yyy(b(iiivi)))") < 0);
- assert(bus_gvariant_get_size("((b)(t))") == 16);
- assert(bus_gvariant_get_size("((b)(b)(t))") == 16);
- assert(bus_gvariant_get_size("(bt)") == 16);
- assert(bus_gvariant_get_size("((t)(b))") == 16);
- assert(bus_gvariant_get_size("(tb)") == 16);
- assert(bus_gvariant_get_size("((b)(b))") == 2);
- assert(bus_gvariant_get_size("((t)(t))") == 16);
+ assert_se(bus_gvariant_get_size("") == 0);
+ assert_se(bus_gvariant_get_size("()") == 0);
+ assert_se(bus_gvariant_get_size("y") == 1);
+ assert_se(bus_gvariant_get_size("u") == 4);
+ assert_se(bus_gvariant_get_size("b") == 1);
+ assert_se(bus_gvariant_get_size("n") == 2);
+ assert_se(bus_gvariant_get_size("q") == 2);
+ assert_se(bus_gvariant_get_size("i") == 4);
+ assert_se(bus_gvariant_get_size("t") == 8);
+ assert_se(bus_gvariant_get_size("d") == 8);
+ assert_se(bus_gvariant_get_size("s") < 0);
+ assert_se(bus_gvariant_get_size("o") < 0);
+ assert_se(bus_gvariant_get_size("g") < 0);
+ assert_se(bus_gvariant_get_size("h") == 4);
+ assert_se(bus_gvariant_get_size("ay") < 0);
+ assert_se(bus_gvariant_get_size("v") < 0);
+ assert_se(bus_gvariant_get_size("(u)") == 4);
+ assert_se(bus_gvariant_get_size("(uuuuy)") == 20);
+ assert_se(bus_gvariant_get_size("(uusuuy)") < 0);
+ assert_se(bus_gvariant_get_size("a{ss}") < 0);
+ assert_se(bus_gvariant_get_size("((u)yyy(b(iiii)))") == 28);
+ assert_se(bus_gvariant_get_size("((u)yyy(b(iiivi)))") < 0);
+ assert_se(bus_gvariant_get_size("((b)(t))") == 16);
+ assert_se(bus_gvariant_get_size("((b)(b)(t))") == 16);
+ assert_se(bus_gvariant_get_size("(bt)") == 16);
+ assert_se(bus_gvariant_get_size("((t)(b))") == 16);
+ assert_se(bus_gvariant_get_size("(tb)") == 16);
+ assert_se(bus_gvariant_get_size("((b)(b))") == 2);
+ assert_se(bus_gvariant_get_size("((t)(t))") == 16);
}
static void test_bus_gvariant_get_alignment(void) {
- assert(bus_gvariant_get_alignment("") == 1);
- assert(bus_gvariant_get_alignment("()") == 1);
- assert(bus_gvariant_get_alignment("y") == 1);
- assert(bus_gvariant_get_alignment("b") == 1);
- assert(bus_gvariant_get_alignment("u") == 4);
- assert(bus_gvariant_get_alignment("s") == 1);
- assert(bus_gvariant_get_alignment("o") == 1);
- assert(bus_gvariant_get_alignment("g") == 1);
- assert(bus_gvariant_get_alignment("v") == 8);
- assert(bus_gvariant_get_alignment("h") == 4);
- assert(bus_gvariant_get_alignment("i") == 4);
- assert(bus_gvariant_get_alignment("t") == 8);
- assert(bus_gvariant_get_alignment("x") == 8);
- assert(bus_gvariant_get_alignment("q") == 2);
- assert(bus_gvariant_get_alignment("n") == 2);
- assert(bus_gvariant_get_alignment("d") == 8);
- assert(bus_gvariant_get_alignment("ay") == 1);
- assert(bus_gvariant_get_alignment("as") == 1);
- assert(bus_gvariant_get_alignment("au") == 4);
- assert(bus_gvariant_get_alignment("an") == 2);
- assert(bus_gvariant_get_alignment("ans") == 2);
- assert(bus_gvariant_get_alignment("ant") == 8);
- assert(bus_gvariant_get_alignment("(ss)") == 1);
- assert(bus_gvariant_get_alignment("(ssu)") == 4);
- assert(bus_gvariant_get_alignment("a(ssu)") == 4);
- assert(bus_gvariant_get_alignment("(u)") == 4);
- assert(bus_gvariant_get_alignment("(uuuuy)") == 4);
- assert(bus_gvariant_get_alignment("(uusuuy)") == 4);
- assert(bus_gvariant_get_alignment("a{ss}") == 1);
- assert(bus_gvariant_get_alignment("((u)yyy(b(iiii)))") == 4);
- assert(bus_gvariant_get_alignment("((u)yyy(b(iiivi)))") == 8);
- assert(bus_gvariant_get_alignment("((b)(t))") == 8);
- assert(bus_gvariant_get_alignment("((b)(b)(t))") == 8);
- assert(bus_gvariant_get_alignment("(bt)") == 8);
- assert(bus_gvariant_get_alignment("((t)(b))") == 8);
- assert(bus_gvariant_get_alignment("(tb)") == 8);
- assert(bus_gvariant_get_alignment("((b)(b))") == 1);
- assert(bus_gvariant_get_alignment("((t)(t))") == 8);
+ assert_se(bus_gvariant_get_alignment("") == 1);
+ assert_se(bus_gvariant_get_alignment("()") == 1);
+ assert_se(bus_gvariant_get_alignment("y") == 1);
+ assert_se(bus_gvariant_get_alignment("b") == 1);
+ assert_se(bus_gvariant_get_alignment("u") == 4);
+ assert_se(bus_gvariant_get_alignment("s") == 1);
+ assert_se(bus_gvariant_get_alignment("o") == 1);
+ assert_se(bus_gvariant_get_alignment("g") == 1);
+ assert_se(bus_gvariant_get_alignment("v") == 8);
+ assert_se(bus_gvariant_get_alignment("h") == 4);
+ assert_se(bus_gvariant_get_alignment("i") == 4);
+ assert_se(bus_gvariant_get_alignment("t") == 8);
+ assert_se(bus_gvariant_get_alignment("x") == 8);
+ assert_se(bus_gvariant_get_alignment("q") == 2);
+ assert_se(bus_gvariant_get_alignment("n") == 2);
+ assert_se(bus_gvariant_get_alignment("d") == 8);
+ assert_se(bus_gvariant_get_alignment("ay") == 1);
+ assert_se(bus_gvariant_get_alignment("as") == 1);
+ assert_se(bus_gvariant_get_alignment("au") == 4);
+ assert_se(bus_gvariant_get_alignment("an") == 2);
+ assert_se(bus_gvariant_get_alignment("ans") == 2);
+ assert_se(bus_gvariant_get_alignment("ant") == 8);
+ assert_se(bus_gvariant_get_alignment("(ss)") == 1);
+ assert_se(bus_gvariant_get_alignment("(ssu)") == 4);
+ assert_se(bus_gvariant_get_alignment("a(ssu)") == 4);
+ assert_se(bus_gvariant_get_alignment("(u)") == 4);
+ assert_se(bus_gvariant_get_alignment("(uuuuy)") == 4);
+ assert_se(bus_gvariant_get_alignment("(uusuuy)") == 4);
+ assert_se(bus_gvariant_get_alignment("a{ss}") == 1);
+ assert_se(bus_gvariant_get_alignment("((u)yyy(b(iiii)))") == 4);
+ assert_se(bus_gvariant_get_alignment("((u)yyy(b(iiivi)))") == 8);
+ assert_se(bus_gvariant_get_alignment("((b)(t))") == 8);
+ assert_se(bus_gvariant_get_alignment("((b)(b)(t))") == 8);
+ assert_se(bus_gvariant_get_alignment("(bt)") == 8);
+ assert_se(bus_gvariant_get_alignment("((t)(b))") == 8);
+ assert_se(bus_gvariant_get_alignment("(tb)") == 8);
+ assert_se(bus_gvariant_get_alignment("((b)(b))") == 1);
+ assert_se(bus_gvariant_get_alignment("((t)(t))") == 8);
}
static void test_marshal(void) {
diff --git a/src/libsystemd/sd-bus/test-bus-match.c b/src/libsystemd/sd-bus/test-bus-match.c
index 7133117038..76ca0b6bf3 100644
--- a/src/libsystemd/sd-bus/test-bus-match.c
+++ b/src/libsystemd/sd-bus/test-bus-match.c
@@ -19,8 +19,6 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <assert.h>
-
#include "log.h"
#include "util.h"
#include "macro.h"
@@ -34,7 +32,7 @@ static bool mask[32];
static int filter(sd_bus *b, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
log_info("Ran %u", PTR_TO_UINT(userdata));
- assert(PTR_TO_UINT(userdata) < ELEMENTSOF(mask));
+ assert_se(PTR_TO_UINT(userdata) < ELEMENTSOF(mask));
mask[PTR_TO_UINT(userdata)] = true;
return 0;
}
diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c
index ffefb14b74..721700be7b 100644
--- a/src/libsystemd/sd-event/test-event.c
+++ b/src/libsystemd/sd-event/test-event.c
@@ -22,6 +22,7 @@
#include "sd-event.h"
#include "log.h"
#include "util.h"
+#include "macro.h"
static int prepare_handler(sd_event_source *s, void *userdata) {
log_info("preparing %c", PTR_TO_INT(userdata));
@@ -62,12 +63,12 @@ static int io_handler(sd_event_source *s, int fd, uint32_t revents, void *userda
static int child_handler(sd_event_source *s, const siginfo_t *si, void *userdata) {
- assert(s);
- assert(si);
+ assert_se(s);
+ assert_se(si);
log_info("got child on %c", PTR_TO_INT(userdata));
- assert(userdata == INT_TO_PTR('f'));
+ assert_se(userdata == INT_TO_PTR('f'));
assert_se(sd_event_exit(sd_event_source_get_event(s), 0) >= 0);
sd_event_source_unref(s);
@@ -80,12 +81,12 @@ static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si,
sigset_t ss;
pid_t pid;
- assert(s);
- assert(si);
+ assert_se(s);
+ assert_se(si);
log_info("got signal on %c", PTR_TO_INT(userdata));
- assert(userdata == INT_TO_PTR('e'));
+ assert_se(userdata == INT_TO_PTR('e'));
assert_se(sigemptyset(&ss) >= 0);
assert_se(sigaddset(&ss, SIGCHLD) >= 0);
@@ -109,11 +110,11 @@ static int defer_handler(sd_event_source *s, void *userdata) {
sd_event_source *p = NULL;
sigset_t ss;
- assert(s);
+ assert_se(s);
log_info("got defer on %c", PTR_TO_INT(userdata));
- assert(userdata == INT_TO_PTR('d'));
+ assert_se(userdata == INT_TO_PTR('d'));
assert_se(sigemptyset(&ss) >= 0);
assert_se(sigaddset(&ss, SIGUSR1) >= 0);
@@ -140,7 +141,7 @@ static int time_handler(sd_event_source *s, uint64_t usec, void *userdata) {
assert_se(sd_event_add_defer(sd_event_source_get_event(s), &p, defer_handler, INT_TO_PTR('d')) >= 0);
assert_se(sd_event_source_set_enabled(p, SD_EVENT_ONESHOT) >= 0);
} else {
- assert(!got_c);
+ assert_se(!got_c);
got_c = true;
}
} else
diff --git a/src/libsystemd/sd-resolve/test-resolve.c b/src/libsystemd/sd-resolve/test-resolve.c
index a9dc9313a6..d08e1b5a05 100644
--- a/src/libsystemd/sd-resolve/test-resolve.c
+++ b/src/libsystemd/sd-resolve/test-resolve.c
@@ -28,7 +28,6 @@
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
-#include <assert.h>
#include <signal.h>
#include <errno.h>
@@ -40,7 +39,7 @@
static int getaddrinfo_handler(sd_resolve_query *q, int ret, const struct addrinfo *ai, void *userdata) {
const struct addrinfo *i;
- assert(q);
+ assert_se(q);
if (ret != 0) {
log_error("getaddrinfo error: %s %i", gai_strerror(ret), ret);
@@ -60,7 +59,7 @@ static int getaddrinfo_handler(sd_resolve_query *q, int ret, const struct addrin
}
static int getnameinfo_handler(sd_resolve_query *q, int ret, const char *host, const char *serv, void *userdata) {
- assert(q);
+ assert_se(q);
if (ret != 0) {
log_error("getnameinfo error: %s %i", gai_strerror(ret), ret);
@@ -77,7 +76,7 @@ static int res_handler(sd_resolve_query *q, int ret, unsigned char *answer, void
unsigned char *end = answer + ret;
HEADER *head = (HEADER *) answer;
char name[256];
- assert(q);
+ assert_se(q);
if (ret < 0) {
log_error("res_query() error: %s %i", strerror(errno), errno);
@@ -96,7 +95,7 @@ static int res_handler(sd_resolve_query *q, int ret, unsigned char *answer, void
/* Ignore the questions */
while (qdcount-- > 0 && (len = dn_expand(answer, end, pos, name, 255)) >= 0) {
- assert(len >= 0);
+ assert_se(len >= 0);
pos += len + QFIXEDSZ;
}
@@ -104,7 +103,7 @@ static int res_handler(sd_resolve_query *q, int ret, unsigned char *answer, void
while (ancount-- > 0 && (len = dn_expand(answer, end, pos, name, 255)) >= 0) {
/* Ignore the initial string */
uint16_t pref, weight, port;
- assert(len >= 0);
+ assert_se(len >= 0);
pos += len;
/* Ignore type, ttl, class and dlen */
pos += 10;
diff --git a/src/resolve/test-dns-domain.c b/src/resolve/test-dns-domain.c
index dfe2a44eae..ebc8d98fce 100644
--- a/src/resolve/test-dns-domain.c
+++ b/src/resolve/test-dns-domain.c
@@ -20,6 +20,7 @@
***/
#include "log.h"
+#include "macro.h"
#include "resolved-dns-domain.h"
static void test_dns_label_unescape_one(const char *what, const char *expect, size_t buffer_sz, int ret) {
@@ -55,7 +56,7 @@ static void test_dns_label_escape_one(const char *what, size_t l, const char *ex
int r;
r = dns_label_escape(what, l, &t);
- assert(r == ret);
+ assert_se(r == ret);
if (r < 0)
return;
diff --git a/src/test/test-sigbus.c b/src/test/test-sigbus.c
index 39d0fec894..f5bae65bef 100644
--- a/src/test/test-sigbus.c
+++ b/src/test/test-sigbus.c
@@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
sigbus_install();
- assert(sigbus_pop(&addr) == 0);
+ assert_se(sigbus_pop(&addr) == 0);
assert_se((fd = mkostemp(template, O_RDWR|O_CREAT|O_EXCL)) >= 0);
assert_se(unlink(template) >= 0);
diff --git a/src/test/test-util.c b/src/test/test-util.c
index a37316b9cb..f2b7038a4d 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -1254,11 +1254,11 @@ static void test_execute_directory(void) {
execute_directories(dirs, DEFAULT_TIMEOUT_USEC, NULL);
- assert(chdir(template_lo) == 0);
+ assert_se(chdir(template_lo) == 0);
assert_se(access("it_works", F_OK) >= 0);
assert_se(access("failed", F_OK) < 0);
- assert(chdir(template_hi) == 0);
+ assert_se(chdir(template_hi) == 0);
assert_se(access("it_works2", F_OK) >= 0);
assert_se(access("failed", F_OK) < 0);