[PATCH 07/11] android/test: Add HAL IPC thread callback test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 android/test-hal-ipc.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/android/test-hal-ipc.c b/android/test-hal-ipc.c
index 3321367..b4cf071 100644
--- a/android/test-hal-ipc.c
+++ b/android/test-hal-ipc.c
@@ -92,6 +92,41 @@ static void test_accept(void)
 	wait(NULL);
 }
 
+static int thread_cb_cnt = 0;
+
+static void thread_cb(bool enable)
+{
+	g_assert((enable && !thread_cb_cnt) || (!enable && thread_cb_cnt));
+	thread_cb_cnt++;
+}
+
+static void test_thread_cb(void)
+{
+	pid_t pid;
+
+	g_assert(hal_ipc_init(HAL_SK_PATH, sizeof(HAL_SK_PATH)));
+
+	pid = fork();
+	if (pid == 0) {
+		connect_hal();
+
+		exit(0);
+	}
+
+	g_assert(pid > 0);
+
+	hal_ipc_set_thread_cb(thread_cb);
+
+	g_assert(hal_ipc_accept());
+
+	hal_ipc_cleanup();
+
+	wait(NULL);
+
+	g_assert(thread_cb_cnt == 2);
+	thread_cb_cnt = 0;
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -101,6 +136,7 @@ int main(int argc, char *argv[])
 
 	g_test_add_func("/android_hal_ipc/init", test_init);
 	g_test_add_func("/android_hal_ipc/accept", test_accept);
+	g_test_add_func("/android_hal_ipc/thread_cb", test_thread_cb);
 
 	return g_test_run();
 }
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux