Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1214535pxb; Tue, 17 Aug 2021 06:35:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPtdiKQgwOvRsCrzbFPv3JM0Km8gACmAmKConLRutg3rjsgLwbRj5Mci7s6e2gjb9c14mx X-Received: by 2002:a17:907:1c08:: with SMTP id nc8mr4104582ejc.514.1629207353497; Tue, 17 Aug 2021 06:35:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629207353; cv=none; d=google.com; s=arc-20160816; b=PJzb5KW0CWwfKlzghMx1+adGcB8EhQlA7iCE8oSD/3S3PyY2YarT9xG5FSD2pTqPBO TrcEQzHFcl8QIiVS4vCsDJgZIFpl3Yi+jkwj2HvU0CDVSLzshqpX/MSmGqtktJBNbYa1 4e2aYLsUYFSxuArIPQMISKfeVcY6xarooN+5ltB4ABHEqSpr+pXKNYTtoPdtaRcksGBS 0m9GsfLWeTtpXjbndTdjHHg33P8O9LpaXD98dsnRF72GRPxUI72wPEJcf64Ej6pn+plm +NiQmskU6GflffszousR61JO5JOkFk2cHCCpplnxbvw5KA/1OrWnsM3kcPgCwz+H2hf6 6TwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/ZplN+DQNjy/fGTSwhmHuEQ65uOe/NIplIHGWhiFszo=; b=E+Y1BoodoqlivnGkdBjFGZTVGU1gZNIYj0hx0RptGMPlqMof6K3BLR8w+oP0XygVoE pPS3WkTK55ZSNxn0WDUapOcLru57IOr/jujAciIKDH3hLwmZToFgxwTZOMhmpcp2+gyw bq5R5yLvTVKKyD2YO7ucMU+U9go9LweGTjickwNuk7hvT75ifRxw6Ze3BuP2S1NBNjyC i6YZR+wz0Ax54sDcQKY6xUqVP6AUvrwsm+pROuLQmiUQMcnJFB9Eh8Kz1jzFQicQGRTZ 6fbvCZ909LgVGsLUfubKoed/6Qz8g+1f2OA5OQnpW2S74AB2xKQ18zTT4HqKul3iI8Jn om8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WvAyxJYI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 10si2242638ejt.595.2021.08.17.06.35.26; Tue, 17 Aug 2021 06:35:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WvAyxJYI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240269AbhHQNae (ORCPT + 99 others); Tue, 17 Aug 2021 09:30:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240054AbhHQN32 (ORCPT ); Tue, 17 Aug 2021 09:29:28 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85CA5C061764; Tue, 17 Aug 2021 06:28:55 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id 28-20020a17090a031cb0290178dcd8a4d1so2970554pje.0; Tue, 17 Aug 2021 06:28:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/ZplN+DQNjy/fGTSwhmHuEQ65uOe/NIplIHGWhiFszo=; b=WvAyxJYInJUFXJ4QJrYKlFxGPar8wHEk8GoKa4cC8pk2RwtyHr3CGvO6XZxVmGoATF HYRGTWOGBKO13ow5rCLeVZ0koRfaofZd7zL52nSKpjkTW+IohzOGz4rK8Ve+XcYnAuKj kkNc0LARPhlFloFzpTqHCyuYaAbr5pyEYv498KwHzj0HWix6zkI0pjyIASxWx+V/L2SI co7rqsKc/mA9uqikoyzo9aTipBKpbamxJLDKkFFLaS+VPi5seMCcQoA2pwuKu/wzqipR QVp4N6/eEiIU3PqtKEUoQiBSyDfsQl2Ml4Bm/ELhkgKq8Nrt0AOj4PYPxAB19ua1OVN5 W9IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/ZplN+DQNjy/fGTSwhmHuEQ65uOe/NIplIHGWhiFszo=; b=O5FfG2uY6Ymxq0rdesF4p8r8T//6pSQ+oMZ/C/99YpamQiP43uSgUTrwVaZfidyiFn hda20A7O/7RgO+MFo+Kj7XVF9p/VZoTQWKJoWTg0gFEoO2IYf2nDwJ6N2k0fU360HAiW u/EhhWYcDDu7GCzM2FP64fYLfM3CuAO7/RS9UEHipiXXMiGgqQXpO7aTu/4+mJyZ5Eh3 HbQkEy3JvD/GIjS6Zn9fMf0ifUbMHnhhIUWTGZpMbGxrGmEnmvmwrUk73tz2z+iZtAW1 +d7CjNQAyEbxZgzK77h2jbKYE4Xukb6OBNlA0TSKUE9XdXM6k/ktNQ35YX2KPW5vfLI9 S+og== X-Gm-Message-State: AOAM533awtyL1tZamX4CpPM9UUs+yusAuQFSt7qMLytHVx/kmA+Ic6jG IvOpWkWfmU9CbsjkpjsMC9xIh29xNjZw+g== X-Received: by 2002:a17:903:234e:b0:12d:ad8d:56c6 with SMTP id c14-20020a170903234e00b0012dad8d56c6mr2762205plh.23.1629206934900; Tue, 17 Aug 2021 06:28:54 -0700 (PDT) Received: from ubuntu.localdomain ([182.226.226.37]) by smtp.gmail.com with ESMTPSA id j6sm2791577pfi.220.2021.08.17.06.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 06:28:54 -0700 (PDT) From: bongsu.jeon2@gmail.com To: shuah@kernel.org, krzysztof.kozlowski@canonical.com Cc: netdev@vger.kernel.org, linux-nfc@lists.01.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Bongsu Jeon Subject: [PATCH v2 net-next 7/8] selftests: nci: Extract the start/stop discovery function Date: Tue, 17 Aug 2021 06:28:17 -0700 Message-Id: <20210817132818.8275-8-bongsu.jeon2@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210817132818.8275-1-bongsu.jeon2@gmail.com> References: <20210817132818.8275-1-bongsu.jeon2@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bongsu Jeon To reuse the start/stop discovery code in other testcase, extract the code. Signed-off-by: Bongsu Jeon --- tools/testing/selftests/nci/nci_dev.c | 53 +++++++++++++++++++-------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/nci/nci_dev.c b/tools/testing/selftests/nci/nci_dev.c index 2b90379523c6..a68b14642c20 100644 --- a/tools/testing/selftests/nci/nci_dev.c +++ b/tools/testing/selftests/nci/nci_dev.c @@ -517,38 +517,61 @@ static void *virtual_poll_stop(void *data) return (void *)-1; } -TEST_F(NCI, start_poll) +int start_polling(int dev_idx, int proto, int virtual_fd, int sd, int fid, int pid) { __u16 nla_start_poll_type[2] = {NFC_ATTR_DEVICE_INDEX, NFC_ATTR_PROTOCOLS}; - void *nla_start_poll_data[2] = {&self->dev_idex, &self->proto}; + void *nla_start_poll_data[2] = {&dev_idx, &proto}; int nla_start_poll_len[2] = {4, 4}; pthread_t thread_t; int status; int rc; rc = pthread_create(&thread_t, NULL, virtual_poll_start, - (void *)&self->virtual_nci_fd); - ASSERT_GT(rc, -1); + (void *)&virtual_fd); + if (rc < 0) + return rc; - rc = send_cmd_mt_nla(self->sd, self->fid, self->pid, NFC_CMD_START_POLL, 2, - nla_start_poll_type, nla_start_poll_data, - nla_start_poll_len, NLM_F_REQUEST); - EXPECT_EQ(rc, 0); + rc = send_cmd_mt_nla(sd, fid, pid, NFC_CMD_START_POLL, 2, nla_start_poll_type, + nla_start_poll_data, nla_start_poll_len, NLM_F_REQUEST); + if (rc != 0) + return rc; pthread_join(thread_t, (void **)&status); - ASSERT_EQ(status, 0); + return status; +} + +int stop_polling(int dev_idx, int virtual_fd, int sd, int fid, int pid) +{ + pthread_t thread_t; + int status; + int rc; rc = pthread_create(&thread_t, NULL, virtual_poll_stop, - (void *)&self->virtual_nci_fd); - ASSERT_GT(rc, -1); + (void *)&virtual_fd); + if (rc < 0) + return rc; - rc = send_cmd_with_idx(self->sd, self->fid, self->pid, - NFC_CMD_STOP_POLL, self->dev_idex); - EXPECT_EQ(rc, 0); + rc = send_cmd_with_idx(sd, fid, pid, + NFC_CMD_STOP_POLL, dev_idx); + if (rc != 0) + return rc; pthread_join(thread_t, (void **)&status); - ASSERT_EQ(status, 0); + return status; +} + +TEST_F(NCI, start_poll) +{ + int status; + + status = start_polling(self->dev_idex, self->proto, self->virtual_nci_fd, + self->sd, self->fid, self->pid); + EXPECT_EQ(status, 0); + + status = stop_polling(self->dev_idex, self->virtual_nci_fd, self->sd, + self->fid, self->pid); + EXPECT_EQ(status, 0); } TEST_F(NCI, deinit) -- 2.32.0