kdbus-test: fix test-endpoint for both TIZEN and non-TIZEN
authorKonrad Lipinski <konrad.l@samsung.com>
Thu, 15 Sep 2016 06:58:16 +0000 (08:58 +0200)
committerKonrad Lipinski <konrad.l@samsung.com>
Thu, 15 Sep 2016 06:58:16 +0000 (08:58 +0200)
tools/testing/selftests/kdbus/kdbus-util.h
tools/testing/selftests/kdbus/test-endpoint.c
tools/testing/selftests/kdbus/test-message.c
tools/testing/selftests/kdbus/test-sync.c

index 444011814ee166f73de5c7e384f381f0161a7d7b..09c559aaa7a011c3fc1ae38ac90c5ad45fea5640 100644 (file)
 #include <linux/kdbus.h>
 
 #define TIZEN /* backwards-incompatible tizen customizations */
+#ifdef TIZEN
+       #define ONTIZEN(TIZEN,NONTIZEN) TIZEN
+#else
+       #define ONTIZEN(TIZEN,NONTIZEN) NONTIZEN
+#endif
 
 /* c99 compat */
 #define typeof __typeof__
index 0a279bd45eb45f4f301a84459c445813d1fdfe67..c71678ec0fa089a3eeeb6a2a449fa59c16edec47 100644 (file)
@@ -136,7 +136,7 @@ static wur int unpriv_test_custom_ep(const char *buspath)
                 */
                ep_conn = kdbus_hello(ep1, 0, NULL, 0);
                ASSERT_EXIT(errno,==,EACCES);
-               ASSERT_EXIT_ZERO(!ep_conn);
+               ASSERT_EXIT_ZERO(ep_conn);
 
                /* Endpoint "apps2" world accessible */
                ASSERT_EXIT_NONZERO(ep_conn = kdbus_hello(ep2, 0, NULL, 0));
@@ -218,24 +218,18 @@ wur int kdbus_test_custom_endpoint(struct kdbus_test_env *env)
        ASSERT_RETURN(-EINVAL,==,create_endpoint(env->buspath, getuid() + 1, "foobar", 0));
 
        /* create a custom endpoint, and open a connection on it */
-       ep_fd = create_endpoint(env->buspath, getuid(), "foo", 0);
-       ASSERT_RETURN(ep_fd,>=,0);
+       ASSERT_RETURN(0,<=,ep_fd = create_endpoint(env->buspath, getuid(), "foo", 0));
 
        ASSERT_NONZERO(tmp = strdup(env->buspath));
-
-       ret = asprintf(&ep, "%s/%u-%s", dirname(tmp), getuid(), epname);
+       ASSERT_RETURN(0,<=,asprintf(&ep, "%s/%u-%s", dirname(tmp), getuid(), epname));
        free(tmp);
-       ASSERT_RETURN(ret,>=,0);
 
        /* Register a connection that listen to broadcasts */
-       reader = kdbus_hello(ep, 0, NULL, 0);
-       ASSERT_NONZERO(reader);
+       ASSERT_NONZERO(reader = kdbus_hello(ep, 0, NULL, 0));
 
        /* Register to kernel signals */
        ASSERT_ZERO(kdbus_add_match_id(reader, 0x1, KDBUS_ITEM_ID_ADD, KDBUS_MATCH_ID_ANY));
-
        ASSERT_ZERO(kdbus_add_match_id(reader, 0x2, KDBUS_ITEM_ID_REMOVE, KDBUS_MATCH_ID_ANY));
-
        ASSERT_ZERO(install_name_add_match(reader, name));
 
        /* Monitor connections are not supported on custom endpoints */
@@ -262,14 +256,14 @@ wur int kdbus_test_custom_endpoint(struct kdbus_test_env *env)
 
        ASSERT_ZERO(kdbus_name_acquire(env->conn, name, NULL));
 
-       ASSERT_RETURN(-EAGAIN,==,kdbus_msg_recv(ep_conn, NULL, NULL));
-       ASSERT_RETURN(-ESRCH,==,kdbus_conn_info(ep_conn, 0, name, 0, NULL));
+       ASSERT_RETURN(ONTIZEN(0,-EAGAIN),==,kdbus_msg_recv(ep_conn, NULL, NULL));
+       ASSERT_RETURN(ONTIZEN(0,-ESRCH),==,kdbus_conn_info(ep_conn, 0, name, 0, NULL));
        ASSERT_RETURN(-ESRCH,==,kdbus_conn_info(ep_conn, 0, "random.crappy.name", 0, NULL));
-       ASSERT_RETURN(-ENXIO,==,kdbus_conn_info(ep_conn, env->conn->id, NULL, 0, NULL));
+       ASSERT_RETURN(ONTIZEN(0,-ENXIO),==,kdbus_conn_info(ep_conn, env->conn->id, NULL, 0, NULL));
        ASSERT_RETURN(-ENXIO,==,kdbus_conn_info(ep_conn, 0x0fffffffffffffffULL, NULL, 0, NULL));
 
        /* Check that the reader did not receive the name notification */
-       ASSERT_RETURN(-EAGAIN,==,kdbus_msg_recv(reader, NULL, NULL));
+       ASSERT_RETURN(ONTIZEN(0,-EAGAIN),==,kdbus_msg_recv(reader, NULL, NULL));
 
        /*
         * Release the name again, update the custom endpoint policy,
index 0cc8ad145163cf5911f5b6e59057ff332790bf8c..236051c3c6ff16bd01982b86ec8e1a99746aba39 100644 (file)
@@ -62,13 +62,7 @@ wur int kdbus_test_message_basic(struct kdbus_test_env *env)
        ASSERT_RETURN(-EINVAL,==,kdbus_msg_send(sender, NULL, 0, KDBUS_MSG_EXPECT_REPLY, 0, 0, conn->id)); /* neither cookie nor timeout */
 
        /* Faked replies with a valid reply cookie are rejected iff not TIZEN */
-       ASSERT_RETURN(
-#ifdef TIZEN
-                       0,
-#else
-                       -EBADSLT,
-#endif
-               ==,kdbus_msg_send_reply(conn, time(NULL) ^ cookie, sender->id));
+       ASSERT_RETURN(ONTIZEN(0,-EBADSLT),==,kdbus_msg_send_reply(conn, time(NULL) ^ cookie, sender->id));
 
        ASSERT_ZERO(kdbus_free(conn, offset));
 
index 7a37d3b3c74675854e99392c068ca66ab46f6f43..265639eda194fa511b8a500bce8d5a9b512c6e18 100644 (file)
@@ -213,13 +213,7 @@ static void *run_thread_reply(void *data)
        kdbus_printf("Thread received message, sending reply ...\n");
 
        /* using an unknown cookie must fail iff not TIZEN */
-       if (
-#ifdef TIZEN
-               0
-#else
-               -EBADSLT
-#endif
-               != kdbus_msg_send_reply(conn_a, ~cookie, conn_b->id))
+       if (ONTIZEN(0,-EBADSLT) != kdbus_msg_send_reply(conn_a, ~cookie, conn_b->id))
        {
                status = TEST_ERR;
                goto exit_thread;