_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);
}
#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 \
test_import(h, sb, BUF, sizeof(BUF), 0);
#undef BUF
- assert(hashmap_size(h) == 1);
+ assert_se(hashmap_size(h) == 1);
log_debug("----------------------------------------");
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) {
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);
}
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,
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);
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) {
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);
}
#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);
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);
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;
advertisement[5] = flags;
- assert(write(test_fd[1], advertisement, sizeof(advertisement)) ==
+ assert_se(write(test_fd[1], advertisement, sizeof(advertisement)) ==
sizeof(advertisement));
if (verbose)
{ 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)
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]);
}
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();
&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);
}
&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",
n++;
}
- assert(r >= 0);
+ assert_se(r >= 0);
printf("%u inhibitors\n", n);
}
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);