summaryrefslogtreecommitdiff
path: root/android/ipc-tester.c
diff options
context:
space:
mode:
authorJakub Tyszkowski <jakub.tyszkowski@tieto.com>2014-01-20 10:36:03 +0100
committerSzymon Janc <szymon.janc@gmail.com>2014-01-20 23:23:27 +0100
commitb1d3bdfaedcefeb933aabd652fb662335e393a97 (patch)
tree40a5fd27a2d7c0669f3cd05ea2d2e2ad3ce9a96f /android/ipc-tester.c
parent732acf30cf97aa9ae60c9b4c2992a967bfdca074 (diff)
downloadbluez-b1d3bdfaedcefeb933aabd652fb662335e393a97.tar.gz
android/ipc-tester: Add daemon shutdown handler
Handle daemon shutdown asynchronously.
Diffstat (limited to 'android/ipc-tester.c')
-rw-r--r--android/ipc-tester.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index ff17ced35..b6f813128 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -52,6 +52,7 @@ struct test_data {
struct hciemu *hciemu;
enum hciemu_type hciemu_type;
pid_t bluetoothd_pid;
+ bool setup_done;
};
#define CONNECT_TIMEOUT (5 * 1000)
@@ -364,6 +365,31 @@ static void cleanup_ipc(void)
cmd_sk = -1;
}
+static gboolean check_for_daemon(gpointer user_data)
+{
+ int status;
+ struct test_data *data = user_data;
+
+ if ((waitpid(data->bluetoothd_pid, &status, WNOHANG))
+ != data->bluetoothd_pid)
+ return true;
+
+ if (data->setup_done) {
+ if (WIFEXITED(status) &&
+ (WEXITSTATUS(status) == EXIT_SUCCESS)) {
+ tester_test_passed();
+ return false;
+ }
+ tester_test_failed();
+ } else {
+ tester_setup_failed();
+ test_post_teardown(data);
+ }
+
+ tester_warn("Unexpected Daemon shutdown with status %d", status);
+ return false;
+}
+
static void setup(const void *data)
{
struct test_data *test_data = tester_get_data();
@@ -401,24 +427,29 @@ static void setup(const void *data)
goto failed;
}
+ g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, check_for_daemon, test_data,
+ NULL);
+
if (!init_ipc()) {
tester_warn("Cannot initialize IPC mechanism!");
goto failed;
}
/* TODO: register modules */
+ test_data->setup_done = true;
return;
failed:
+ g_idle_remove_by_data(test_data);
tester_setup_failed();
test_post_teardown(data);
}
-
static void teardown(const void *data)
{
struct test_data *test_data = tester_get_data();
+ g_idle_remove_by_data(test_data);
cleanup_ipc();
if (test_data->bluetoothd_pid)