Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934772AbbGHK0p (ORCPT ); Wed, 8 Jul 2015 06:26:45 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:47992 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934721AbbGHKZg (ORCPT ); Wed, 8 Jul 2015 06:25:36 -0400 X-AuditID: cbfec7f5-f794b6d000001495-26-559cfa9ea790 From: Paul Osmialowski To: Paul Moore , James Morris , Casey Schaufler , "Serge E. Hallyn" , Kees Cook , Tetsuo Handa , Stephen Smalley , Neil Brown , Mark Rustad , Greg Kroah-Hartman , Daniel Mack , David Herrmann , Djalal Harouni , Shuah Khan , Al Viro , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Cc: Karol Lewandowski , Paul Osmialowski , Lukasz Skalski Subject: [RFC 6/8] kdbus: TEST_CREATE_CONN now does no depend on TEST_CREATE_BUS Date: Wed, 08 Jul 2015 12:25:08 +0200 Message-id: <1436351110-5902-7-git-send-email-p.osmialowsk@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1436351110-5902-1-git-send-email-p.osmialowsk@samsung.com> References: <1436351110-5902-1-git-send-email-p.osmialowsk@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeLIzCtJLcpLzFFi42I5/e/4Vd15v+aEGizdpWdxb9svNoumv69Y LBZfFrNoXryezaLvcZBF46e5zBZnunMt5pxrZLLY/L2DzeLyrjlsFh96HrFZzHn7ls1i7/wG FosJbw4wW8xuecdq8fnaL3aLw7sXM1ucv3CO3WLqlw8sFit/b2ezOP/3OKuDqMfshossHk8n TGb3uLY70mPn2lVMHov3vGTy2D93DbvHil9H2D0+Pr3F4rGl/y67x/t9V9k8+rasYvQ4un8R m8fm09UeW6f/Z/X4vEnOY9OTt0wBglFcNimpOZllqUX6dglcGd+a7zEWXBCruPZyIVMD4x/B LkZODgkBE4nu6TNZIGwxiQv31rN1MXJxCAksZZT4da2XBcJpZJKYdvcfM0gVm4ChxM3/hxlB bBGBXawSb3bEgRQxC3QySszpOscEkhAWCJDY+2wdG4jNIqAqsefrB1YQm1fAXeLi17vMEOvk JE4emwwW5xTwkFj48itYXAioZuPqf2wTGHkXMDKsYhRNLU0uKE5KzzXSK07MLS7NS9dLzs/d xAiJpK87GJceszrEKMDBqMTD6xEzJ1SINbGsuDL3EKMEB7OSCO+uC0Ah3pTEyqrUovz4otKc 1OJDjNIcLErivDN3vQ8REkhPLEnNTk0tSC2CyTJxcEo1MKYUl9aeq7uak9ifLpWwOTKo6sLs fp2J56M9+g9Z7DRdsF9bXF1DZ+HMD+G33ZXP+76J0jiVFPyt8ufjtZ+X2lXGbUp3W1CVcXDe Hk3rqny36l1dk74wHnixSHbLpv3ps0TDTgpM27Xpl2LgGleh6zXvi3V+xi6f/aSWq2BRxbkZ /H+sJpbJ2SqxFGckGmoxFxUnAgBuTslNoAIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3050 Lines: 96 Without this patch, it is impossible to specify test case able to connect to a bus already created (e.g. by 'test-daemon' test case), you can only specify: 1) TEST_CREATE_BUS which creates new bus, or 2) TEST_CREATE_CONN OR'ed with TEST_CREATE_BUS which creates new bus and creates connection to it. This patch adds the missing ability to specify TEST_CREATE_CONN alone. It will be used by a new test case (will be added by separate commit) which is supposed to connect to already started test-daemon case. Signed-off-by: Paul Osmialowski --- tools/testing/selftests/kdbus/kdbus-test.c | 21 +++++++++++++++++++++ tools/testing/selftests/kdbus/kdbus-util.c | 18 +++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/kdbus/kdbus-test.c b/tools/testing/selftests/kdbus/kdbus-test.c index 294e82a..d3a656f 100644 --- a/tools/testing/selftests/kdbus/kdbus-test.c +++ b/tools/testing/selftests/kdbus/kdbus-test.c @@ -309,6 +309,27 @@ static int test_prepare_env(const struct kdbus_test *t, } if (t->flags & TEST_CREATE_CONN) { + if (!env->buspath) { + char *s = NULL; + char *n = NULL; + int ret; + + if (!args->busname) { + n = unique_name("test-bus"); + ASSERT_RETURN(n); + } + + ret = kdbus_create_bus(-1, + args->busname ?: n, + 0, + 0, &s); + free(n); + ASSERT_RETURN(ret == 0); + + asprintf(&env->buspath, "%s/%s/bus", args->root, s); + free(s); + } + ASSERT_RETURN(env->buspath); env->conn = kdbus_hello(env->buspath, 0, NULL, 0); ASSERT_RETURN(env->conn); } diff --git a/tools/testing/selftests/kdbus/kdbus-util.c b/tools/testing/selftests/kdbus/kdbus-util.c index 29a0cb1..26104ca 100644 --- a/tools/testing/selftests/kdbus/kdbus-util.c +++ b/tools/testing/selftests/kdbus/kdbus-util.c @@ -141,7 +141,7 @@ int kdbus_create_bus(int control_fd, const char *name, char str[64]; } name; } bus_make; - int ret; + int ret = 0; memset(&bus_make, 0, sizeof(bus_make)); bus_make.bp.size = sizeof(bus_make.bp); @@ -171,13 +171,17 @@ int kdbus_create_bus(int control_fd, const char *name, bus_make.attach[1].size + bus_make.name.size; - kdbus_printf("Creating bus with name >%s< on control fd %d ...\n", - name, control_fd); + if (control_fd != -1) { + kdbus_printf( + "Creating bus with name >%s< on control fd %d ...\n", + name, control_fd); - ret = kdbus_cmd_bus_make(control_fd, &bus_make.cmd); - if (ret < 0) { - kdbus_printf("--- error when making bus: %d (%m)\n", ret); - return ret; + ret = kdbus_cmd_bus_make(control_fd, &bus_make.cmd); + if (ret < 0) { + kdbus_printf("--- error when making bus: %d (%m)\n", + ret); + return ret; + } } if (ret == 0 && path) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/