From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 1/2] android/tester: Add Socket test close and listen
Date: Wed, 18 Dec 2013 17:15:16 +0200 [thread overview]
Message-ID: <1387379717-1457-1-git-send-email-Andrei.Emeltchenko.news@gmail.com> (raw)
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This test the situation when Android close file descriptor we passed to
it and try to listen() again.
---
android/android-tester.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 8a2861e..cb8fb4e 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1141,6 +1141,57 @@ clean:
close(sock_fd);
}
+static void test_listen_close(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct socket_data *test = data->test_data;
+ bt_status_t status;
+ int sock_fd = -1;
+
+ status = data->if_sock->listen(test->sock_type,
+ test->service_name, test->service_uuid,
+ test->channel, &sock_fd, test->flags);
+ if (status != test->expected_status) {
+ tester_test_failed();
+ goto clean;
+ }
+
+ /* Check that file descriptor is valid */
+ if (status == BT_STATUS_SUCCESS && fcntl(sock_fd, F_GETFD) == -1) {
+ tester_test_failed();
+ return;
+ }
+
+ tester_print("sock_fd: %d", sock_fd);
+
+ /* Now close sock_fd */
+ close(sock_fd);
+
+ /* Try to listen again */
+ status = data->if_sock->listen(test->sock_type,
+ test->service_name, test->service_uuid,
+ test->channel, &sock_fd, test->flags);
+ if (status != test->expected_status) {
+ tester_test_failed();
+ goto clean;
+ }
+
+ /* Check that file descriptor is valid */
+ if (status == BT_STATUS_SUCCESS && fcntl(sock_fd, F_GETFD) == -1) {
+ tester_test_failed();
+ return;
+ }
+
+ tester_print("sock_fd: %d", sock_fd);
+
+ tester_test_passed();
+
+clean:
+ if (sock_fd >= 0)
+ close(sock_fd);
+
+}
+
static void test_generic_connect(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1363,6 +1414,10 @@ int main(int argc, char *argv[])
&btsock_success_check_chan,
setup_socket_interface, test_generic_listen, teardown);
+ test_bredrle("Socket Listen - Close and Listen again",
+ &btsock_success_check_chan,
+ setup_socket_interface, test_listen_close, teardown);
+
test_bredrle("Socket Connect - Invalid: sock_type 0",
&btsock_inv_param_socktype, setup_socket_interface,
test_generic_connect, teardown);
--
1.8.3.2
next reply other threads:[~2013-12-18 15:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-18 15:15 Andrei Emeltchenko [this message]
2013-12-18 15:15 ` [PATCH 2/2] android/socket: Handle Android events for server socket Andrei Emeltchenko
2013-12-19 8:18 ` [PATCH 1/2] android/tester: Add Socket test close and listen Johan Hedberg
2013-12-19 8:51 ` [PATCHv2 " Andrei Emeltchenko
2013-12-19 8:51 ` [PATCHv2 2/2] android/socket: Handle Android events for server socket Andrei Emeltchenko
2013-12-19 9:09 ` [PATCHv2 1/2] android/tester: Add Socket test close and listen Johan Hedberg
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=1387379717-1457-1-git-send-email-Andrei.Emeltchenko.news@gmail.com \
--to=andrei.emeltchenko.news@gmail.com \
--cc=linux-bluetooth@vger.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).