chiark / gitweb /
tests: use assert_se instead of assert
authorRonny Chevalier <chevalier.ronny@gmail.com>
Sun, 30 Nov 2014 01:16:19 +0000 (02:16 +0100)
committerRonny Chevalier <chevalier.ronny@gmail.com>
Sun, 30 Nov 2014 01:35:52 +0000 (02:35 +0100)
Otherwise they can be optimized away with -DNDEBUG

src/journal/test-catalog.c
src/journal/test-compress.c
src/journal/test-journal-syslog.c
src/journal/test-journal-verify.c
src/journal/test-journal.c
src/journal/test-mmap-cache.c
src/libsystemd-network/test-icmp6-rs.c
src/login/test-inhibit.c

index 5fe2f6a2697e6bb65ba264b2c274e297a013293a..c605ee0e70963f5c7400cd3622a067310827a545 100644 (file)
@@ -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);
         _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_se(write(fd, contents, size) == size);
 
         r = catalog_import_file(h, sb, name);
-        assert(r == code);
+        assert_se(r == code);
 
         unlink(name);
 }
 
         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
 #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 \
         log_debug("----------------------------------------");
 
 #define BUF \
@@ -89,7 +89,7 @@ static void test_catalog_importing(void) {
         test_import(h, sb, BUF, sizeof(BUF), 0);
 #undef BUF
 
         test_import(h, sb, BUF, sizeof(BUF), 0);
 #undef BUF
 
-        assert(hashmap_size(h) == 1);
+        assert_se(hashmap_size(h) == 1);
 
         log_debug("----------------------------------------");
 
 
         log_debug("----------------------------------------");
 
@@ -105,22 +105,22 @@ static void test_catalog_update(void) {
         int r;
 
         r = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
         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);
 
         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);
 
         /* 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);
 
         /* 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) {
 }
 
 static void test_catalog_file_lang(void) {
index dbf09d97c3e265ff6174aed34d27b35e3e6d2fd3..97577e827c8efa5c88df1bb344bd862aa4134135 100644 (file)
@@ -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");
         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 {
         } else {
-                assert(r == 0);
+                assert_se(r == 0);
                 r = decompress(compressed, csize,
                                (void **) &decompressed, &usize, &csize, 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_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);
 
         /* 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);
 
         r = decompress("\100000000g", 9,
                        (void **) &decompressed, &usize, &csize, 0);
-        assert(r < 0);
+        assert_se(r < 0);
 
         memzero(decompressed, usize);
 }
 
         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");
         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;
         }
                 return;
         }
-        assert(r == 0);
+        assert_se(r == 0);
 
         assert_se(decompress_sw(compressed,
                                 csize,
 
         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_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);
 
         assert_se(lseek(dst, 0, SEEK_SET) == 0);
         assert_se(lseek(dst2, 0, SEEK_SET) == 0);
index c4d407148c8d2a8e9496e09262fcb02ca2bf23d8..c99ca0654bb732c32648855214477672428eedc9 100644 (file)
@@ -30,9 +30,9 @@ static void test_syslog_parse_identifier(const char* str,
 
         ret2 = syslog_parse_identifier(&buf, &ident2, &pid2);
 
 
         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 main(void) {
index 3b181c679493daf62c061afd6bc09fde0e1dc0e0..9da120c0bb0add35639c30feb47668ef4ddfd8ff 100644 (file)
@@ -38,15 +38,15 @@ static void bit_toggle(const char *fn, uint64_t p) {
         int fd;
 
         fd = open(fn, O_RDWR|O_CLOEXEC);
         int fd;
 
         fd = open(fn, O_RDWR|O_CLOEXEC);
-        assert(fd >= 0);
+        assert_se(fd >= 0);
 
         r = pread(fd, &b, 1, p/8);
 
         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);
 
         b ^= 1 << (p % 8);
 
         r = pwrite(fd, &b, 1, p/8);
-        assert(r == 1);
+        assert_se(r == 1);
 
         safe_close(fd);
 }
 
         safe_close(fd);
 }
index 74168b9b830e2e2dd84e4e347ebdb07439252590..ff9dc9e1700fd1ea3c4e83899fb411d90277233b 100644 (file)
@@ -66,55 +66,55 @@ static void test_non_empty(void) {
 #endif
         journal_file_dump(f);
 
 #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);
 
         journal_file_rotate(&f, true, true);
         journal_file_rotate(&f, true, true);
index 778e884c3ff032927498c4b215221b75e3538500..1227b62310462a5e5ae8d1caf3aa476631c6a84a 100644 (file)
@@ -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_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);
         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);
         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);
         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);
 
         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);
 
         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);
 
         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);
 
         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);
 
 
         mmap_cache_unref(m);
 
index afa85626598b61cd0840bd9e3fae0bd81527a80c..be64d334fa679c94c9ea95114349e56176e713db 100644 (file)
@@ -36,13 +36,13 @@ static int test_fd[2];
 
 static int test_rs_hangcheck(sd_event_source *s, uint64_t usec,
                              void *userdata) {
 
 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) {
 
         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;
 
         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;
 
 
         advertisement[5] = flags;
 
-        assert(write(test_fd[1], advertisement, sizeof(advertisement)) ==
+        assert_se(write(test_fd[1], advertisement, sizeof(advertisement)) ==
                sizeof(advertisement));
 
         if (verbose)
                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 }
         };
                 { 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)
         idx++;
 
         if (verbose)
@@ -114,31 +114,31 @@ static void test_rs(sd_event *e) {
         if (verbose)
                 printf("* %s\n", __FUNCTION__);
 
         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);
 
                                  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);
 
         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]);
 }
 
         close(test_fd[1]);
 }
@@ -146,7 +146,7 @@ static void test_rs(sd_event *e) {
 int main(int argc, char *argv[]) {
         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();
 
         log_set_max_level(LOG_DEBUG);
         log_parse_environment();
index 21d233961615a319e3be5a00d5a0fa1d80f8fb1e..5379ffcaa1a055d735dad6e6ebb0450f3de59b13 100644 (file)
@@ -42,11 +42,11 @@ static int inhibit(sd_bus *bus, const char *what) {
                         &error,
                         &reply,
                         "ssss", what, who, reason, mode);
                         &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);
 
         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);
 }
 
         return dup(fd);
 }
@@ -67,10 +67,10 @@ static void print_inhibitors(sd_bus *bus) {
                         &error,
                         &reply,
                         "");
                         &error,
                         &reply,
                         "");
-        assert(r >= 0);
+        assert_se(r >= 0);
 
         r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssuu)");
 
         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",
 
         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++;
         }
 
                 n++;
         }
-        assert(r >= 0);
+        assert_se(r >= 0);
 
         printf("%u inhibitors\n", n);
 }
 
         printf("%u inhibitors\n", n);
 }
@@ -89,16 +89,16 @@ int main(int argc, char*argv[]) {
         int r;
 
         r = sd_bus_open_system(&bus);
         int r;
 
         r = sd_bus_open_system(&bus);
-        assert(r >= 0);
+        assert_se(r >= 0);
 
         print_inhibitors(bus);
 
         fd1 = inhibit(bus, "sleep");
 
         print_inhibitors(bus);
 
         fd1 = inhibit(bus, "sleep");
-        assert(fd1 >= 0);
+        assert_se(fd1 >= 0);
         print_inhibitors(bus);
 
         fd2 = inhibit(bus, "idle:shutdown");
         print_inhibitors(bus);
 
         fd2 = inhibit(bus, "idle:shutdown");
-        assert(fd2 >= 0);
+        assert_se(fd2 >= 0);
         print_inhibitors(bus);
 
         safe_close(fd1);
         print_inhibitors(bus);
 
         safe_close(fd1);