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 <bongsu.jeon@samsung.com>
Subject: [linux-nfc] [PATCH v2 net-next 7/8] selftests: nci: Extract the start/stop discovery function
Date: Tue, 17 Aug 2021 06:28:17 -0700 [thread overview]
Message-ID: <20210817132818.8275-8-bongsu.jeon2@gmail.com> (raw)
In-Reply-To: <20210817132818.8275-1-bongsu.jeon2@gmail.com>
From: Bongsu Jeon <bongsu.jeon@samsung.com>
To reuse the start/stop discovery code in other testcase, extract the code.
Signed-off-by: Bongsu Jeon <bongsu.jeon@samsung.com>
---
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
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
next prev parent reply other threads:[~2021-08-17 13:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 13:28 [linux-nfc] [PATCH v2 net-next 0/8] Update the virtual NCI device driver and add the NCI testcase bongsu.jeon2
2021-08-17 13:28 ` [linux-nfc] [PATCH v2 net-next 1/8] nfc: virtual_ncidev: Use wait queue instead of polling bongsu.jeon2
2021-08-17 13:28 ` [linux-nfc] [PATCH v2 net-next 2/8] selftests: nci: Remove the polling code to read a NCI frame bongsu.jeon2
2021-08-17 13:28 ` [linux-nfc] [PATCH v2 net-next 3/8] selftests: nci: Fix the typo bongsu.jeon2
2021-08-17 13:28 ` [linux-nfc] [PATCH v2 net-next 4/8] selftests: nci: Fix the code for next nlattr offset bongsu.jeon2
2021-08-17 13:28 ` [linux-nfc] [PATCH v2 net-next 5/8] selftests: nci: Fix the wrong condition bongsu.jeon2
2021-08-17 13:28 ` [linux-nfc] [PATCH v2 net-next 6/8] selftests: nci: Add the flags parameter for the send_cmd_mt_nla bongsu.jeon2
2021-08-17 13:28 ` bongsu.jeon2 [this message]
2021-08-17 13:28 ` [linux-nfc] [PATCH v2 net-next 8/8] selftests: nci: Add the NCI testcase reading T4T Tag bongsu.jeon2
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210817132818.8275-8-bongsu.jeon2@gmail.com \
--to=bongsu.jeon2@gmail.com \
--cc=bongsu.jeon@samsung.com \
--cc=krzysztof.kozlowski@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-nfc@lists.01.org \
--cc=netdev@vger.kernel.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).