kdbus: test suite changed to common format
[platform/kernel/linux-rpi.git] / tools / testing / selftests / kdbus / test-policy-priv.c
index 14a09c6..0d9d476 100644 (file)
 #include "kdbus-util.h"
 #include "kdbus-enum.h"
 
-static int test_policy_priv_by_id(const char *bus,
+static wur int test_policy_priv_by_id(const char *bus,
                                  struct kdbus_conn *conn_dst,
-                                 bool drop_second_user,
                                  int parent_status,
                                  int child_status)
 {
-       int ret = 0;
        uint64_t expected_cookie = time(NULL) ^ 0xdeadbeef;
 
-       ASSERT_RETURN(conn_dst);
+#ifdef TIZEN
+       parent_status = child_status = 0;
+#endif
+
+       ASSERT_NONZERO(conn_dst);
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, bus, ({
-               ret = kdbus_msg_send(unpriv, NULL,
-                                    expected_cookie, 0, 0, 0,
-                                    conn_dst->id, 0, NULL);
-               ASSERT_EXIT(ret == child_status);
+       RUN_UNPRIVILEGED_CONN(unpriv, bus, ({
+               ASSERT_EXIT(child_status,==,kdbus_msg_send(unpriv, NULL, expected_cookie, 0, 0, 0, conn_dst->id));
        }));
-       ASSERT_RETURN(ret >= 0);
 
-       ret = kdbus_msg_recv_poll(conn_dst, 300, NULL, NULL);
-       ASSERT_RETURN(ret == parent_status);
+       ASSERT_RETURN(parent_status,==,kdbus_msg_recv_poll(conn_dst, 300, NULL, NULL));
 
        return 0;
 }
 
-static int test_policy_priv_by_broadcast(const char *bus,
+static wur int test_policy_priv_by_broadcast(const char *bus,
                                         struct kdbus_conn *conn_dst,
                                         int drop_second_user,
                                         int parent_status,
@@ -55,6 +52,12 @@ static int test_policy_priv_by_broadcast(const char *bus,
        struct kdbus_conn *child_2 = conn_dst;
        uint64_t expected_cookie = time(NULL) ^ 0xdeadbeef;
 
+#ifdef TIZEN
+       child_status = 0;
+       if (DO_NOT_DROP != drop_second_user)
+               parent_status = 0;
+#endif
+
        /* Drop to another unprivileged user other than UNPRIV_UID */
        if (drop_second_user == DROP_OTHER_UNPRIV) {
                second_uid = UNPRIV_UID - 1;
@@ -63,141 +66,112 @@ static int test_policy_priv_by_broadcast(const char *bus,
 
        /* child will signal parent to send broadcast */
        efd = eventfd(0, EFD_CLOEXEC);
-       ASSERT_RETURN_VAL(efd >= 0, efd);
+       ASSERT_RETURN_VAL(efd,>=,0, efd);
 
-       ret = RUN_UNPRIVILEGED(UNPRIV_UID, UNPRIV_GID, ({
+       RUN_UNPRIVILEGED(UNPRIV_UID, UNPRIV_GID, ({
                struct kdbus_conn *child;
 
-               child = kdbus_hello(bus, 0, NULL, 0);
-               ASSERT_EXIT(child);
+               ASSERT_EXIT_NONZERO(child = kdbus_hello(bus, 0, NULL, 0));
 
-               ret = kdbus_add_match_empty(child);
-               ASSERT_EXIT(ret == 0);
+               ASSERT_EXIT_ZERO(kdbus_add_match_empty(child));
 
                /* signal parent */
-               ret = eventfd_write(efd, 1);
-               ASSERT_EXIT(ret == 0);
+               ASSERT_EXIT_ZERO(eventfd_write(efd, 1));
 
                /* Use a little bit high time */
-               ret = kdbus_msg_recv_poll(child, 500, &msg, NULL);
-               ASSERT_EXIT(ret == child_status);
+               ASSERT_EXIT(child_status,==,kdbus_msg_recv_poll(child, 500, &msg, NULL));
 
                /*
                 * If we expect the child to get the broadcast
                 * message, then check the received cookie.
                 */
-               if (ret == 0) {
-                       ASSERT_EXIT(expected_cookie == msg->cookie);
+               if (!child_status) {
+                       ASSERT_EXIT(expected_cookie,==,msg->cookie);
+                       kdbus_msg_free(msg);
                }
 
                /* Use expected_cookie since 'msg' might be NULL */
-               ret = kdbus_msg_send(child, NULL, expected_cookie + 1,
-                                    0, 0, 0, KDBUS_DST_ID_BROADCAST,
-                                    0, NULL);
-               ASSERT_EXIT(ret == 0);
+               ASSERT_EXIT_ZERO(kdbus_msg_send(child, NULL, expected_cookie + 1, 0, 0, 0, KDBUS_DST_ID_BROADCAST));
 
-               kdbus_msg_free(msg);
                kdbus_conn_free(child);
        }),
        ({
-               if (drop_second_user == DO_NOT_DROP) {
-                       ASSERT_RETURN(child_2);
-
-                       ret = eventfd_read(efd, &event_status);
-                       ASSERT_RETURN(ret >= 0 && event_status == 1);
+               bool got_own_broadcast = 0;
+               #define RECEIVE_FROM_PARENT() for (;;) {\
+                       /* Use a little bit high time */\
+                       ret = kdbus_msg_recv_poll(child_2, 1000, &msg, NULL);\
+                       if (!ret && child_2->id == msg->src_id) {\
+                               ASSERT_ZERO(got_own_broadcast);\
+                               got_own_broadcast = 1;\
+                               kdbus_msg_free(msg);\
+                               continue;\
+                       }\
+                       ASSERT_RETURN(parent_status,==,ret);\
+                       /* Check returned cookie in case we expect success. */\
+                       if (!ret) {\
+                               ASSERT_RETURN(msg->cookie,==,expected_cookie + 1);\
+                               kdbus_msg_free(msg);\
+                       }\
+                       break;\
+               }
 
-                       ret = kdbus_msg_send(child_2, NULL,
-                                            expected_cookie, 0, 0, 0,
-                                            KDBUS_DST_ID_BROADCAST,
-                                            0, NULL);
-                       ASSERT_RETURN(ret == 0);
+               if (drop_second_user == DO_NOT_DROP) {
+                       ASSERT_NONZERO(child_2);
 
-                       /* Use a little bit high time */
-                       ret = kdbus_msg_recv_poll(child_2, 1000,
-                                                 &msg, NULL);
-                       ASSERT_RETURN(ret == parent_status);
+                       ASSERT_RETURN(0,<=,eventfd_read(efd, &event_status));
+                       ASSERT_RETURN(event_status,==,(eventfd_t)1);
 
-                       /*
-                        * Check returned cookie in case we expect
-                        * success.
-                        */
-                       if (ret == 0) {
-                               ASSERT_RETURN(msg->cookie ==
-                                             expected_cookie + 1);
-                       }
+                       ASSERT_ZERO(kdbus_msg_send(child_2, NULL, expected_cookie, 0, 0, 0, KDBUS_DST_ID_BROADCAST));
 
-                       kdbus_msg_free(msg);
+                       RECEIVE_FROM_PARENT();
                } else {
                        /*
                         * Two unprivileged users will try to
                         * communicate using broadcast.
                         */
-                       ret = RUN_UNPRIVILEGED(second_uid, second_gid, ({
-                               child_2 = kdbus_hello(bus, 0, NULL, 0);
-                               ASSERT_EXIT(child_2);
-
-                               ret = kdbus_add_match_empty(child_2);
-                               ASSERT_EXIT(ret == 0);
-
-                               ret = eventfd_read(efd, &event_status);
-                               ASSERT_EXIT(ret >= 0 && event_status == 1);
-
-                               ret = kdbus_msg_send(child_2, NULL,
-                                               expected_cookie, 0, 0, 0,
-                                               KDBUS_DST_ID_BROADCAST,
-                                               0, NULL);
-                               ASSERT_EXIT(ret == 0);
-
-                               /* Use a little bit high time */
-                               ret = kdbus_msg_recv_poll(child_2, 1000,
-                                                         &msg, NULL);
-                               ASSERT_EXIT(ret == parent_status);
-
-                               /*
-                                * Check returned cookie in case we expect
-                                * success.
-                                */
-                               if (ret == 0) {
-                                       ASSERT_EXIT(msg->cookie ==
-                                                   expected_cookie + 1);
-                               }
-
-                               kdbus_msg_free(msg);
+                       RUN_UNPRIVILEGED(second_uid, second_gid, ({
+                               ASSERT_EXIT_NONZERO(child_2 = kdbus_hello(bus, 0, NULL, 0));
+
+                               ASSERT_EXIT_ZERO(kdbus_add_match_empty(child_2));
+
+                               ASSERT_EXIT(0,<=,eventfd_read(efd, &event_status));
+                               ASSERT_EXIT(event_status,==,(eventfd_t)1);
+
+                               ASSERT_EXIT_ZERO(kdbus_msg_send(child_2, NULL, expected_cookie, 0, 0, 0, KDBUS_DST_ID_BROADCAST));
+
+                               RECEIVE_FROM_PARENT();
                                kdbus_conn_free(child_2);
                        }),
-                       ({ 0; }));
-                       ASSERT_RETURN(ret == 0);
+                       ({}));
                }
        }));
-       ASSERT_RETURN(ret == 0);
+#undef RECEIVE_FROM_PARENT
 
-       close(efd);
+       CLOSE(efd);
 
        return ret;
 }
 
 static void nosig(int sig)
 {
+       UNUSED(sig);
 }
 
-static int test_priv_before_policy_upload(struct kdbus_test_env *env)
+static wur int test_priv_before_policy_upload(struct kdbus_test_env *env)
 {
        int ret = 0;
        struct kdbus_conn *conn;
 
-       conn = kdbus_hello(env->buspath, 0, NULL, 0);
-       ASSERT_RETURN(conn);
+       ASSERT_NONZERO(conn = kdbus_hello(env->buspath, 0, NULL, 0));
 
        /*
         * Make sure unprivileged bus user cannot acquire names
-        * before registring any policy holder.
+        * before registering any policy holder.
         */
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.a", NULL);
-               ASSERT_EXIT(ret < 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT(0,ONTIZEN(==,>),kdbus_name_acquire(unpriv, "com.example.a", NULL));
        }));
-       ASSERT_RETURN(ret == 0);
 
        /*
         * Make sure unprivileged bus users cannot talk by default
@@ -205,27 +179,18 @@ static int test_priv_before_policy_upload(struct kdbus_test_env *env)
         * this was uploaded.
         */
 
-       ret = test_policy_priv_by_id(env->buspath, conn, false,
-                                    -ETIMEDOUT, -EPERM);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_id(env->buspath, conn, -ETIMEDOUT, -EPERM));
 
        /* Activate matching for a privileged connection */
-       ret = kdbus_add_match_empty(conn);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_add_match_empty(conn));
 
        /*
         * First make sure that BROADCAST with msg flag
         * KDBUS_MSG_EXPECT_REPLY will fail with -ENOTUNIQ
         */
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_msg_send(unpriv, NULL, 0xdeadbeef,
-                                    KDBUS_MSG_EXPECT_REPLY,
-                                    5000000000ULL, 0,
-                                    KDBUS_DST_ID_BROADCAST,
-                                    0, NULL);
-               ASSERT_EXIT(ret == -ENOTUNIQ);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT(-ENOTUNIQ,==,kdbus_msg_send(unpriv, NULL, 0xdeadbeef, KDBUS_MSG_EXPECT_REPLY, 5000000000ULL, 0, KDBUS_DST_ID_BROADCAST));
        }));
-       ASSERT_RETURN(ret == 0);
 
        /*
         * Test broadcast with a privileged connection.
@@ -243,10 +208,7 @@ static int test_priv_before_policy_upload(struct kdbus_test_env *env)
         * all connections it will receive those.
         */
 
-       ret = test_policy_priv_by_broadcast(env->buspath, conn,
-                                           DO_NOT_DROP,
-                                           0, -ETIMEDOUT);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_broadcast(env->buspath, conn, DO_NOT_DROP, 0, -ETIMEDOUT));
 
 
        /*
@@ -256,9 +218,7 @@ static int test_priv_before_policy_upload(struct kdbus_test_env *env)
         * Both connections should succeed.
         */
 
-       ret = test_policy_priv_by_broadcast(env->buspath, NULL,
-                                           DROP_SAME_UNPRIV, 0, 0);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_broadcast(env->buspath, NULL, DROP_SAME_UNPRIV, 0, 0));
 
        /*
         * Test broadcast with two unprivileged connections running
@@ -267,19 +227,15 @@ static int test_priv_before_policy_upload(struct kdbus_test_env *env)
         * Both connections will fail with -ETIMEDOUT.
         */
 
-       ret = test_policy_priv_by_broadcast(env->buspath, NULL,
-                                           DROP_OTHER_UNPRIV,
-                                           -ETIMEDOUT, -ETIMEDOUT);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_broadcast(env->buspath, NULL, DROP_OTHER_UNPRIV, -ETIMEDOUT, -ETIMEDOUT));
 
        kdbus_conn_free(conn);
 
        return ret;
 }
 
-static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
+static wur int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
 {
-       int ret;
        int efd;
        eventfd_t event_status = 0;
        struct kdbus_msg *msg = NULL;
@@ -288,11 +244,9 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
        struct kdbus_policy_access access = {};
        uint64_t expected_cookie = time(NULL) ^ 0xdeadbeef;
 
-       owner_a = kdbus_hello(env->buspath, 0, NULL, 0);
-       ASSERT_RETURN(owner_a);
+       ASSERT_NONZERO(owner_a = kdbus_hello(env->buspath, 0, NULL, 0));
 
-       ret = kdbus_name_acquire(owner_a, "com.example.broadcastA", NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT_ZERO(kdbus_name_acquire(owner_a, "com.example.broadcastA", NULL));
 
        /*
         * Make sure unprivileged bus users cannot talk by default
@@ -301,9 +255,7 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
         */
 
        ++expected_cookie;
-       ret = test_policy_priv_by_id(env->buspath, owner_a, false,
-                                    -ETIMEDOUT, -EPERM);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_id(env->buspath, owner_a, -ETIMEDOUT, -EPERM));
 
        /*
         * Make sure that privileged won't receive broadcasts unless
@@ -316,15 +268,10 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
         * registered so we fail by default), thus the unprivileged
         * receiver is not able to TALK to that name.
         */
-
-       ret = test_policy_priv_by_broadcast(env->buspath, owner_a,
-                                           DO_NOT_DROP,
-                                           -ETIMEDOUT, -ETIMEDOUT);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_broadcast(env->buspath, owner_a, DO_NOT_DROP, -ETIMEDOUT, -ETIMEDOUT));
 
        /* Activate matching for a privileged connection */
-       ret = kdbus_add_match_empty(owner_a);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_add_match_empty(owner_a));
 
        /*
         * Redo the previous test. The privileged conn owner_a is
@@ -332,19 +279,14 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
         * broadcast message now.
         */
 
-       ret = test_policy_priv_by_broadcast(env->buspath, owner_a,
-                                           DO_NOT_DROP,
-                                           0, -ETIMEDOUT);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_broadcast(env->buspath, owner_a, DO_NOT_DROP, 0, -ETIMEDOUT));
 
        /*
         * Test that broadcast between two unprivileged users running
         * under the same user still succeed.
         */
 
-       ret = test_policy_priv_by_broadcast(env->buspath, NULL,
-                                           DROP_SAME_UNPRIV, 0, 0);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_broadcast(env->buspath, NULL, DROP_SAME_UNPRIV, 0, 0));
 
        /*
         * Test broadcast with two unprivileged connections running
@@ -353,10 +295,7 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
         * Both connections will fail with -ETIMEDOUT.
         */
 
-       ret = test_policy_priv_by_broadcast(env->buspath, NULL,
-                                           DROP_OTHER_UNPRIV,
-                                           -ETIMEDOUT, -ETIMEDOUT);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_broadcast(env->buspath, NULL, DROP_OTHER_UNPRIV, -ETIMEDOUT, -ETIMEDOUT));
 
        access = (struct kdbus_policy_access){
                .type = KDBUS_POLICY_ACCESS_USER,
@@ -364,40 +303,25 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_OWN,
        };
 
-       holder_a = kdbus_hello_registrar(env->buspath,
-                                        "com.example.broadcastA",
-                                        &access, 1,
-                                        KDBUS_HELLO_POLICY_HOLDER);
-       ASSERT_RETURN(holder_a);
-
-       holder_b = kdbus_hello_registrar(env->buspath,
-                                        "com.example.broadcastB",
-                                        &access, 1,
-                                        KDBUS_HELLO_POLICY_HOLDER);
-       ASSERT_RETURN(holder_b);
+       ASSERT_NONZERO(holder_a = kdbus_hello_registrar(env->buspath, "com.example.broadcastA", &access, 1, KDBUS_HELLO_POLICY_HOLDER));
+       ASSERT_NONZERO(holder_b = kdbus_hello_registrar(env->buspath, "com.example.broadcastB", &access, 1, KDBUS_HELLO_POLICY_HOLDER));
 
        /* Free connections and their received messages and restart */
        kdbus_conn_free(owner_a);
 
-       owner_a = kdbus_hello(env->buspath, 0, NULL, 0);
-       ASSERT_RETURN(owner_a);
+       ASSERT_NONZERO(owner_a = kdbus_hello(env->buspath, 0, NULL, 0));
 
        /* Activate matching for a privileged connection */
-       ret = kdbus_add_match_empty(owner_a);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_add_match_empty(owner_a));
 
-       ret = kdbus_name_acquire(owner_a, "com.example.broadcastA", NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT_ZERO(kdbus_name_acquire(owner_a, "com.example.broadcastA", NULL));
 
-       owner_b = kdbus_hello(env->buspath, 0, NULL, 0);
-       ASSERT_RETURN(owner_b);
+       ASSERT_NONZERO(owner_b = kdbus_hello(env->buspath, 0, NULL, 0));
 
-       ret = kdbus_name_acquire(owner_b, "com.example.broadcastB", NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT_ZERO(kdbus_name_acquire(owner_b, "com.example.broadcastB", NULL));
 
        /* Activate matching for a privileged connection */
-       ret = kdbus_add_match_empty(owner_b);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_add_match_empty(owner_b));
 
        /*
         * Test that even if "com.example.broadcastA" and
@@ -408,23 +332,23 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
         */
 
        ++expected_cookie;
-       ret = kdbus_msg_send(owner_a, NULL, expected_cookie, 0,
-                            0, 0, KDBUS_DST_ID_BROADCAST, 0, NULL);
-       ASSERT_RETURN(ret == 0);
-
-       ret = kdbus_msg_recv_poll(owner_b, 100, &msg, NULL);
-       ASSERT_RETURN(ret == 0);
-       ASSERT_RETURN(msg->cookie == expected_cookie);
+       ASSERT_ZERO(kdbus_msg_send(owner_a, NULL, expected_cookie, 0, 0, 0, KDBUS_DST_ID_BROADCAST));
 
+       ASSERT_ZERO(kdbus_msg_recv_poll(owner_b, 100, &msg, NULL));
+       ASSERT_RETURN(msg->cookie,==,expected_cookie);
        /* Check src ID */
-       ASSERT_RETURN(msg->src_id == owner_a->id);
-
+       ASSERT_RETURN(msg->src_id,==,owner_a->id);
        kdbus_msg_free(msg);
 
+       /* purge self-broadcast */
+       ASSERT_ZERO(kdbus_msg_recv_poll(owner_a, 100, &msg, NULL));
+       ASSERT_RETURN(msg->cookie,==,expected_cookie);
+       /* Check src ID */
+       ASSERT_RETURN(msg->src_id,==,owner_a->id);
+
        /* Release name "com.example.broadcastB" */
 
-       ret = kdbus_name_release(owner_b, "com.example.broadcastB");
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT_ZERO(kdbus_name_release(owner_b, "com.example.broadcastB"));
 
        /* KDBUS_POLICY_OWN for unprivileged connections */
        access = (struct kdbus_policy_access){
@@ -435,10 +359,7 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
 
        /* Update the policy so unprivileged will own the name */
 
-       ret = kdbus_conn_update_policy(holder_b,
-                                      "com.example.broadcastB",
-                                      &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(holder_b, "com.example.broadcastB", &access, 1));
 
        /*
         * Send broadcasts from an unprivileged connection that
@@ -469,72 +390,55 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
 
        ++expected_cookie;
        efd = eventfd(0, EFD_CLOEXEC);
-       ASSERT_RETURN_VAL(efd >= 0, efd);
+       ASSERT_RETURN_VAL(efd,>=,0, efd);
 
-       ret = RUN_UNPRIVILEGED(UNPRIV_UID, UNPRIV_UID, ({
+       RUN_UNPRIVILEGED(UNPRIV_UID, UNPRIV_UID, ({
                struct kdbus_conn *unpriv_owner;
                struct kdbus_conn *unpriv_a, *unpriv_b;
 
-               unpriv_owner = kdbus_hello(env->buspath, 0, NULL, 0);
-               ASSERT_EXIT(unpriv_owner);
-
-               unpriv_a = kdbus_hello(env->buspath, 0, NULL, 0);
-               ASSERT_EXIT(unpriv_a);
+               ASSERT_EXIT_NONZERO(unpriv_owner = kdbus_hello(env->buspath, 0, NULL, 0));
+               ASSERT_EXIT_NONZERO(unpriv_a = kdbus_hello(env->buspath, 0, NULL, 0));
+               ASSERT_EXIT_NONZERO(unpriv_b = kdbus_hello(env->buspath, 0, NULL, 0));
 
-               unpriv_b = kdbus_hello(env->buspath, 0, NULL, 0);
-               ASSERT_EXIT(unpriv_b);
+               ASSERT_EXIT_ZERO(kdbus_name_acquire(unpriv_owner, "com.example.broadcastB", NULL));
 
-               ret = kdbus_name_acquire(unpriv_owner,
-                                        "com.example.broadcastB",
-                                        NULL);
-               ASSERT_EXIT(ret >= 0);
-
-               ret = kdbus_add_match_empty(unpriv_a);
-               ASSERT_EXIT(ret == 0);
+               ASSERT_EXIT_ZERO(kdbus_add_match_empty(unpriv_a));
 
                /* Signal that we are doing broadcasts */
-               ret = eventfd_write(efd, 1);
-               ASSERT_EXIT(ret == 0);
+               ASSERT_EXIT_ZERO(eventfd_write(efd, 1));
 
                /*
                 * Do broadcast from a connection that owns the
                 * names "com.example.broadcastB".
                 */
-               ret = kdbus_msg_send(unpriv_owner, NULL,
-                                    expected_cookie,
-                                    0, 0, 0,
-                                    KDBUS_DST_ID_BROADCAST,
-                                    0, NULL);
-               ASSERT_EXIT(ret == 0);
+               ASSERT_EXIT_ZERO(kdbus_msg_send(unpriv_owner, NULL, expected_cookie, 0, 0, 0, KDBUS_DST_ID_BROADCAST));
 
                /*
                 * Unprivileged connection running under the same
                 * user. It should succeed.
                 */
-               ret = kdbus_msg_recv_poll(unpriv_a, 300, &msg, NULL);
-               ASSERT_EXIT(ret == 0 && msg->cookie == expected_cookie);
+               ASSERT_EXIT_ZERO(kdbus_msg_recv_poll(unpriv_a, 300, &msg, NULL));
+               ASSERT_EXIT(msg->cookie,==,expected_cookie);
 
                /*
                 * Did not install matches, not interested in
                 * broadcasts
                 */
-               ret = kdbus_msg_recv_poll(unpriv_b, 300, NULL, NULL);
-               ASSERT_EXIT(ret == -ETIMEDOUT);
+               ASSERT_EXIT(-ETIMEDOUT,==,kdbus_msg_recv_poll(unpriv_b, 300, NULL, NULL));
        }),
        ({
-               ret = eventfd_read(efd, &event_status);
-               ASSERT_RETURN(ret >= 0 && event_status == 1);
+               ASSERT_RETURN(0,<=,eventfd_read(efd, &event_status));
+               ASSERT_RETURN(event_status,==,(eventfd_t)1);
 
                /*
                 * owner_a must fail with -ETIMEDOUT, since it owns
                 * name "com.example.broadcastA" and its TALK
                 * access is restriced.
                 */
-               ret = kdbus_msg_recv_poll(owner_a, 300, &msg, NULL);
-               ASSERT_RETURN(ret == 0);
+               ASSERT_ZERO(kdbus_msg_recv_poll(owner_a, 300, &msg, NULL));
 
                /* confirm the received cookie */
-               ASSERT_RETURN(msg->cookie == expected_cookie);
+               ASSERT_RETURN(msg->cookie,==,expected_cookie);
 
                kdbus_msg_free(msg);
 
@@ -542,18 +446,16 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
                 * owner_b got the broadcast from an unprivileged
                 * connection.
                 */
-               ret = kdbus_msg_recv_poll(owner_b, 300, &msg, NULL);
-               ASSERT_RETURN(ret == 0);
+               ASSERT_ZERO(kdbus_msg_recv_poll(owner_b, 300, &msg, NULL));
 
                /* confirm the received cookie */
-               ASSERT_RETURN(msg->cookie == expected_cookie);
+               ASSERT_RETURN(msg->cookie,==,expected_cookie);
 
                kdbus_msg_free(msg);
 
        }));
-       ASSERT_RETURN(ret == 0);
 
-       close(efd);
+       CLOSE(efd);
 
        /*
         * Test broadcast with two unprivileged connections running
@@ -562,25 +464,18 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
         * Both connections will fail with -ETIMEDOUT.
         */
 
-       ret = test_policy_priv_by_broadcast(env->buspath, NULL,
-                                           DROP_OTHER_UNPRIV,
-                                           -ETIMEDOUT, -ETIMEDOUT);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_broadcast(env->buspath, NULL, DROP_OTHER_UNPRIV, -ETIMEDOUT, -ETIMEDOUT));
 
        /* Drop received broadcasts by privileged */
-       ret = kdbus_msg_recv_poll(owner_a, 100, NULL, NULL);
-       ret = kdbus_msg_recv_poll(owner_a, 100, NULL, NULL);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_msg_recv_poll(owner_a, 100, NULL, NULL));
+       ASSERT_ZERO(kdbus_msg_recv_poll(owner_a, 100, NULL, NULL));
 
-       ret = kdbus_msg_recv(owner_a, NULL, NULL);
-       ASSERT_RETURN(ret == -EAGAIN);
+       ASSERT_RETURN(-EAGAIN,==,kdbus_msg_recv(owner_a, NULL, NULL));
 
-       ret = kdbus_msg_recv_poll(owner_b, 100, NULL, NULL);
-       ret = kdbus_msg_recv_poll(owner_b, 100, NULL, NULL);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_msg_recv_poll(owner_b, 100, NULL, NULL));
+       ASSERT_ZERO(kdbus_msg_recv_poll(owner_b, 100, NULL, NULL));
 
-       ret = kdbus_msg_recv(owner_b, NULL, NULL);
-       ASSERT_RETURN(ret == -EAGAIN);
+       ASSERT_RETURN(-EAGAIN,==,kdbus_msg_recv(owner_b, NULL, NULL));
 
        /*
         * Perform last tests, allow others to talk to name
@@ -595,36 +490,25 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_TALK,
        };
 
-       ret = kdbus_conn_update_policy(holder_a,
-                                      "com.example.broadcastA",
-                                      &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(holder_a, "com.example.broadcastA", &access, 1));
 
        /*
         * Unprivileged is able to TALK to "com.example.broadcastA"
         * now so it will receive its broadcasts
         */
-       ret = test_policy_priv_by_broadcast(env->buspath, owner_a,
-                                           DO_NOT_DROP, 0, 0);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_policy_priv_by_broadcast(env->buspath, owner_a, DO_NOT_DROP, 0, 0));
 
        ++expected_cookie;
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.broadcastB",
-                                        NULL);
-               ASSERT_EXIT(ret >= 0);
-               ret = kdbus_msg_send(unpriv, NULL, expected_cookie,
-                                    0, 0, 0, KDBUS_DST_ID_BROADCAST, 0, NULL);
-               ASSERT_EXIT(ret == 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_name_acquire(unpriv, "com.example.broadcastB", NULL));
+               ASSERT_EXIT_ZERO(kdbus_msg_send(unpriv, NULL, expected_cookie, 0, 0, 0, KDBUS_DST_ID_BROADCAST));
        }));
-       ASSERT_RETURN(ret == 0);
 
        /* owner_a is privileged it will get the broadcast now. */
-       ret = kdbus_msg_recv_poll(owner_a, 300, &msg, NULL);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_msg_recv_poll(owner_a, 300, &msg, NULL));
 
        /* confirm the received cookie */
-       ASSERT_RETURN(msg->cookie == expected_cookie);
+       ASSERT_RETURN(msg->cookie,==,expected_cookie);
 
        kdbus_msg_free(msg);
 
@@ -637,26 +521,19 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
         * signal to the privileged connection.
         */
 
-       ret = kdbus_name_release(owner_a, "com.example.broadcastA");
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT_ZERO(kdbus_name_release(owner_a, "com.example.broadcastA"));
 
        ++expected_cookie;
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.broadcastB",
-                                        NULL);
-               ASSERT_EXIT(ret >= 0);
-               ret = kdbus_msg_send(unpriv, NULL, expected_cookie,
-                                    0, 0, 0, KDBUS_DST_ID_BROADCAST, 0, NULL);
-               ASSERT_EXIT(ret == 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_name_acquire(unpriv, "com.example.broadcastB", NULL));
+               ASSERT_EXIT_ZERO(kdbus_msg_send(unpriv, NULL, expected_cookie, 0, 0, 0, KDBUS_DST_ID_BROADCAST));
        }));
-       ASSERT_RETURN(ret == 0);
 
        /* owner_a will get the broadcast now. */
-       ret = kdbus_msg_recv_poll(owner_a, 300, &msg, NULL);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_msg_recv_poll(owner_a, 300, &msg, NULL));
 
        /* confirm the received cookie */
-       ASSERT_RETURN(msg->cookie == expected_cookie);
+       ASSERT_RETURN(msg->cookie,==,expected_cookie);
 
        kdbus_msg_free(msg);
 
@@ -668,7 +545,7 @@ static int test_broadcast_after_policy_upload(struct kdbus_test_env *env)
        return 0;
 }
 
-static int test_policy_priv(struct kdbus_test_env *env)
+static wur int test_policy_priv(struct kdbus_test_env *env)
 {
        struct kdbus_conn *conn_a, *conn_b, *conn, *owner;
        struct kdbus_policy_access access, *acc;
@@ -681,7 +558,7 @@ static int test_policy_priv(struct kdbus_test_env *env)
         */
 
        ret = test_is_capable(CAP_SETUID, CAP_SETGID, -1);
-       ASSERT_RETURN(ret >= 0);
+       ASSERT_RETURN(ret,>=,0);
 
        if (!ret)
                return TEST_SKIP;
@@ -701,8 +578,7 @@ static int test_policy_priv(struct kdbus_test_env *env)
        sigaddset(&sset, SIGUSR1);
        sigprocmask(SIG_BLOCK, &sset, NULL);
 
-       conn = kdbus_hello(env->buspath, 0, NULL, 0);
-       ASSERT_RETURN(conn);
+       ASSERT_NONZERO(conn = kdbus_hello(env->buspath, 0, NULL, 0));
 
        /*
         * Before registering any policy holder, make sure that the
@@ -710,43 +586,36 @@ static int test_policy_priv(struct kdbus_test_env *env)
         * several cases where old D-Bus was vulnerable.
         */
 
-       ret = test_priv_before_policy_upload(env);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_priv_before_policy_upload(env));
 
        /*
         * Make sure unprivileged are not able to register policy
         * holders
         */
 
-       ret = RUN_UNPRIVILEGED(UNPRIV_UID, UNPRIV_GID, ({
+       RUN_UNPRIVILEGED(UNPRIV_UID, UNPRIV_GID, ({
                struct kdbus_conn *holder;
 
                holder = kdbus_hello_registrar(env->buspath,
                                               "com.example.a", NULL, 0,
                                               KDBUS_HELLO_POLICY_HOLDER);
-               ASSERT_EXIT(holder == NULL && errno == EPERM);
+               ASSERT_EXIT(errno,==,EPERM);
+               ASSERT_ZERO(holder);
        }),
-       ({ 0; }));
-       ASSERT_RETURN(ret == 0);
+       ({}));
 
 
        /* Register policy holder */
 
-       conn_a = kdbus_hello_registrar(env->buspath, "com.example.a",
-                                      NULL, 0, KDBUS_HELLO_POLICY_HOLDER);
-       ASSERT_RETURN(conn_a);
-
-       conn_b = kdbus_hello(env->buspath, 0, NULL, 0);
-       ASSERT_RETURN(conn_b);
+       ASSERT_NONZERO(conn_a = kdbus_hello_registrar(env->buspath, "com.example.a", NULL, 0, KDBUS_HELLO_POLICY_HOLDER));
+       ASSERT_NONZERO(conn_b = kdbus_hello(env->buspath, 0, NULL, 0));
 
-       ret = kdbus_name_acquire(conn_b, "com.example.b", NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT_ZERO(kdbus_name_acquire(conn_b, "com.example.b", NULL));
 
        /*
         * Make sure bus-owners can always acquire names.
         */
-       ret = kdbus_name_acquire(conn, "com.example.a", NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT_ZERO(kdbus_name_acquire(conn, "com.example.a", NULL));
 
        kdbus_conn_free(conn);
 
@@ -755,11 +624,9 @@ static int test_policy_priv(struct kdbus_test_env *env)
         * policy assigned.
         */
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.a", NULL);
-               ASSERT_EXIT(ret < 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT(0,ONTIZEN(==,!=),kdbus_name_acquire(unpriv, "com.example.a", NULL));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        /*
         * Make sure unprivileged users can acquire names if we make them
@@ -777,21 +644,15 @@ static int test_policy_priv(struct kdbus_test_env *env)
         * to update policies
         */
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_conn_update_policy(unpriv, "com.example.a",
-                                              &access, 1);
-               ASSERT_EXIT(ret == -EOPNOTSUPP);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT(-EOPNOTSUPP,==,kdbus_conn_update_policy(unpriv, "com.example.a", &access, 1));
        }));
-       ASSERT_RETURN(ret == 0);
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.a", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.a", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.a", NULL);
-               ASSERT_EXIT(ret >= 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_name_acquire(unpriv, "com.example.a", NULL));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        /*
         * Make sure unprivileged users can acquire names if we make them
@@ -804,14 +665,11 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_OWN,
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.a", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.a", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.a", NULL);
-               ASSERT_EXIT(ret >= 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_name_acquire(unpriv, "com.example.a", NULL));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        access = (struct kdbus_policy_access){
                .type = KDBUS_POLICY_ACCESS_GROUP,
@@ -819,14 +677,11 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_OWN,
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.a", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.a", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.a", NULL);
-               ASSERT_EXIT(ret < 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT(0,ONTIZEN(==,!=),kdbus_name_acquire(unpriv, "com.example.a", NULL));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        /*
         * Make sure unprivileged users can acquire names if we make them
@@ -839,14 +694,11 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_OWN,
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.a", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.a", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.a", NULL);
-               ASSERT_EXIT(ret >= 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_name_acquire(unpriv, "com.example.a", NULL));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        access = (struct kdbus_policy_access){
                .type = KDBUS_POLICY_ACCESS_USER,
@@ -854,14 +706,11 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_OWN,
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.a", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.a", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.a", NULL);
-               ASSERT_EXIT(ret < 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT(0,ONTIZEN(==,!=),kdbus_name_acquire(unpriv, "com.example.a", NULL));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        /*
         * Make sure unprivileged users cannot acquire names if no owner-policy
@@ -892,14 +741,11 @@ static int test_policy_priv(struct kdbus_test_env *env)
                },
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.a", acc, num);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.a", acc, num));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.a", NULL);
-               ASSERT_EXIT(ret < 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT(0,ONTIZEN(==,!=),kdbus_name_acquire(unpriv, "com.example.a", NULL));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        /*
         * Make sure unprivileged users can acquire names if the only matching
@@ -935,35 +781,27 @@ static int test_policy_priv(struct kdbus_test_env *env)
                },
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.a", acc, num);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.a", acc, num));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_name_acquire(unpriv, "com.example.a", NULL);
-               ASSERT_EXIT(ret >= 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_name_acquire(unpriv, "com.example.a", NULL));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        /*
         * Clear policies
         */
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.a", NULL, 0);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.a", NULL, 0));
 
        /*
         * Make sure privileged bus users can _always_ talk to others.
         */
 
-       conn = kdbus_hello(env->buspath, 0, NULL, 0);
-       ASSERT_RETURN(conn);
+       ASSERT_NONZERO(conn = kdbus_hello(env->buspath, 0, NULL, 0));
 
-       ret = kdbus_msg_send(conn, "com.example.b", 0xdeadbeef, 0, 0, 0, 0,
-                            0, NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT_ZERO(kdbus_msg_send(conn, "com.example.b", 0xdeadbeef, 0, 0, 0, 0));
 
-       ret = kdbus_msg_recv_poll(conn_b, 300, NULL, NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT(0,<=,kdbus_msg_recv_poll(conn_b, 300, NULL, NULL));
 
        kdbus_conn_free(conn);
 
@@ -971,12 +809,9 @@ static int test_policy_priv(struct kdbus_test_env *env)
         * Make sure unprivileged bus users cannot talk by default.
         */
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret == -EPERM);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT(ONTIZEN(0,-EPERM),==,kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0, 0, 0));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        /*
         * Make sure unprivileged bus users can talk to equals, even without
@@ -989,27 +824,20 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_OWN,
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.c", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.c", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
                struct kdbus_conn *owner;
 
-               owner = kdbus_hello(env->buspath, 0, NULL, 0);
-               ASSERT_RETURN(owner);
+               ASSERT_NONZERO(owner = kdbus_hello(env->buspath, 0, NULL, 0));
 
-               ret = kdbus_name_acquire(owner, "com.example.c", NULL);
-               ASSERT_EXIT(ret >= 0);
+               ASSERT_EXIT_ZERO(kdbus_name_acquire(owner, "com.example.c", NULL));
 
-               ret = kdbus_msg_send(unpriv, "com.example.c", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret >= 0);
-               ret = kdbus_msg_recv_poll(owner, 100, NULL, NULL);
-               ASSERT_EXIT(ret >= 0);
+               ASSERT_ZERO(kdbus_msg_send(unpriv, "com.example.c", 0xdeadbeef, 0, 0, 0, 0));
+               ASSERT_EXIT(0,<=,kdbus_msg_recv_poll(owner, 100, NULL, NULL));
 
                kdbus_conn_free(owner);
        }));
-       ASSERT_RETURN(ret >= 0);
 
        /*
         * Make sure unprivileged bus users can talk to privileged users if a
@@ -1022,18 +850,13 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_TALK,
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.b", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.b", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret >= 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0, 0, 0));
        }));
-       ASSERT_RETURN(ret >= 0);
 
-       ret = kdbus_msg_recv_poll(conn_b, 100, NULL, NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT(0,<=,kdbus_msg_recv_poll(conn_b, 100, NULL, NULL));
 
        /*
         * Make sure unprivileged bus users can talk to privileged users if a
@@ -1046,18 +869,13 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_TALK,
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.b", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.b", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret >= 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0, 0, 0));
        }));
-       ASSERT_RETURN(ret >= 0);
 
-       ret = kdbus_msg_recv_poll(conn_b, 100, NULL, NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT(0,<=,kdbus_msg_recv_poll(conn_b, 100, NULL, NULL));
 
        /*
         * Make sure unprivileged bus users can talk to privileged users if a
@@ -1070,18 +888,13 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_TALK,
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.b", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.b", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret >= 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0, 0, 0));
        }));
-       ASSERT_RETURN(ret >= 0);
 
-       ret = kdbus_msg_recv_poll(conn_b, 100, NULL, NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT(0,<=,kdbus_msg_recv_poll(conn_b, 100, NULL, NULL));
 
        /*
         * Make sure unprivileged bus users cannot talk to privileged users if
@@ -1117,15 +930,11 @@ static int test_policy_priv(struct kdbus_test_env *env)
                },
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.b", acc, num);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.b", acc, num));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret == -EPERM);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT(ONTIZEN(0,-EPERM),==,kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0, 0, 0));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        /*
         * Make sure unprivileged bus users can talk to privileged users if a
@@ -1138,18 +947,13 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_OWN,
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.b", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.b", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret >= 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0, 0, 0));
        }));
-       ASSERT_RETURN(ret >= 0);
 
-       ret = kdbus_msg_recv_poll(conn_b, 100, NULL, NULL);
-       ASSERT_EXIT(ret >= 0);
+       ASSERT_EXIT(0,<=,kdbus_msg_recv_poll(conn_b, 100, NULL, NULL));
 
        /*
         * Make sure the TALK cache is reset correctly when policies are
@@ -1162,26 +966,17 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_TALK,
        };
 
-       ret = kdbus_conn_update_policy(conn_a, "com.example.b", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.b", &access, 1));
 
-       ret = RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
-               ret = kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret >= 0);
+       RUN_UNPRIVILEGED_CONN(unpriv, env->buspath, ({
+               ASSERT_EXIT_ZERO(kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0, 0, 0));
 
-               ret = kdbus_msg_recv_poll(conn_b, 100, NULL, NULL);
-               ASSERT_EXIT(ret >= 0);
+               ASSERT_EXIT(0,<=,kdbus_msg_recv_poll(conn_b, 100, NULL, NULL));
 
-               ret = kdbus_conn_update_policy(conn_a, "com.example.b",
-                                              NULL, 0);
-               ASSERT_RETURN(ret == 0);
+               ASSERT_ZERO(kdbus_conn_update_policy(conn_a, "com.example.b", NULL, 0));
 
-               ret = kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret == -EPERM);
+               ASSERT_EXIT(ONTIZEN(0,-EPERM),==,kdbus_msg_send(unpriv, "com.example.b", 0xdeadbeef, 0, 0, 0, 0));
        }));
-       ASSERT_RETURN(ret >= 0);
 
        /*
         * Make sure the TALK cache is reset correctly when policy holders
@@ -1194,43 +989,33 @@ static int test_policy_priv(struct kdbus_test_env *env)
                .access = KDBUS_POLICY_OWN,
        };
 
-       conn = kdbus_hello_registrar(env->buspath, "com.example.c",
-                                    NULL, 0, KDBUS_HELLO_POLICY_HOLDER);
-       ASSERT_RETURN(conn);
+       ASSERT_NONZERO(conn = kdbus_hello_registrar(env->buspath, "com.example.c", NULL, 0, KDBUS_HELLO_POLICY_HOLDER));
 
-       ret = kdbus_conn_update_policy(conn, "com.example.c", &access, 1);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(kdbus_conn_update_policy(conn, "com.example.c", &access, 1));
 
-       owner = kdbus_hello(env->buspath, 0, NULL, 0);
-       ASSERT_RETURN(owner);
+       ASSERT_NONZERO(owner = kdbus_hello(env->buspath, 0, NULL, 0));
 
-       ret = kdbus_name_acquire(owner, "com.example.c", NULL);
-       ASSERT_RETURN(ret >= 0);
+       ASSERT_ZERO(kdbus_name_acquire(owner, "com.example.c", NULL));
 
-       ret = RUN_UNPRIVILEGED(UNPRIV_UID, UNPRIV_GID, ({
+       RUN_UNPRIVILEGED(UNPRIV_UID, UNPRIV_GID, ({
                struct kdbus_conn *unpriv;
 
                /* wait for parent to be finished */
                sigemptyset(&sset);
                ret = sigsuspend(&sset);
-               ASSERT_RETURN(ret == -1 && errno == EINTR);
+               ASSERT_RETURN(errno,==,EINTR);
+               ASSERT_RETURN(ret,==,-1);
 
-               unpriv = kdbus_hello(env->buspath, 0, NULL, 0);
-               ASSERT_RETURN(unpriv);
+               ASSERT_NONZERO(unpriv = kdbus_hello(env->buspath, 0, NULL, 0));
 
-               ret = kdbus_msg_send(unpriv, "com.example.c", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret >= 0);
+               ASSERT_EXIT_ZERO(kdbus_msg_send(unpriv, "com.example.c", 0xdeadbeef, 0, 0, 0, 0));
 
-               ret = kdbus_msg_recv_poll(owner, 100, NULL, NULL);
-               ASSERT_EXIT(ret >= 0);
+               ASSERT_EXIT(0,<=,kdbus_msg_recv_poll(owner, 100, NULL, NULL));
 
                /* free policy holder */
                kdbus_conn_free(conn);
 
-               ret = kdbus_msg_send(unpriv, "com.example.c", 0xdeadbeef, 0, 0,
-                                    0, 0, 0, NULL);
-               ASSERT_EXIT(ret == -EPERM);
+               ASSERT_EXIT(ONTIZEN(0,-EPERM),==,kdbus_msg_send(unpriv, "com.example.c", 0xdeadbeef, 0, 0, 0, 0));
 
                kdbus_conn_free(unpriv);
        }), ({
@@ -1238,15 +1023,12 @@ static int test_policy_priv(struct kdbus_test_env *env)
                kdbus_conn_free(conn);
                kill(pid, SIGUSR1);
        }));
-       ASSERT_RETURN(ret >= 0);
-
 
        /*
         * The following tests are necessary.
         */
 
-       ret = test_broadcast_after_policy_upload(env);
-       ASSERT_RETURN(ret == 0);
+       ASSERT_ZERO(test_broadcast_after_policy_upload(env));
 
        kdbus_conn_free(owner);
 
@@ -1260,7 +1042,7 @@ static int test_policy_priv(struct kdbus_test_env *env)
        return TEST_OK;
 }
 
-int kdbus_test_policy_priv(struct kdbus_test_env *env)
+wur int kdbus_test_policy_priv(struct kdbus_test_env *env)
 {
        pid_t pid;
        int ret;