From: Andrei Emeltchenko <[email protected]>
Add Socket test making listen two times on the same RFCOMM channel.
---
android/android-tester.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 5e60397..fb95dd2 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1129,6 +1129,16 @@ static const struct socket_data btsock_inv_param_bdaddr = {
.expected_status = BT_STATUS_PARM_INVALID,
};
+static const struct socket_data btsock_inv_listen_listen = {
+ .sock_type = BTSOCK_RFCOMM,
+ .channel = 1,
+ .service_uuid = NULL,
+ .service_name = "Test service",
+ .flags = 0,
+ .expected_status = BT_STATUS_FAIL,
+ .test_channel = true,
+};
+
static void setup_socket_interface(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1264,6 +1274,43 @@ clean:
}
+static void test_listen_listen(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_fd1 = -1, sock_fd2 = -1;
+
+ status = data->if_sock->listen(test->sock_type,
+ test->service_name, test->service_uuid,
+ test->channel, &sock_fd1, test->flags);
+ if (status != BT_STATUS_SUCCESS) {
+ tester_warn("sock->listen() failed");
+ tester_test_failed();
+ goto clean;
+ }
+
+ status = data->if_sock->listen(test->sock_type,
+ test->service_name, test->service_uuid,
+ test->channel, &sock_fd2, test->flags);
+ if (status != test->expected_status) {
+ tester_warn("sock->listen() failed, status %d", status);
+ tester_test_failed();
+ goto clean;
+ }
+
+ tester_print("status after second listen(): %d", status);
+
+ tester_test_passed();
+
+clean:
+ if (sock_fd1 >= 0)
+ close(sock_fd1);
+
+ if (sock_fd2 >= 0)
+ close(sock_fd2);
+}
+
static void test_generic_connect(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1568,6 +1615,10 @@ int main(int argc, char *argv[])
&btsock_success_check_chan,
setup_socket_interface, test_listen_close, teardown);
+ test_bredrle("Socket Listen - Invalid: double Listen",
+ &btsock_inv_listen_listen,
+ setup_socket_interface, test_listen_listen, teardown);
+
test_bredrle("Socket Connect - Invalid: sock_type 0",
&btsock_inv_param_socktype, setup_socket_interface,
test_generic_connect, teardown);
--
1.8.3.2
Hi Andrei,
On Fri, Dec 20, 2013, Andrei Emeltchenko wrote:
> Add Socket test making listen two times on the same RFCOMM channel.
> ---
> android/android-tester.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
All three patches have been applied. Thanks.
Johan
From: Andrei Emeltchenko <[email protected]>
---
android/android-tester.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index fb95dd2..4148c0e 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1194,7 +1194,7 @@ static void test_generic_listen(const void *test_data)
}
/* Check that file descriptor is valid */
- if (status == BT_STATUS_SUCCESS && fcntl(sock_fd, F_GETFD) == -1) {
+ if (status == BT_STATUS_SUCCESS && fcntl(sock_fd, F_GETFD) < 0) {
tester_test_failed();
return;
}
@@ -1327,7 +1327,7 @@ static void test_generic_connect(const void *test_data)
}
/* Check that file descriptor is valid */
- if (status == BT_STATUS_SUCCESS && fcntl(sock_fd, F_GETFD) == -1) {
+ if (status == BT_STATUS_SUCCESS && fcntl(sock_fd, F_GETFD) < 0) {
tester_test_failed();
return;
}
@@ -1462,7 +1462,7 @@ static void test_socket_real_connect(const void *test_data)
}
/* Check that file descriptor is valid */
- if (status == BT_STATUS_SUCCESS && fcntl(sock_fd, F_GETFD) == -1) {
+ if (status == BT_STATUS_SUCCESS && fcntl(sock_fd, F_GETFD) < 0) {
tester_test_failed();
return;
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
The case is analog for similar test case with listen().
---
android/android-tester.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 4148c0e..fa65416 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1101,12 +1101,14 @@ static const struct socket_data btsock_inv_params_chan_uuid = {
};
static const struct socket_data btsock_success = {
+ .bdaddr = &bdaddr_dummy,
.sock_type = BTSOCK_RFCOMM,
.channel = 1,
.service_uuid = NULL,
.service_name = "Test service",
.flags = 0,
.expected_status = BT_STATUS_SUCCESS,
+ .test_channel = false
};
static const struct socket_data btsock_success_check_chan = {
@@ -1619,6 +1621,10 @@ int main(int argc, char *argv[])
&btsock_inv_listen_listen,
setup_socket_interface, test_listen_listen, teardown);
+ test_bredrle("Socket Connect - Check returned fd valid",
+ &btsock_success, setup_socket_interface,
+ test_generic_connect, teardown);
+
test_bredrle("Socket Connect - Invalid: sock_type 0",
&btsock_inv_param_socktype, setup_socket_interface,
test_generic_connect, teardown);
--
1.8.3.2