NFC: nci: Extend virtual NCI deinit test
authorDmitry Vyukov <dvyukov@google.com>
Thu, 17 Nov 2022 16:21:01 +0000 (17:21 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Nov 2022 10:49:58 +0000 (10:49 +0000)
Extend the test to check the scenario when NCI core tries to send data
to already closed device to ensure that nothing bad happens.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Bongsu Jeon <bongsu.jeon@samsung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/nci/nci_dev.c

index 162c41e9bcae876be1a503dba0e3d27d3d4b2beb..1562aa7d60b0f26ec8837f84643f678ee64493de 100644 (file)
@@ -888,6 +888,17 @@ TEST_F(NCI, deinit)
                           &msg);
        ASSERT_EQ(rc, 0);
        EXPECT_EQ(get_dev_enable_state(&msg), 0);
+
+       /* Test that operations that normally send packets to the driver
+        * don't cause issues when the device is already closed.
+        * Note: the send of NFC_CMD_DEV_UP itself still succeeds it's just
+        * that the device won't actually be up.
+        */
+       close(self->virtual_nci_fd);
+       self->virtual_nci_fd = -1;
+       rc = send_cmd_with_idx(self->sd, self->fid, self->pid,
+                              NFC_CMD_DEV_UP, self->dev_idex);
+       EXPECT_EQ(rc, 0);
 }
 
 TEST_HARNESS_MAIN