Diff between 6a9ed0d6b3a0ac878b5b742455dea0744a63662e and 5128fb7e2b7392a02a92371ae4da614f326b0356

Changed Files

File Additions Deletions Status
android/android-tester.c +38 -0 modified

Full Patch

diff --git a/android/android-tester.c b/android/android-tester.c
index f4f8e9b..c7ffef0 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -73,6 +73,7 @@ struct socket_data {
 	btsock_type_t sock_type;
 	const char *service_name;
 	const uint8_t *service_uuid;
+	const bt_bdaddr_t *bdaddr;
 	int channel;
 	int flags;
 	bt_status_t expected_status;
@@ -682,7 +683,12 @@ static void test_dummy(const void *test_data)
 
 /* Test Socket HAL */
 
+const bt_bdaddr_t bdaddr_dummy = {
+	.address = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55}
+};
+
 static const struct socket_data btsock_inv_param_socktype = {
+	.bdaddr = &bdaddr_dummy,
 	.sock_type = 0,
 	.channel = 1,
 	.service_uuid = NULL,
@@ -763,6 +769,34 @@ clean:
 		close(sock_fd);
 }
 
+static void test_generic_connect(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->connect(test->bdaddr, test->sock_type,
+					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_test_passed();
+
+clean:
+	if (sock_fd >= 0)
+		close(sock_fd);
+}
+
 #define test_bredrle(name, data, test_setup, test, test_teardown) \
 	do { \
 		struct test_data *user; \
@@ -812,5 +846,9 @@ int main(int argc, char *argv[])
 			&btsock_sucess,
 			setup_socket_interface, test_generic_listen, teardown);
 
+	test_bredrle("Test Socket Connect - Invalid: sock_type 0",
+			&btsock_inv_param_socktype, setup_socket_interface,
+			test_generic_connect, teardown);
+
 	return tester_run();
 }