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);
/* 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);
}
#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)
{
#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];
}
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];
/* 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));
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];
/* 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));
* 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]);