test: decrease memfd_count by 1 because all fds take one item
authorSheng Yong <shyodx@gmail.com>
Wed, 21 Jan 2015 13:38:21 +0000 (21:38 +0800)
committerDjalal Harouni <tixxdz@opendz.org>
Wed, 21 Jan 2015 13:55:53 +0000 (14:55 +0100)
When test E2BIG using memfd_count, we should consider that all fds
will take one item. So the number of left item, which will trigger
E2BIG is (KDBUG_MSG_MAX_ITEMs - 1).

Signed-off-by: Sheng Yong <shyodx@gmail.com>
Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test/test-fd.c

index 261cfc8aee6bb28f0e2280383b1c7952831263c1..462be1dc7a3d7db8d6614f99677a1e3fd6eb640e 100644 (file)
@@ -544,10 +544,13 @@ static int kdbus_send_multiple_fds(struct kdbus_conn *conn_src,
                              memfds, 100);
        ASSERT_RETURN(ret == -EMFILE);
 
-       /* Combine multiple 253 fds and 128 + 1 memfds */
+       /*
+        * Combine multiple 253 fds and (128 - 1) + 1 memfds,
+        * all fds take one item, while each memfd takes one item
+        */
        ret = send_fds_memfds(conn_src, conn_dst->id,
                              fds, KDBUS_MSG_MAX_FDS,
-                             memfds, KDBUS_MSG_MAX_ITEMS + 1);
+                             memfds, (KDBUS_MSG_MAX_ITEMS - 1) + 1);
        ASSERT_RETURN(ret == -E2BIG);
 
        ret = send_fds_memfds(conn_src, conn_dst->id,