kdbus-test: misc refinements
authorKonrad Lipinski <konrad.l@samsung.com>
Tue, 29 Nov 2016 15:35:26 +0000 (16:35 +0100)
committerAdrian Szyndela <adrian.s@samsung.com>
Wed, 7 Aug 2019 14:42:17 +0000 (16:42 +0200)
packaging/kdbusTest.spec
tools/testing/selftests/kdbus/test-message.c
tools/testing/selftests/kdbus/test-timeout.c

index ef224aaafeeff8ad2358d47660b43ca76c79ceae..c1f4381b973031cc3ae6b2532b80e80f48be1baa 100644 (file)
@@ -1,5 +1,5 @@
 Name:           kdbusTest
-Summary:        kdbus tests
+Summary:        Kdbus tests
 License:        Apache-2.0
 Group:          Base/IPC
 Version:        0.0.1
index 4a7adf07c349989b58ae99c7a52807c8972e0d0a..aa12118e590c7d3b050ec72b777a3a3153ea335b 100644 (file)
@@ -313,7 +313,7 @@ wur int kdbus_test_activator_quota(struct kdbus_test_env *env)
 
        msg = (struct kdbus_msg *)(activator->buf + recv.msg.offset);
        ASSERT_RETURN(msg->src_id,==,sender->id);
-       ASSERT_RETURN(msg->dst_id,==,KDBUS_DST_ID_NAME);
+       ASSERT_RETURN(msg->dst_id,==,(typeof(msg->dst_id))KDBUS_DST_ID_NAME);
        --activator_msgs_count;
        kdbus_msg_free(msg);
 
@@ -358,7 +358,7 @@ wur int kdbus_test_activator_quota(struct kdbus_test_env *env)
        /* make sure that we got our previous activator msgs */
        ASSERT_ZERO(kdbus_msg_recv(activator, &msg, NULL));
        ASSERT_RETURN(msg->src_id,==,sender->id);
-       ASSERT_RETURN(msg->dst_id,==,KDBUS_DST_ID_NAME);
+       ASSERT_RETURN(msg->dst_id,==,(typeof(msg->dst_id))KDBUS_DST_ID_NAME);
        --activator_msgs_count;
        kdbus_msg_free(msg);
 
@@ -399,6 +399,7 @@ wur int kdbus_test_activator_quota(struct kdbus_test_env *env)
 }
 
 #define TIMEOUT_CONNECTION_COUNT 8
+#define TIMEOUTS_PER_CONNECTION (MIN(KDBUS_CONN_MAX_REQUESTS_PENDING,KDBUS_CONN_MAX_MSGS)/TIMEOUT_CONNECTION_COUNT)
 
 static wur int kdbus_test_expected_reply_validate_timeouts(struct kdbus_conn *conn, uint64_t first_cookie, uint64_t type)
 {
@@ -415,9 +416,8 @@ static wur int kdbus_test_expected_reply_validate_timeouts(struct kdbus_conn *co
                #undef A
                ASSERT_RETURN(first_cookie,<=,cookie_reply);
                cookie_reply -= first_cookie;
-               ASSERT_RETURN(cookie_reply,<,KDBUS_CONN_MAX_REQUESTS_PENDING);
-               n = cookie_reply / (KDBUS_CONN_MAX_REQUESTS_PENDING/TIMEOUT_CONNECTION_COUNT);
-               r = cookie_reply % (KDBUS_CONN_MAX_REQUESTS_PENDING/TIMEOUT_CONNECTION_COUNT);
+               n = cookie_reply % TIMEOUT_CONNECTION_COUNT;
+               r = cookie_reply / TIMEOUT_CONNECTION_COUNT;
                ASSERT_RETURN(r,==,next_cookie[n]);
                ++next_cookie[n];
        }
@@ -427,9 +427,8 @@ static wur int kdbus_test_expected_reply_validate_timeouts(struct kdbus_conn *co
 
 static wur int kdbus_test_expected_reply_timeouts_or_quota(struct kdbus_test_env *env)
 {
-       unsigned int i, n;
-       uint64_t cookie = 0x1234abcd5678eeff;
-       uint64_t first_cookie = cookie;
+       unsigned i, n;
+       uint64_t first_cookie = 0x1234abcd5678eeff;
        struct kdbus_conn *conn;
        struct kdbus_conn *connections[1+TIMEOUT_CONNECTION_COUNT];
 
@@ -442,8 +441,8 @@ static wur int kdbus_test_expected_reply_timeouts_or_quota(struct kdbus_test_env
 
        /* Send messages to TIMEOUT_CONNECTION_COUNT different connections */
        for (i = 0; i < TIMEOUT_CONNECTION_COUNT; i++)
-               for (n = 0; n < KDBUS_CONN_MAX_REQUESTS_PENDING/TIMEOUT_CONNECTION_COUNT; n++) {
-                       ASSERT_ZERO(kdbus_msg_send(conn, NULL, cookie++,
+               for (n = 0; n < TIMEOUTS_PER_CONNECTION; n++) {
+                       ASSERT_ZERO(kdbus_msg_send(conn, NULL, first_cookie + i + n*TIMEOUT_CONNECTION_COUNT,
                                             KDBUS_MSG_EXPECT_REPLY,
                                             200000000ULL /* 0.2s */, 0,
                                             connections[i]->id));
@@ -465,9 +464,8 @@ static wur int kdbus_test_expected_reply_timeouts_or_quota(struct kdbus_test_env
 
 static wur int kdbus_test_expected_reply_quota(struct kdbus_test_env *env)
 {
-       unsigned int i, n;
-       uint64_t cookie = 0x5678eeff1234abcd;
-       uint64_t first_cookie = cookie;
+       unsigned i, n;
+       uint64_t first_cookie = 0x5678eeff1234abcd;
        struct kdbus_conn *conn;
        struct kdbus_conn *connections[1+TIMEOUT_CONNECTION_COUNT];
 
@@ -479,7 +477,7 @@ static wur int kdbus_test_expected_reply_quota(struct kdbus_test_env *env)
        /* Send messages to TIMEOUT_CONNECTION_COUNT different connections */
        for (i = 0; i < TIMEOUT_CONNECTION_COUNT; i++)
                for (n = 0; n < KDBUS_CONN_MAX_REQUESTS_PENDING/TIMEOUT_CONNECTION_COUNT; n++) {
-                       ASSERT_ZERO(kdbus_msg_send(conn, NULL, cookie++,
+                       ASSERT_ZERO(kdbus_msg_send(conn, NULL, first_cookie + i + n*TIMEOUT_CONNECTION_COUNT,
                                             KDBUS_MSG_EXPECT_REPLY,
                                             KDBUS_TIMEOUT_INFINITE, 0, /* massive timeout to make sure all pending replies do not timeout before quota check below */
                                             connections[i]->id));
@@ -492,7 +490,7 @@ static wur int kdbus_test_expected_reply_quota(struct kdbus_test_env *env)
         * if we have reached KDBUS_CONN_MAX_REQUESTS_PENDING
         * no further requests are allowed
         */
-       ASSERT_RETURN(-EMLINK,==,kdbus_msg_send(conn, NULL, cookie++, KDBUS_MSG_EXPECT_REPLY, 1000000000ULL, 0, connections[TIMEOUT_CONNECTION_COUNT]->id));
+       ASSERT_RETURN(-EMLINK,==,kdbus_msg_send(conn, NULL, first_cookie + TIMEOUT_CONNECTION_COUNT*TIMEOUTS_PER_CONNECTION, KDBUS_MSG_EXPECT_REPLY, 1000000000ULL, 0, connections[TIMEOUT_CONNECTION_COUNT]->id));
 
        for (i = 0; i < 1+TIMEOUT_CONNECTION_COUNT; i++)
                kdbus_conn_free(connections[i]);
index da17bb1ae9f35b087d7802584731c6b97b4211c0..5e15dda7202484db7decd406270fee0237693374 100644 (file)
@@ -31,7 +31,7 @@ wur int timeout_msg_recv(struct kdbus_conn *conn, uint64_t type, uint64_t *cooki
        msg = (struct kdbus_msg *)(conn->buf + recv.msg.offset);
 
        ASSERT_RETURN_VAL(msg->payload_type,==,(typeof(msg->payload_type))KDBUS_PAYLOAD_KERNEL, -EINVAL);
-       ASSERT_RETURN_VAL(msg->src_id,==,KDBUS_SRC_ID_KERNEL, -EINVAL);
+       ASSERT_RETURN_VAL(msg->src_id,==,(typeof(msg->src_id))KDBUS_SRC_ID_KERNEL, -EINVAL);
        ASSERT_RETURN_VAL(msg->dst_id,==,conn->id, -EINVAL);
 
        {