summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/journal/test-catalog.c16
-rw-r--r--src/journal/test-compress.c18
-rw-r--r--src/journal/test-journal-syslog.c6
-rw-r--r--src/journal/test-journal-verify.c6
-rw-r--r--src/journal/test-journal.c66
-rw-r--r--src/journal/test-mmap-cache.c22
-rw-r--r--src/libsystemd-network/test-icmp6-rs.c36
-rw-r--r--src/login/test-inhibit.c18
8 files changed, 94 insertions, 94 deletions
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
index 5fe2f6a269..c605ee0e70 100644
--- a/src/journal/test-catalog.c
+++ b/src/journal/test-catalog.c
@@ -49,11 +49,11 @@ static void test_import(Hashmap *h, struct strbuf *sb,
_cleanup_close_ int fd;
fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
- assert(fd >= 0);
+ assert_se(fd >= 0);
assert_se(write(fd, contents, size) == size);
r = catalog_import_file(h, sb, name);
- assert(r == code);
+ assert_se(r == code);
unlink(name);
}
@@ -68,7 +68,7 @@ static void test_catalog_importing(void) {
#define BUF "xxx"
test_import(h, sb, BUF, sizeof(BUF), -EINVAL);
#undef BUF
- assert(hashmap_isempty(h));
+ assert_se(hashmap_isempty(h));
log_debug("----------------------------------------");
#define BUF \
@@ -89,7 +89,7 @@ static void test_catalog_importing(void) {
test_import(h, sb, BUF, sizeof(BUF), 0);
#undef BUF
- assert(hashmap_size(h) == 1);
+ assert_se(hashmap_size(h) == 1);
log_debug("----------------------------------------");
@@ -105,22 +105,22 @@ static void test_catalog_update(void) {
int r;
r = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
- assert(r >= 0);
+ assert_se(r >= 0);
database = name;
/* Test what happens if there are no files. */
r = catalog_update(database, NULL, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
/* Test what happens if there are no files in the directory. */
r = catalog_update(database, NULL, no_catalog_dirs);
- assert(r >= 0);
+ assert_se(r >= 0);
/* Make sure that we at least have some files loaded or the
catalog_list below will fail. */
r = catalog_update(database, NULL, catalog_dirs);
- assert(r >= 0);
+ assert_se(r >= 0);
}
static void test_catalog_file_lang(void) {
diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c
index dbf09d97c3..97577e827c 100644
--- a/src/journal/test-compress.c
+++ b/src/journal/test-compress.c
@@ -64,28 +64,28 @@ static void test_compress_decompress(int compression,
r = compress(data, data_len, compressed, &csize);
if (r == -ENOBUFS) {
log_info_errno(r, "compression failed: %m");
- assert(may_fail);
+ assert_se(may_fail);
} else {
- assert(r == 0);
+ assert_se(r == 0);
r = decompress(compressed, csize,
(void **) &decompressed, &usize, &csize, 0);
- assert(r == 0);
+ assert_se(r == 0);
assert_se(decompressed);
assert_se(memcmp(decompressed, data, data_len) == 0);
}
r = decompress("garbage", 7,
(void **) &decompressed, &usize, &csize, 0);
- assert(r < 0);
+ assert_se(r < 0);
/* make sure to have the minimal lz4 compressed size */
r = decompress("00000000\1g", 9,
(void **) &decompressed, &usize, &csize, 0);
- assert(r < 0);
+ assert_se(r < 0);
r = decompress("\100000000g", 9,
(void **) &decompressed, &usize, &csize, 0);
- assert(r < 0);
+ assert_se(r < 0);
memzero(decompressed, usize);
}
@@ -109,10 +109,10 @@ static void test_decompress_startswith(int compression,
r = compress(data, data_len, compressed, &csize);
if (r == -ENOBUFS) {
log_info_errno(r, "compression failed: %m");
- assert(may_fail);
+ assert_se(may_fail);
return;
}
- assert(r == 0);
+ assert_se(r == 0);
assert_se(decompress_sw(compressed,
csize,
@@ -184,7 +184,7 @@ static void test_compress_stream(int compression,
assert_se(lseek(dst, 1, SEEK_SET) == 1);
r = decompress(dst, dst2, st.st_size);
- assert(r == -EBADMSG);
+ assert_se(r == -EBADMSG);
assert_se(lseek(dst, 0, SEEK_SET) == 0);
assert_se(lseek(dst2, 0, SEEK_SET) == 0);
diff --git a/src/journal/test-journal-syslog.c b/src/journal/test-journal-syslog.c
index c4d407148c..c99ca0654b 100644
--- a/src/journal/test-journal-syslog.c
+++ b/src/journal/test-journal-syslog.c
@@ -30,9 +30,9 @@ static void test_syslog_parse_identifier(const char* str,
ret2 = syslog_parse_identifier(&buf, &ident2, &pid2);
- assert(ret == ret2);
- assert(ident == ident2 || streq_ptr(ident, ident2));
- assert(pid == pid2 || streq_ptr(pid, pid2));
+ assert_se(ret == ret2);
+ assert_se(ident == ident2 || streq_ptr(ident, ident2));
+ assert_se(pid == pid2 || streq_ptr(pid, pid2));
}
int main(void) {
diff --git a/src/journal/test-journal-verify.c b/src/journal/test-journal-verify.c
index 3b181c6794..9da120c0bb 100644
--- a/src/journal/test-journal-verify.c
+++ b/src/journal/test-journal-verify.c
@@ -38,15 +38,15 @@ static void bit_toggle(const char *fn, uint64_t p) {
int fd;
fd = open(fn, O_RDWR|O_CLOEXEC);
- assert(fd >= 0);
+ assert_se(fd >= 0);
r = pread(fd, &b, 1, p/8);
- assert(r == 1);
+ assert_se(r == 1);
b ^= 1 << (p % 8);
r = pwrite(fd, &b, 1, p/8);
- assert(r == 1);
+ assert_se(r == 1);
safe_close(fd);
}
diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c
index 74168b9b83..ff9dc9e170 100644
--- a/src/journal/test-journal.c
+++ b/src/journal/test-journal.c
@@ -66,55 +66,55 @@ static void test_non_empty(void) {
#endif
journal_file_dump(f);
- assert(journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 2);
+ assert_se(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 2);
- assert(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 3);
+ assert_se(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 3);
- assert(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 0);
+ assert_se(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 0);
- assert(journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_skip_entry(f, o, p, 2, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 3);
+ assert_se(journal_file_skip_entry(f, o, p, 2, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 3);
- assert(journal_file_skip_entry(f, o, p, -2, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_skip_entry(f, o, p, -2, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_skip_entry(f, o, p, -2, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_skip_entry(f, o, p, -2, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_find_data_object(f, test, strlen(test), NULL, &p) == 1);
- assert(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_DOWN, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_find_data_object(f, test, strlen(test), NULL, &p) == 1);
+ assert_se(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_DOWN, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_UP, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 3);
+ assert_se(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_UP, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 3);
- assert(journal_file_find_data_object(f, test2, strlen(test2), NULL, &p) == 1);
- assert(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_UP, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 2);
+ assert_se(journal_file_find_data_object(f, test2, strlen(test2), NULL, &p) == 1);
+ assert_se(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_UP, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 2);
- assert(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_DOWN, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 2);
+ assert_se(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_DOWN, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 2);
- assert(journal_file_find_data_object(f, "quux", 4, NULL, &p) == 0);
+ assert_se(journal_file_find_data_object(f, "quux", 4, NULL, &p) == 0);
- assert(journal_file_move_to_entry_by_seqnum(f, 1, DIRECTION_DOWN, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_move_to_entry_by_seqnum(f, 1, DIRECTION_DOWN, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_move_to_entry_by_seqnum(f, 3, DIRECTION_DOWN, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 3);
+ assert_se(journal_file_move_to_entry_by_seqnum(f, 3, DIRECTION_DOWN, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 3);
- assert(journal_file_move_to_entry_by_seqnum(f, 2, DIRECTION_DOWN, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 2);
+ assert_se(journal_file_move_to_entry_by_seqnum(f, 2, DIRECTION_DOWN, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 2);
- assert(journal_file_move_to_entry_by_seqnum(f, 10, DIRECTION_DOWN, &o, NULL) == 0);
+ assert_se(journal_file_move_to_entry_by_seqnum(f, 10, DIRECTION_DOWN, &o, NULL) == 0);
journal_file_rotate(&f, true, true);
journal_file_rotate(&f, true, true);
diff --git a/src/journal/test-mmap-cache.c b/src/journal/test-mmap-cache.c
index 778e884c3f..1227b62310 100644
--- a/src/journal/test-mmap-cache.c
+++ b/src/journal/test-mmap-cache.c
@@ -38,37 +38,37 @@ int main(int argc, char *argv[]) {
assert_se(m = mmap_cache_new());
x = mkostemp_safe(px, O_RDWR|O_CLOEXEC);
- assert(x >= 0);
+ assert_se(x >= 0);
unlink(px);
y = mkostemp_safe(py, O_RDWR|O_CLOEXEC);
- assert(y >= 0);
+ assert_se(y >= 0);
unlink(py);
z = mkostemp_safe(pz, O_RDWR|O_CLOEXEC);
- assert(z >= 0);
+ assert_se(z >= 0);
unlink(pz);
r = mmap_cache_get(m, x, PROT_READ, 0, false, 1, 2, NULL, &p, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
r = mmap_cache_get(m, x, PROT_READ, 0, false, 2, 2, NULL, &q, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
- assert((uint8_t*) p + 1 == (uint8_t*) q);
+ assert_se((uint8_t*) p + 1 == (uint8_t*) q);
r = mmap_cache_get(m, x, PROT_READ, 1, false, 3, 2, NULL, &q, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
- assert((uint8_t*) p + 2 == (uint8_t*) q);
+ assert_se((uint8_t*) p + 2 == (uint8_t*) q);
r = mmap_cache_get(m, x, PROT_READ, 0, false, 16ULL*1024ULL*1024ULL, 2, NULL, &p, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
r = mmap_cache_get(m, x, PROT_READ, 1, false, 16ULL*1024ULL*1024ULL+1, 2, NULL, &q, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
- assert((uint8_t*) p + 1 == (uint8_t*) q);
+ assert_se((uint8_t*) p + 1 == (uint8_t*) q);
mmap_cache_unref(m);
diff --git a/src/libsystemd-network/test-icmp6-rs.c b/src/libsystemd-network/test-icmp6-rs.c
index afa8562659..be64d334fa 100644
--- a/src/libsystemd-network/test-icmp6-rs.c
+++ b/src/libsystemd-network/test-icmp6-rs.c
@@ -36,13 +36,13 @@ static int test_fd[2];
static int test_rs_hangcheck(sd_event_source *s, uint64_t usec,
void *userdata) {
- assert(false);
+ assert_se(false);
return 0;
}
int dhcp_network_icmp6_bind_router_solicitation(int index) {
- assert(index == 42);
+ assert_se(index == 42);
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, test_fd) < 0)
return -errno;
@@ -69,7 +69,7 @@ static int send_ra(uint8_t flags) {
advertisement[5] = flags;
- assert(write(test_fd[1], advertisement, sizeof(advertisement)) ==
+ assert_se(write(test_fd[1], advertisement, sizeof(advertisement)) ==
sizeof(advertisement));
if (verbose)
@@ -93,9 +93,9 @@ static void test_rs_done(sd_icmp6_nd *nd, int event, void *userdata) {
{ ND_RA_FLAG_OTHER, ICMP6_EVENT_ROUTER_ADVERTISMENT_OTHER },
{ ND_RA_FLAG_MANAGED, ICMP6_EVENT_ROUTER_ADVERTISMENT_MANAGED }
};
- assert(nd);
+ assert_se(nd);
- assert(event == flag_event[idx].event);
+ assert_se(event == flag_event[idx].event);
idx++;
if (verbose)
@@ -114,31 +114,31 @@ static void test_rs(sd_event *e) {
if (verbose)
printf("* %s\n", __FUNCTION__);
- assert(sd_icmp6_nd_new(&nd) >= 0);
- assert(nd);
+ assert_se(sd_icmp6_nd_new(&nd) >= 0);
+ assert_se(nd);
- assert(sd_icmp6_nd_attach_event(nd, e, 0) >= 0);
+ assert_se(sd_icmp6_nd_attach_event(nd, e, 0) >= 0);
- assert(sd_icmp6_nd_set_index(nd, 42) >= 0);
- assert(sd_icmp6_nd_set_mac(nd, &mac_addr) >= 0);
- assert(sd_icmp6_nd_set_callback(nd, test_rs_done, e) >= 0);
+ assert_se(sd_icmp6_nd_set_index(nd, 42) >= 0);
+ assert_se(sd_icmp6_nd_set_mac(nd, &mac_addr) >= 0);
+ assert_se(sd_icmp6_nd_set_callback(nd, test_rs_done, e) >= 0);
- assert(sd_event_add_time(e, &test_hangcheck, clock_boottime_or_monotonic(),
+ assert_se(sd_event_add_time(e, &test_hangcheck, clock_boottime_or_monotonic(),
time_now + 2 *USEC_PER_SEC, 0,
test_rs_hangcheck, NULL) >= 0);
- assert(sd_icmp6_nd_stop(nd) >= 0);
- assert(sd_icmp6_router_solicitation_start(nd) >= 0);
- assert(sd_icmp6_nd_stop(nd) >= 0);
+ assert_se(sd_icmp6_nd_stop(nd) >= 0);
+ assert_se(sd_icmp6_router_solicitation_start(nd) >= 0);
+ assert_se(sd_icmp6_nd_stop(nd) >= 0);
- assert(sd_icmp6_router_solicitation_start(nd) >= 0);
+ assert_se(sd_icmp6_router_solicitation_start(nd) >= 0);
sd_event_loop(e);
test_hangcheck = sd_event_source_unref(test_hangcheck);
nd = sd_icmp6_nd_unref(nd);
- assert(!nd);
+ assert_se(!nd);
close(test_fd[1]);
}
@@ -146,7 +146,7 @@ static void test_rs(sd_event *e) {
int main(int argc, char *argv[]) {
sd_event *e;
- assert(sd_event_new(&e) >= 0);
+ assert_se(sd_event_new(&e) >= 0);
log_set_max_level(LOG_DEBUG);
log_parse_environment();
diff --git a/src/login/test-inhibit.c b/src/login/test-inhibit.c
index 21d2339616..5379ffcaa1 100644
--- a/src/login/test-inhibit.c
+++ b/src/login/test-inhibit.c
@@ -42,11 +42,11 @@ static int inhibit(sd_bus *bus, const char *what) {
&error,
&reply,
"ssss", what, who, reason, mode);
- assert(r >= 0);
+ assert_se(r >= 0);
r = sd_bus_message_read_basic(reply, SD_BUS_TYPE_UNIX_FD, &fd);
- assert(r >= 0);
- assert(fd >= 0);
+ assert_se(r >= 0);
+ assert_se(fd >= 0);
return dup(fd);
}
@@ -67,10 +67,10 @@ static void print_inhibitors(sd_bus *bus) {
&error,
&reply,
"");
- assert(r >= 0);
+ assert_se(r >= 0);
r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssuu)");
- assert(r >= 0);
+ assert_se(r >= 0);
while ((r = sd_bus_message_read(reply, "(ssssuu)", &what, &who, &why, &mode, &uid, &pid)) > 0) {
printf("what=<%s> who=<%s> why=<%s> mode=<%s> uid=<"UID_FMT"> pid=<"PID_FMT">\n",
@@ -78,7 +78,7 @@ static void print_inhibitors(sd_bus *bus) {
n++;
}
- assert(r >= 0);
+ assert_se(r >= 0);
printf("%u inhibitors\n", n);
}
@@ -89,16 +89,16 @@ int main(int argc, char*argv[]) {
int r;
r = sd_bus_open_system(&bus);
- assert(r >= 0);
+ assert_se(r >= 0);
print_inhibitors(bus);
fd1 = inhibit(bus, "sleep");
- assert(fd1 >= 0);
+ assert_se(fd1 >= 0);
print_inhibitors(bus);
fd2 = inhibit(bus, "idle:shutdown");
- assert(fd2 >= 0);
+ assert_se(fd2 >= 0);
print_inhibitors(bus);
safe_close(fd1);