From: Konrad Lipinski Date: Thu, 15 Sep 2016 06:58:16 +0000 (+0200) Subject: kdbus-test: fix test-endpoint for both TIZEN and non-TIZEN X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=803fa35a81510bf04807b0facdca3f6ebcb464ba;p=platform%2Fkernel%2Flinux-exynos.git kdbus-test: fix test-endpoint for both TIZEN and non-TIZEN --- diff --git a/tools/testing/selftests/kdbus/kdbus-util.h b/tools/testing/selftests/kdbus/kdbus-util.h index 444011814ee1..09c559aaa7a0 100644 --- a/tools/testing/selftests/kdbus/kdbus-util.h +++ b/tools/testing/selftests/kdbus/kdbus-util.h @@ -17,6 +17,11 @@ #include #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__ diff --git a/tools/testing/selftests/kdbus/test-endpoint.c b/tools/testing/selftests/kdbus/test-endpoint.c index 0a279bd45eb4..c71678ec0fa0 100644 --- a/tools/testing/selftests/kdbus/test-endpoint.c +++ b/tools/testing/selftests/kdbus/test-endpoint.c @@ -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, diff --git a/tools/testing/selftests/kdbus/test-message.c b/tools/testing/selftests/kdbus/test-message.c index 0cc8ad145163..236051c3c6ff 100644 --- a/tools/testing/selftests/kdbus/test-message.c +++ b/tools/testing/selftests/kdbus/test-message.c @@ -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)); diff --git a/tools/testing/selftests/kdbus/test-sync.c b/tools/testing/selftests/kdbus/test-sync.c index 7a37d3b3c746..265639eda194 100644 --- a/tools/testing/selftests/kdbus/test-sync.c +++ b/tools/testing/selftests/kdbus/test-sync.c @@ -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;