From: Bongsu Jeon <[email protected]>
This series updates the virtual NCI device driver and NCI selftest code
and add the NCI test case in selftests.
1/8 to use wait queue in virtual device driver.
2/8 to remove the polling code in selftests.
3/8 to fix a typo.
4/8 to fix the next nlattr offset calculation.
5/8 to fix the wrong condition in if statement.
6/8 to add a flag parameter to the Netlink send function.
7/8 to extract the start/stop discovery function.
8/8 to add the NCI testcase in selftests.
v2:
1/8
- change the commit message.
- add the dfense code while reading a frame.
3/8
- change the commit message.
- separate the commit into 3/8~8/8.
Bongsu Jeon (8):
nfc: virtual_ncidev: Use wait queue instead of polling
selftests: nci: Remove the polling code to read a NCI frame
selftests: nci: Fix the typo
selftests: nci: Fix the code for next nlattr offset
selftests: nci: Fix the wrong condition
selftests: nci: Add the flags parameter for the send_cmd_mt_nla
selftests: nci: Extract the start/stop discovery function
selftests: nci: Add the NCI testcase reading T4T Tag
drivers/nfc/virtual_ncidev.c | 9 +-
tools/testing/selftests/nci/nci_dev.c | 416 ++++++++++++++++++++++----
2 files changed, 362 insertions(+), 63 deletions(-)
--
2.32.0
From: Bongsu Jeon <[email protected]>
To reuse the start/stop discovery code in other testcase, extract the code.
Signed-off-by: Bongsu Jeon <[email protected]>
---
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
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
On Tue, 17 Aug 2021 06:28:10 -0700 you wrote:
> From: Bongsu Jeon <[email protected]>
>
> This series updates the virtual NCI device driver and NCI selftest code
> and add the NCI test case in selftests.
>
> 1/8 to use wait queue in virtual device driver.
> 2/8 to remove the polling code in selftests.
> 3/8 to fix a typo.
> 4/8 to fix the next nlattr offset calculation.
> 5/8 to fix the wrong condition in if statement.
> 6/8 to add a flag parameter to the Netlink send function.
> 7/8 to extract the start/stop discovery function.
> 8/8 to add the NCI testcase in selftests.
>
> [...]
Here is the summary with links:
- [v2,net-next,1/8] nfc: virtual_ncidev: Use wait queue instead of polling
https://git.kernel.org/netdev/net-next/c/8675569d73ca
- [v2,net-next,2/8] selftests: nci: Remove the polling code to read a NCI frame
https://git.kernel.org/netdev/net-next/c/4ef956c64394
- [v2,net-next,3/8] selftests: nci: Fix the typo
https://git.kernel.org/netdev/net-next/c/366f6edf5dea
- [v2,net-next,4/8] selftests: nci: Fix the code for next nlattr offset
https://git.kernel.org/netdev/net-next/c/78a7b2a8a0fa
- [v2,net-next,5/8] selftests: nci: Fix the wrong condition
https://git.kernel.org/netdev/net-next/c/1d5b8d01db98
- [v2,net-next,6/8] selftests: nci: Add the flags parameter for the send_cmd_mt_nla
https://git.kernel.org/netdev/net-next/c/6ebbc9680a33
- [v2,net-next,7/8] selftests: nci: Extract the start/stop discovery function
https://git.kernel.org/netdev/net-next/c/72696bd8a09d
- [v2,net-next,8/8] selftests: nci: Add the NCI testcase reading T4T Tag
https://git.kernel.org/netdev/net-next/c/61612511e55c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html