dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
Blob Blame History Raw
From bdf7026e9557349cd3eeb291c01655d5f2a55db8 Mon Sep 17 00:00:00 2001
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Date: Sat, 4 Oct 2014 23:51:45 +0200
Subject: [PATCH] test: only use assert_se

The asserts used in the tests should never be allowed to be
optimized away
---
 src/test/test-cgroup-mask.c | 68 ++++++++++++++++++++++-----------------------
 src/test/test-cgroup.c      | 12 ++++----
 src/test/test-engine.c      |  4 +--
 src/test/test-fileio.c      | 14 +++++-----
 src/test/test-hashmap.c     |  2 +-
 src/test/test-install.c     |  2 +-
 src/test/test-job-type.c    | 22 +++++++--------
 src/test/test-libudev.c     |  2 +-
 src/test/test-sched-prio.c  |  2 +-
 src/test/test-set.c         |  2 +-
 src/test/test-socket-util.c |  8 +++---
 src/test/test-strbuf.c      | 54 +++++++++++++++++------------------
 src/test/test-strv.c        | 10 +++----
 src/test/test-strxcpyx.c    | 20 ++++++-------
 src/test/test-tmpfiles.c    |  4 +--
 src/test/test-unit-file.c   | 52 +++++++++++++++++-----------------
 src/test/test-unit-name.c   | 12 ++++----
 src/test/test-util.c        | 48 ++++++++++++++++----------------
 18 files changed, 169 insertions(+), 169 deletions(-)

diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c
index f98e1bb174..9e9de23e0e 100644
--- a/src/test/test-cgroup-mask.c
+++ b/src/test/test-cgroup-mask.c
@@ -45,7 +45,7 @@ static int test_cgroup_mask(void) {
                 puts("manager_new: Permission denied. Skipping test.");
                 return EXIT_TEST_SKIP;
         }
-        assert(r >= 0);
+        assert_se(r >= 0);
         assert_se(manager_startup(m, serial, fdset) >= 0);
 
         /* Load units and verify hierarchy. */
@@ -54,48 +54,48 @@ static int test_cgroup_mask(void) {
         assert_se(manager_load_unit(m, "daughter.service", NULL, NULL, &daughter) >= 0);
         assert_se(manager_load_unit(m, "grandchild.service", NULL, NULL, &grandchild) >= 0);
         assert_se(manager_load_unit(m, "parent-deep.slice", NULL, NULL, &parent_deep) >= 0);
-        assert(parent->load_state == UNIT_LOADED);
-        assert(son->load_state == UNIT_LOADED);
-        assert(daughter->load_state == UNIT_LOADED);
-        assert(grandchild->load_state == UNIT_LOADED);
-        assert(parent_deep->load_state == UNIT_LOADED);
-        assert(UNIT_DEREF(son->slice) == parent);
-        assert(UNIT_DEREF(daughter->slice) == parent);
-        assert(UNIT_DEREF(parent_deep->slice) == parent);
-        assert(UNIT_DEREF(grandchild->slice) == parent_deep);
+        assert_se(parent->load_state == UNIT_LOADED);
+        assert_se(son->load_state == UNIT_LOADED);
+        assert_se(daughter->load_state == UNIT_LOADED);
+        assert_se(grandchild->load_state == UNIT_LOADED);
+        assert_se(parent_deep->load_state == UNIT_LOADED);
+        assert_se(UNIT_DEREF(son->slice) == parent);
+        assert_se(UNIT_DEREF(daughter->slice) == parent);
+        assert_se(UNIT_DEREF(parent_deep->slice) == parent);
+        assert_se(UNIT_DEREF(grandchild->slice) == parent_deep);
         root = UNIT_DEREF(parent->slice);
 
         /* Verify per-unit cgroups settings. */
-        assert(unit_get_cgroup_mask(son) == (CGROUP_CPU | CGROUP_CPUACCT));
-        assert(unit_get_cgroup_mask(daughter) == 0);
-        assert(unit_get_cgroup_mask(grandchild) == 0);
-        assert(unit_get_cgroup_mask(parent_deep) == CGROUP_MEMORY);
-        assert(unit_get_cgroup_mask(parent) == CGROUP_BLKIO);
-        assert(unit_get_cgroup_mask(root) == 0);
+        assert_se(unit_get_cgroup_mask(son) == (CGROUP_CPU | CGROUP_CPUACCT));
+        assert_se(unit_get_cgroup_mask(daughter) == 0);
+        assert_se(unit_get_cgroup_mask(grandchild) == 0);
+        assert_se(unit_get_cgroup_mask(parent_deep) == CGROUP_MEMORY);
+        assert_se(unit_get_cgroup_mask(parent) == CGROUP_BLKIO);
+        assert_se(unit_get_cgroup_mask(root) == 0);
 
         /* Verify aggregation of member masks */
-        assert(unit_get_members_mask(son) == 0);
-        assert(unit_get_members_mask(daughter) == 0);
-        assert(unit_get_members_mask(grandchild) == 0);
-        assert(unit_get_members_mask(parent_deep) == 0);
-        assert(unit_get_members_mask(parent) == (CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY));
-        assert(unit_get_members_mask(root) == (CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY));
+        assert_se(unit_get_members_mask(son) == 0);
+        assert_se(unit_get_members_mask(daughter) == 0);
+        assert_se(unit_get_members_mask(grandchild) == 0);
+        assert_se(unit_get_members_mask(parent_deep) == 0);
+        assert_se(unit_get_members_mask(parent) == (CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY));
+        assert_se(unit_get_members_mask(root) == (CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY));
 
         /* Verify aggregation of sibling masks. */
-        assert(unit_get_siblings_mask(son) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert(unit_get_siblings_mask(daughter) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert(unit_get_siblings_mask(grandchild) == 0);
-        assert(unit_get_siblings_mask(parent_deep) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert(unit_get_siblings_mask(parent) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
-        assert(unit_get_siblings_mask(root) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
+        assert_se(unit_get_siblings_mask(son) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
+        assert_se(unit_get_siblings_mask(daughter) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
+        assert_se(unit_get_siblings_mask(grandchild) == 0);
+        assert_se(unit_get_siblings_mask(parent_deep) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
+        assert_se(unit_get_siblings_mask(parent) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
+        assert_se(unit_get_siblings_mask(root) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
 
         /* Verify aggregation of target masks. */
-        assert(unit_get_target_mask(son) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert(unit_get_target_mask(daughter) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert(unit_get_target_mask(grandchild) == 0);
-        assert(unit_get_target_mask(parent_deep) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
-        assert(unit_get_target_mask(parent) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
-        assert(unit_get_target_mask(root) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
+        assert_se(unit_get_target_mask(son) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
+        assert_se(unit_get_target_mask(daughter) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
+        assert_se(unit_get_target_mask(grandchild) == 0);
+        assert_se(unit_get_target_mask(parent_deep) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_MEMORY) & m->cgroup_supported));
+        assert_se(unit_get_target_mask(parent) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
+        assert_se(unit_get_target_mask(root) == ((CGROUP_CPU | CGROUP_CPUACCT | CGROUP_BLKIO | CGROUP_MEMORY) & m->cgroup_supported));
 
         manager_free(m);
 
diff --git a/src/test/test-cgroup.c b/src/test/test-cgroup.c
index 2a0ce27206..46642f92fe 100644
--- a/src/test/test-cgroup.c
+++ b/src/test/test-cgroup.c
@@ -79,8 +79,8 @@ int main(int argc, char*argv[]) {
         assert_se(cg_delete(SYSTEMD_CGROUP_CONTROLLER, "/test-a") >= 0);
 
         assert_se(cg_split_spec("foobar:/", &c, &p) == 0);
-        assert(streq(c, "foobar"));
-        assert(streq(p, "/"));
+        assert_se(streq(c, "foobar"));
+        assert_se(streq(p, "/"));
         free(c);
         free(p);
 
@@ -92,13 +92,13 @@ int main(int argc, char*argv[]) {
         assert_se(cg_split_spec("fo/obar:/", &c, &p) < 0);
 
         assert_se(cg_split_spec("/", &c, &p) >= 0);
-        assert(c == NULL);
-        assert(streq(p, "/"));
+        assert_se(c == NULL);
+        assert_se(streq(p, "/"));
         free(p);
 
         assert_se(cg_split_spec("foo", &c, &p) >= 0);
-        assert(streq(c, "foo"));
-        assert(p == NULL);
+        assert_se(streq(c, "foo"));
+        assert_se(p == NULL);
         free(c);
 
         return 0;
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
index 6e39a586c0..1b71416a04 100644
--- a/src/test/test-engine.c
+++ b/src/test/test-engine.c
@@ -43,7 +43,7 @@ int main(int argc, char *argv[]) {
                 printf("Skipping test: manager_new: %s", strerror(-r));
                 return EXIT_TEST_SKIP;
         }
-        assert(r >= 0);
+        assert_se(r >= 0);
         assert_se(manager_startup(m, serial, fdset) >= 0);
 
         printf("Load1:\n");
@@ -56,7 +56,7 @@ int main(int argc, char *argv[]) {
         r = manager_add_job(m, JOB_START, c, JOB_REPLACE, false, &err, &j);
         if (sd_bus_error_is_set(&err))
                 log_error("error: %s: %s", err.name, err.message);
-        assert(r == 0);
+        assert_se(r == 0);
         manager_dump_jobs(m, stdout, "\t");
 
         printf("Load2:\n");
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index ad65abf426..76a9e8e9c9 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -246,25 +246,25 @@ static void test_status_field(void) {
 
         r = get_status_field("/proc/meminfo", "MemTotal:", &p);
         if (r != -ENOENT) {
-                assert(r == 0);
+                assert_se(r == 0);
                 puts(p);
                 assert_se(safe_atollu(p, &total) == 0);
         }
 
         r = get_status_field("/proc/meminfo", "\nBuffers:", &s);
         if (r != -ENOENT) {
-                assert(r == 0);
+                assert_se(r == 0);
                 puts(s);
                 assert_se(safe_atollu(s, &buffers) == 0);
         }
 
         if (p)
-                assert(buffers < total);
+                assert_se(buffers < total);
 
         /* Seccomp should be a good test for field full of zeros. */
         r = get_status_field("/proc/meminfo", "\nSeccomp:", &z);
         if (r != -ENOENT) {
-                assert(r == 0);
+                assert_se(r == 0);
                 puts(z);
                 assert_se(safe_atollu(z, &buffers) == 0);
         }
@@ -283,10 +283,10 @@ static void test_capeff(void) {
                 if (r == -ENOENT || r == -EPERM)
                         return;
 
-                assert(r == 0);
-                assert(*capeff);
+                assert_se(r == 0);
+                assert_se(*capeff);
                 p = capeff[strspn(capeff, DIGITS "abcdefABCDEF")];
-                assert(!p || isspace(p));
+                assert_se(!p || isspace(p));
         }
 }
 
diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c
index f4afbb8e9d..f9072061dd 100644
--- a/src/test/test-hashmap.c
+++ b/src/test/test-hashmap.c
@@ -522,7 +522,7 @@ static void test_hashmap_steal_first(void) {
         while ((val = hashmap_steal_first(m)))
                 seen[strlen(val) - 1]++;
 
-        assert(seen[0] == 1 && seen[1] == 1 && seen[2] == 1);
+        assert_se(seen[0] == 1 && seen[1] == 1 && seen[2] == 1);
 
         assert_se(hashmap_isempty(m));
 }
diff --git a/src/test/test-install.c b/src/test/test-install.c
index b0f77a18f3..467970b007 100644
--- a/src/test/test-install.c
+++ b/src/test/test-install.c
@@ -31,7 +31,7 @@
 static void dump_changes(UnitFileChange *c, unsigned n) {
         unsigned i;
 
-        assert(n == 0 || c);
+        assert_se(n == 0 || c);
 
         for (i = 0; i < n; i++) {
                 if (c[i].type == UNIT_FILE_UNLINK)
diff --git a/src/test/test-job-type.c b/src/test/test-job-type.c
index 1066374436..1d9d49b228 100644
--- a/src/test/test-job-type.c
+++ b/src/test/test-job-type.c
@@ -52,29 +52,29 @@ int main(int argc, char*argv[]) {
                                 merged_ab = (job_type_merge_and_collapse(&ab, b, u) >= 0);
 
                                 if (!job_type_is_mergeable(a, b)) {
-                                        assert(!merged_ab);
+                                        assert_se(!merged_ab);
                                         printf("Not mergeable: %s + %s\n", job_type_to_string(a), job_type_to_string(b));
                                         continue;
                                 }
 
-                                assert(merged_ab);
+                                assert_se(merged_ab);
                                 printf("%s + %s = %s\n", job_type_to_string(a), job_type_to_string(b), job_type_to_string(ab));
 
                                 for (c = 0; c < _JOB_TYPE_MAX_MERGING; c++) {
 
                                         /* Verify transitivity of mergeability of job types */
-                                        assert(!job_type_is_mergeable(a, b) ||
+                                        assert_se(!job_type_is_mergeable(a, b) ||
                                                !job_type_is_mergeable(b, c) ||
                                                job_type_is_mergeable(a, c));
 
                                         /* Verify that merged entries can be merged with the same entries
                                          * they can be merged with separately */
-                                        assert(!job_type_is_mergeable(a, c) || job_type_is_mergeable(ab, c));
-                                        assert(!job_type_is_mergeable(b, c) || job_type_is_mergeable(ab, c));
+                                        assert_se(!job_type_is_mergeable(a, c) || job_type_is_mergeable(ab, c));
+                                        assert_se(!job_type_is_mergeable(b, c) || job_type_is_mergeable(ab, c));
 
                                         /* Verify that if a merged with b is not mergeable with c, then
                                          * either a or b is not mergeable with c either. */
-                                        assert(job_type_is_mergeable(ab, c) || !job_type_is_mergeable(a, c) || !job_type_is_mergeable(b, c));
+                                        assert_se(job_type_is_mergeable(ab, c) || !job_type_is_mergeable(a, c) || !job_type_is_mergeable(b, c));
 
                                         bc = b;
                                         if (job_type_merge_and_collapse(&bc, c, u) >= 0) {
@@ -82,16 +82,16 @@ int main(int argc, char*argv[]) {
                                                 /* Verify associativity */
 
                                                 ab_c = ab;
-                                                assert(job_type_merge_and_collapse(&ab_c, c, u) == 0);
+                                                assert_se(job_type_merge_and_collapse(&ab_c, c, u) == 0);
 
                                                 bc_a = bc;
-                                                assert(job_type_merge_and_collapse(&bc_a, a, u) == 0);
+                                                assert_se(job_type_merge_and_collapse(&bc_a, a, u) == 0);
 
                                                 a_bc = a;
-                                                assert(job_type_merge_and_collapse(&a_bc, bc, u) == 0);
+                                                assert_se(job_type_merge_and_collapse(&a_bc, bc, u) == 0);
 
-                                                assert(ab_c == bc_a);
-                                                assert(ab_c == a_bc);
+                                                assert_se(ab_c == bc_a);
+                                                assert_se(ab_c == a_bc);
 
                                                 printf("%s + %s + %s = %s\n", job_type_to_string(a), job_type_to_string(b), job_type_to_string(c), job_type_to_string(ab_c));
                                         }
diff --git a/src/test/test-libudev.c b/src/test/test-libudev.c
index ea190990eb..a51814df95 100644
--- a/src/test/test-libudev.c
+++ b/src/test/test-libudev.c
@@ -407,7 +407,7 @@ static void test_hwdb(struct udev *udev, const char *modalias) {
         printf("\n");
 
         hwdb = udev_hwdb_unref(hwdb);
-        assert(hwdb == NULL);
+        assert_se(hwdb == NULL);
 }
 
 int main(int argc, char *argv[]) {
diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c
index 8fdca0ea23..2f559b0413 100644
--- a/src/test/test-sched-prio.c
+++ b/src/test/test-sched-prio.c
@@ -39,7 +39,7 @@ int main(int argc, char *argv[]) {
                 printf("Skipping test: manager_new: %s", strerror(-r));
                 return EXIT_TEST_SKIP;
         }
-        assert(r >= 0);
+        assert_se(r >= 0);
         assert_se(manager_startup(m, serial, fdset) >= 0);
 
         /* load idle ok */
diff --git a/src/test/test-set.c b/src/test/test-set.c
index 060dba42df..e280c8952d 100644
--- a/src/test/test-set.c
+++ b/src/test/test-set.c
@@ -35,7 +35,7 @@ static void test_set_steal_first(void) {
         while ((val = set_steal_first(m)))
                 seen[strlen(val) - 1]++;
 
-        assert(seen[0] == 1 && seen[1] == 1 && seen[2] == 1);
+        assert_se(seen[0] == 1 && seen[1] == 1 && seen[2] == 1);
 
         assert_se(set_isempty(m));
 }
diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c
index 17180db652..c2c728bcde 100644
--- a/src/test/test-socket-util.c
+++ b/src/test/test-socket-util.c
@@ -236,7 +236,7 @@ static void *connect_thread(void *arg) {
         _cleanup_close_ int fd = -1;
 
         fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
-        assert(fd >= 0);
+        assert_se(fd >= 0);
 
         assert_se(connect(fd, &sa->sa, sizeof(sa->in)) == 0);
 
@@ -263,7 +263,7 @@ static void test_nameinfo_pretty(void) {
         assert_se(r < 0);
 
         sfd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
-        assert(sfd >= 0);
+        assert_se(sfd >= 0);
 
         assert_se(bind(sfd, &s.sa, sizeof(s.in)) == 0);
 
@@ -276,11 +276,11 @@ static void test_nameinfo_pretty(void) {
 
         log_debug("Accepting new connection on fd:%d", sfd);
         cfd = accept4(sfd, &c.sa, &clen, SOCK_CLOEXEC);
-        assert(cfd >= 0);
+        assert_se(cfd >= 0);
 
         r = getnameinfo_pretty(cfd, &localhost);
         log_info("Connection from %s", localhost);
-        assert(r == 0);
+        assert_se(r == 0);
 }
 
 static void test_sockaddr_equal(void) {
diff --git a/src/test/test-strbuf.c b/src/test/test-strbuf.c
index 3334e0bf6c..43cb92b74b 100644
--- a/src/test/test-strbuf.c
+++ b/src/test/test-strbuf.c
@@ -48,39 +48,39 @@ static void test_strbuf(void) {
         /* check the content of the buffer directly */
         l = strv_parse_nulstr(sb->buf, sb->len);
 
-        assert(streq(l[0], "")); /* root*/
-        assert(streq(l[1], "waldo"));
-        assert(streq(l[2], "foo"));
-        assert(streq(l[3], "bar"));
-        assert(streq(l[4], "waldorf"));
+        assert_se(streq(l[0], "")); /* root*/
+        assert_se(streq(l[1], "waldo"));
+        assert_se(streq(l[2], "foo"));
+        assert_se(streq(l[3], "bar"));
+        assert_se(streq(l[4], "waldorf"));
 
-        assert(sb->nodes_count == 5); /* root + 4 non-duplicates */
-        assert(sb->dedup_count == 3);
-        assert(sb->in_count == 7);
+        assert_se(sb->nodes_count == 5); /* root + 4 non-duplicates */
+        assert_se(sb->dedup_count == 3);
+        assert_se(sb->in_count == 7);
 
-        assert(sb->in_len == 29);    /* length of all strings added */
-        assert(sb->dedup_len == 11); /* length of all strings duplicated */
-        assert(sb->len == 23);       /* buffer length: in - dedup + \0 for each node */
+        assert_se(sb->in_len == 29);    /* length of all strings added */
+        assert_se(sb->dedup_len == 11); /* length of all strings duplicated */
+        assert_se(sb->len == 23);       /* buffer length: in - dedup + \0 for each node */
 
         /* check the returned offsets and the respective content in the buffer */
-        assert(a == 1);
-        assert(b == 7);
-        assert(c == 11);
-        assert(d == 1);
-        assert(e == 2);
-        assert(f == 4);
-        assert(g == 15);
-
-        assert(streq(sb->buf + a, "waldo"));
-        assert(streq(sb->buf + b, "foo"));
-        assert(streq(sb->buf + c, "bar"));
-        assert(streq(sb->buf + d, "waldo"));
-        assert(streq(sb->buf + e, "aldo"));
-        assert(streq(sb->buf + f, "do"));
-        assert(streq(sb->buf + g, "waldorf"));
+        assert_se(a == 1);
+        assert_se(b == 7);
+        assert_se(c == 11);
+        assert_se(d == 1);
+        assert_se(e == 2);
+        assert_se(f == 4);
+        assert_se(g == 15);
+
+        assert_se(streq(sb->buf + a, "waldo"));
+        assert_se(streq(sb->buf + b, "foo"));
+        assert_se(streq(sb->buf + c, "bar"));
+        assert_se(streq(sb->buf + d, "waldo"));
+        assert_se(streq(sb->buf + e, "aldo"));
+        assert_se(streq(sb->buf + f, "do"));
+        assert_se(streq(sb->buf + g, "waldorf"));
 
         strbuf_complete(sb);
-        assert(sb->root == NULL);
+        assert_se(sb->root == NULL);
 
         strbuf_cleanup(sb);
 }
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index 7ba4c366ac..bbfe306d7d 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -170,7 +170,7 @@ static void test_strv_unquote(const char *quoted, const char **list) {
         assert_se(r == 0);
         assert_se(s);
         j = strv_join(s, " | ");
-        assert(j);
+        assert_se(j);
         puts(j);
 
         STRV_FOREACH(t, s)
@@ -184,8 +184,8 @@ static void test_invalid_unquote(const char *quoted) {
         int r;
 
         r = strv_split_quoted(&s, quoted);
-        assert(s == NULL);
-        assert(r == -EINVAL);
+        assert_se(s == NULL);
+        assert_se(r == -EINVAL);
 }
 
 static void test_strv_split(void) {
@@ -196,7 +196,7 @@ static void test_strv_split(void) {
 
         l = strv_split(str, ",");
 
-        assert(l);
+        assert_se(l);
 
         STRV_FOREACH(s, l) {
                 assert_se(streq(*s, input_table_multiple[i++]));
@@ -211,7 +211,7 @@ static void test_strv_split_newlines(void) {
 
         l = strv_split_newlines(str);
 
-        assert(l);
+        assert_se(l);
 
         STRV_FOREACH(s, l) {
                 assert_se(streq(*s, input_table_multiple[i++]));
diff --git a/src/test/test-strxcpyx.c b/src/test/test-strxcpyx.c
index b7b70d4c15..cb2309210f 100644
--- a/src/test/test-strxcpyx.c
+++ b/src/test/test-strxcpyx.c
@@ -38,8 +38,8 @@ static void test_strpcpy(void) {
         space_left = strpcpy(&s, space_left, "r");
         space_left = strpcpy(&s, space_left, "foo");
 
-        assert(streq(target, "12345hey hey heywaldobar"));
-        assert(space_left == 0);
+        assert_se(streq(target, "12345hey hey heywaldobar"));
+        assert_se(space_left == 0);
 }
 
 static void test_strpcpyf(void) {
@@ -51,8 +51,8 @@ static void test_strpcpyf(void) {
         space_left = strpcpyf(&s, space_left, "space left: %zd. ", space_left);
         space_left = strpcpyf(&s, space_left, "foo%s", "bar");
 
-        assert(streq(target, "space left: 25. foobar"));
-        assert(space_left == 3);
+        assert_se(streq(target, "space left: 25. foobar"));
+        assert_se(space_left == 3);
 }
 
 static void test_strpcpyl(void) {
@@ -64,8 +64,8 @@ static void test_strpcpyl(void) {
         space_left = strpcpyl(&s, space_left, "waldo", " test", " waldo. ", NULL);
         space_left = strpcpyl(&s, space_left, "Banana", NULL);
 
-        assert(streq(target, "waldo test waldo. Banana"));
-        assert(space_left == 1);
+        assert_se(streq(target, "waldo test waldo. Banana"));
+        assert_se(space_left == 1);
 }
 
 static void test_strscpy(void) {
@@ -75,8 +75,8 @@ static void test_strscpy(void) {
         space_left = sizeof(target);
         space_left = strscpy(target, space_left, "12345");
 
-        assert(streq(target, "12345"));
-        assert(space_left == 20);
+        assert_se(streq(target, "12345"));
+        assert_se(space_left == 20);
 }
 
 static void test_strscpyl(void) {
@@ -86,8 +86,8 @@ static void test_strscpyl(void) {
         space_left = sizeof(target);
         space_left = strscpyl(target, space_left, "12345", "waldo", "waldo", NULL);
 
-        assert(streq(target, "12345waldowaldo"));
-        assert(space_left == 10);
+        assert_se(streq(target, "12345waldowaldo"));
+        assert_se(space_left == 10);
 }
 
 int main(int argc, char *argv[]) {
diff --git a/src/test/test-tmpfiles.c b/src/test/test-tmpfiles.c
index 565f0f8b40..84050c6fa4 100644
--- a/src/test/test-tmpfiles.c
+++ b/src/test/test-tmpfiles.c
@@ -35,13 +35,13 @@ int main(int argc, char** argv) {
         _cleanup_free_ char *cmd, *cmd2;
 
         fd = open_tmpfile(p, O_RDWR|O_CLOEXEC);
-        assert(fd >= 0);
+        assert_se(fd >= 0);
 
         assert_se(asprintf(&cmd, "ls -l /proc/"PID_FMT"/fd/%d", getpid(), fd) > 0);
         system(cmd);
 
         fd2 = mkostemp_safe(pattern, O_RDWR|O_CLOEXEC);
-        assert(fd >= 0);
+        assert_se(fd >= 0);
         assert_se(unlink(pattern) == 0);
 
         assert_se(asprintf(&cmd2, "ls -l /proc/"PID_FMT"/fd/%d", getpid(), fd2) > 0);
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index 89f5bdd4ed..03b3e25939 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -45,7 +45,7 @@ static int test_unit_file_get_set(void) {
         UnitFileList *p;
 
         h = hashmap_new(&string_hash_ops);
-        assert(h);
+        assert_se(h);
 
         r = unit_file_get_list(UNIT_FILE_SYSTEM, NULL, h);
 
@@ -231,18 +231,18 @@ static void test_load_env_file_1(void) {
         _cleanup_close_ int fd;
 
         fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert(fd >= 0);
+        assert_se(fd >= 0);
         assert_se(write(fd, env_file_1, sizeof(env_file_1)) == sizeof(env_file_1));
 
         r = load_env_file(NULL, name, NULL, &data);
-        assert(r == 0);
-        assert(streq(data[0], "a=a"));
-        assert(streq(data[1], "b=bc"));
-        assert(streq(data[2], "d=def"));
-        assert(streq(data[3], "g=g "));
-        assert(streq(data[4], "h=h"));
-        assert(streq(data[5], "i=i"));
-        assert(data[6] == NULL);
+        assert_se(r == 0);
+        assert_se(streq(data[0], "a=a"));
+        assert_se(streq(data[1], "b=bc"));
+        assert_se(streq(data[2], "d=def"));
+        assert_se(streq(data[3], "g=g "));
+        assert_se(streq(data[4], "h=h"));
+        assert_se(streq(data[5], "i=i"));
+        assert_se(data[6] == NULL);
         unlink(name);
 }
 
@@ -254,13 +254,13 @@ static void test_load_env_file_2(void) {
         _cleanup_close_ int fd;
 
         fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert(fd >= 0);
+        assert_se(fd >= 0);
         assert_se(write(fd, env_file_2, sizeof(env_file_2)) == sizeof(env_file_2));
 
         r = load_env_file(NULL, name, NULL, &data);
-        assert(r == 0);
-        assert(streq(data[0], "a=a"));
-        assert(data[1] == NULL);
+        assert_se(r == 0);
+        assert_se(streq(data[0], "a=a"));
+        assert_se(data[1] == NULL);
         unlink(name);
 }
 
@@ -272,12 +272,12 @@ static void test_load_env_file_3(void) {
         _cleanup_close_ int fd;
 
         fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert(fd >= 0);
+        assert_se(fd >= 0);
         assert_se(write(fd, env_file_3, sizeof(env_file_3)) == sizeof(env_file_3));
 
         r = load_env_file(NULL, name, NULL, &data);
-        assert(r == 0);
-        assert(data == NULL);
+        assert_se(r == 0);
+        assert_se(data == NULL);
         unlink(name);
 }
 
@@ -288,15 +288,15 @@ static void test_load_env_file_4(void) {
         int r;
 
         fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
-        assert(fd >= 0);
+        assert_se(fd >= 0);
         assert_se(write(fd, env_file_4, sizeof(env_file_4)) == sizeof(env_file_4));
 
         r = load_env_file(NULL, name, NULL, &data);
-        assert(r == 0);
-        assert(streq(data[0], "HWMON_MODULES=coretemp f71882fg"));
-        assert(streq(data[1], "MODULE_0=coretemp"));
-        assert(streq(data[2], "MODULE_1=f71882fg"));
-        assert(data[3] == NULL);
+        assert_se(r == 0);
+        assert_se(streq(data[0], "HWMON_MODULES=coretemp f71882fg"));
+        assert_se(streq(data[1], "MODULE_0=coretemp"));
+        assert_se(streq(data[2], "MODULE_1=f71882fg"));
+        assert_se(data[3] == NULL);
         unlink(name);
 }
 
@@ -329,11 +329,11 @@ static void test_install_printf(void) {
                 memzero(i.name, strlen(i.name));                        \
                 memzero(i.path, strlen(i.path));                        \
                 memzero(i.user, strlen(i.user));                        \
-                assert(d1 && d2 && d3);                                 \
+                assert_se(d1 && d2 && d3);                                 \
                 if (result) {                                           \
                         printf("%s\n", t);                              \
-                        assert(streq(t, result));                       \
-                } else assert(t == NULL);                               \
+                        assert_se(streq(t, result));                       \
+                } else assert_se(t == NULL);                               \
                 strcpy(i.name, d1);                                     \
                 strcpy(i.path, d2);                                     \
                 strcpy(i.user, d3);                                     \
diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c
index b733173742..256e820c22 100644
--- a/src/test/test-unit-name.c
+++ b/src/test/test-unit-name.c
@@ -43,7 +43,7 @@ static void test_replacements(void) {
                 _cleanup_free_ char *t =                           \
                         unit_name_replace_instance(pattern, repl); \
                 puts(t);                                           \
-                assert(streq(t, expected));                        \
+                assert_se(streq(t, expected));                        \
         }
 
         expect("foo@.service", "waldo", "foo@waldo.service");
@@ -64,7 +64,7 @@ static void test_replacements(void) {
                 puts(t);                                           \
                 k = unit_name_to_path(t);                          \
                 puts(k);                                           \
-                assert(streq(k, expected ? expected : path));      \
+                assert_se(streq(k, expected ? expected : path));      \
         }
 
         expect("/waldo", ".mount", NULL);
@@ -80,7 +80,7 @@ static void test_replacements(void) {
                 _cleanup_free_ char *t =                                     \
                         unit_name_from_path_instance(pattern, path, suffix); \
                 puts(t);                                                     \
-                assert(streq(t, expected));                                  \
+                assert_se(streq(t, expected));                                  \
         }
 
         expect("waldo", "/waldo", ".mount", "waldo@waldo.mount");
@@ -130,7 +130,7 @@ static int test_unit_printf(void) {
                 puts("manager_new: Permission denied. Skipping test.");
                 return EXIT_TEST_SKIP;
         }
-        assert(r == 0);
+        assert_se(r == 0);
 
 #define expect(unit, pattern, expected)                                 \
         {                                                               \
@@ -139,9 +139,9 @@ static int test_unit_printf(void) {
                 assert_se(unit_full_printf(unit, pattern, &t) >= 0);    \
                 printf("result: %s\nexpect: %s\n", t, expected);        \
                 if ((e = endswith(expected, "*")))                      \
-                        assert(strncmp(t, e, e-expected));              \
+                        assert_se(strncmp(t, e, e-expected));              \
                 else                                                    \
-                        assert(streq(t, expected));                     \
+                        assert_se(streq(t, expected));                     \
         }
 
         assert_se(setenv("USER", "root", 1) == 0);
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 1311184815..de6a2a0d89 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -231,7 +231,7 @@ static void test_parse_pid(void) {
 
         pid = 65; /* pid is left unchanged on ERANGE. Set to known arbitrary value. */
         r = parse_pid("0xFFFFFFFFFFFFFFFFF", &pid);
-        assert(r == -ERANGE);
+        assert_se(r == -ERANGE);
         assert_se(pid == 65);
 }
 
@@ -434,7 +434,7 @@ static void test_foreach_word_quoted(void) {
                 assert_se(strneq(expected[i++], word, l));
                 printf("<%s>\n", t);
         }
-        assert(isempty(state));
+        assert_se(isempty(state));
 }
 
 static void test_default_term_for_tty(void) {
@@ -466,26 +466,26 @@ static void test_memdup_multiply(void) {
 }
 
 static void test_hostname_is_valid(void) {
-        assert(hostname_is_valid("foobar"));
-        assert(hostname_is_valid("foobar.com"));
-        assert(!hostname_is_valid("fööbar"));
-        assert(!hostname_is_valid(""));
-        assert(!hostname_is_valid("."));
-        assert(!hostname_is_valid(".."));
-        assert(!hostname_is_valid("foobar."));
-        assert(!hostname_is_valid(".foobar"));
-        assert(!hostname_is_valid("foo..bar"));
-        assert(!hostname_is_valid("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"));
+        assert_se(hostname_is_valid("foobar"));
+        assert_se(hostname_is_valid("foobar.com"));
+        assert_se(!hostname_is_valid("fööbar"));
+        assert_se(!hostname_is_valid(""));
+        assert_se(!hostname_is_valid("."));
+        assert_se(!hostname_is_valid(".."));
+        assert_se(!hostname_is_valid("foobar."));
+        assert_se(!hostname_is_valid(".foobar"));
+        assert_se(!hostname_is_valid("foo..bar"));
+        assert_se(!hostname_is_valid("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"));
 }
 
 static void test_u64log2(void) {
-        assert(u64log2(0) == 0);
-        assert(u64log2(8) == 3);
-        assert(u64log2(9) == 3);
-        assert(u64log2(15) == 3);
-        assert(u64log2(16) == 4);
-        assert(u64log2(1024*1024) == 20);
-        assert(u64log2(1024*1024+5) == 20);
+        assert_se(u64log2(0) == 0);
+        assert_se(u64log2(8) == 3);
+        assert_se(u64log2(9) == 3);
+        assert_se(u64log2(15) == 3);
+        assert_se(u64log2(16) == 4);
+        assert_se(u64log2(1024*1024) == 20);
+        assert_se(u64log2(1024*1024+5) == 20);
 }
 
 static void test_get_process_comm(void) {
@@ -532,7 +532,7 @@ static void test_get_process_comm(void) {
         log_info("pid1 gid: "GID_FMT, g);
         assert_se(g == 0);
 
-        assert(get_ctty_devnr(1, &h) == -ENOENT);
+        assert_se(get_ctty_devnr(1, &h) == -ENOENT);
 
         getenv_for_pid(1, "PATH", &i);
         log_info("pid1 $PATH: '%s'", strna(i));
@@ -544,7 +544,7 @@ static void test_protect_errno(void) {
                 PROTECT_ERRNO;
                 errno = 11;
         }
-        assert(errno == 12);
+        assert_se(errno == 12);
 }
 
 static void test_parse_size(void) {
@@ -729,12 +729,12 @@ static void test_writing_tmpfile(void) {
         printf("tmpfile: %s", name);
 
         r = writev(fd, iov, 3);
-        assert(r >= 0);
+        assert_se(r >= 0);
 
         r = read_full_file(name, &contents, &size);
-        assert(r == 0);
+        assert_se(r == 0);
         printf("contents: %s", contents);
-        assert(streq(contents, "abc\n" ALPHANUMERICAL "\n"));
+        assert_se(streq(contents, "abc\n" ALPHANUMERICAL "\n"));
 
         unlink(name);
 }