diff --git a/android/tester-main.c b/android/tester-main.c
index 5496d2e..e7b1e1b 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
g_atomic_int_dec_and_test(&scheduled_cbacks_num);
}
+static gboolean verify_action(gpointer user_data)
+{
+ struct step *step = user_data;
+
+ verify_step(step, g_free);
+
+ return FALSE;
+}
+
static gboolean verify_callback(gpointer user_data)
{
struct step *step = user_data;
g_idle_add(verify_callback, step);
}
+static void schedule_action_verification(struct step *step)
+{
+ g_idle_add_full(G_PRIORITY_HIGH_IDLE, verify_action, step, NULL);
+}
+
static void adapter_state_changed_cb(bt_state_t state)
{
struct step *step = g_new0(struct step, 1);
const void *param, uint8_t len,
void *user_data)
{
- struct step step;
+ struct step *step = g_new0(struct step, 1);
switch (opcode) {
case BT_HCI_CMD_WRITE_SCAN_ENABLE:
return;
}
- memset(&step, 0, sizeof(step));
-
if (status) {
tester_warn("Emulated remote setup failed.");
- step.action_status = BT_STATUS_FAIL;
+ step->action_status = BT_STATUS_FAIL;
} else {
tester_warn("Emulated remote setup done.");
- step.action_status = BT_STATUS_SUCCESS;
+ step->action_status = BT_STATUS_SUCCESS;
}
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void emu_setup_powered_remote_action(void)
struct step *current_data_step = queue_peek_head(data->steps);
struct bt_action_data *action_data = current_data_step->set_data;
struct bthost *bthost;
- struct step step;
+ struct step *step = g_new0(struct step, 1);
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_pin_code(bthost, action_data->pin->pin,
action_data->pin_len);
- memset(&step, 0, sizeof(step));
- step.action_status = BT_STATUS_SUCCESS;
+ step->action_status = BT_STATUS_SUCCESS;
tester_print("Setting emu pin done.");
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void emu_set_ssp_mode_action(void)
{
struct test_data *data = tester_get_data();
struct bthost *bthost;
- struct step step;
+ struct step *step = g_new0(struct step, 1);
bthost = hciemu_client_get_host(data->hciemu);
bthost_write_ssp_mode(bthost, 0x01);
- memset(&step, 0, sizeof(step));
- step.action_status = BT_STATUS_SUCCESS;
+ step->action_status = BT_STATUS_SUCCESS;
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void dummy_action(void)
{
- struct step step;
+ struct step *step = g_new0(struct step, 1);
- memset(&step, 0, sizeof(step));
- step.action = dummy_action;
+ step->action = dummy_action;
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bluetooth_enable_action(void)
{
struct test_data *data = tester_get_data();
- struct step step;
+ struct step *step = g_new0(struct step, 1);
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->enable();
+ step->action_status = data->if_bluetooth->enable();
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bluetooth_disable_action(void)
{
struct test_data *data = tester_get_data();
- struct step step;
+ struct step *step = g_new0(struct step, 1);
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->disable();
+ step->action_status = data->if_bluetooth->disable();
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_set_property_action(void)
{
struct test_data *data = tester_get_data();
- struct step step;
+ struct step *step = g_new0(struct step, 1);
struct step *current_data_step = queue_peek_head(data->steps);
bt_property_t *prop;
prop = (bt_property_t *)current_data_step->set_data;
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->set_adapter_property(
+ step->action_status = data->if_bluetooth->set_adapter_property(
prop);
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_get_property_action(void)
{
struct test_data *data = tester_get_data();
- struct step step;
+ struct step *step = g_new0(struct step, 1);
struct step *current_data_step = queue_peek_head(data->steps);
bt_property_t *prop;
prop = (bt_property_t *)current_data_step->set_data;
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->get_adapter_property(
+ step->action_status = data->if_bluetooth->get_adapter_property(
prop->type);
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_start_discovery_action(void)
{
struct test_data *data = tester_get_data();
- struct step step;
+ struct step *step = g_new0(struct step, 1);
- step.action_status = data->if_bluetooth->start_discovery();
+ step->action_status = data->if_bluetooth->start_discovery();
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_cancel_discovery_action(void)
{
struct test_data *data = tester_get_data();
- struct step step;
+ struct step *step = g_new0(struct step, 1);
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->cancel_discovery();
+ step->action_status = data->if_bluetooth->cancel_discovery();
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_get_device_props_action(void)
{
struct test_data *data = tester_get_data();
struct step *current_data_step = queue_peek_head(data->steps);
- struct step step;
+ struct step *step = g_new0(struct step, 1);
if (!current_data_step->set_data) {
tester_debug("bdaddr not defined");
return;
}
- memset(&step, 0, sizeof(step));
- step.action_status =
+ step->action_status =
data->if_bluetooth->get_remote_device_properties(
current_data_step->set_data);
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_get_device_prop_action(void)
struct test_data *data = tester_get_data();
struct step *current_data_step = queue_peek_head(data->steps);
struct bt_action_data *action_data = current_data_step->set_data;
- struct step step;
+ struct step *step = g_new0(struct step, 1);
if (!action_data) {
tester_warn("No arguments for 'get remote device prop' req.");
return;
}
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->get_remote_device_property(
+ step->action_status = data->if_bluetooth->get_remote_device_property(
action_data->addr,
action_data->prop_type);
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_set_device_prop_action(void)
struct test_data *data = tester_get_data();
struct step *current_data_step = queue_peek_head(data->steps);
struct bt_action_data *action_data = current_data_step->set_data;
- struct step step;
+ struct step *step = g_new0(struct step, 1);
if (!action_data) {
tester_warn("No arguments for 'set remote device prop' req.");
return;
}
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->set_remote_device_property(
+ step->action_status = data->if_bluetooth->set_remote_device_property(
action_data->addr,
action_data->prop);
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_create_bond_action(void)
struct test_data *data = tester_get_data();
struct step *current_data_step = queue_peek_head(data->steps);
struct bt_action_data *action_data = current_data_step->set_data;
- struct step step;
+ struct step *step = g_new0(struct step, 1);
if (!action_data || !action_data->addr) {
tester_warn("Bad arguments for 'create bond' req.");
return;
}
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->create_bond(action_data->addr);
+ step->action_status =
+ data->if_bluetooth->create_bond(action_data->addr);
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_pin_reply_accept_action(void)
struct test_data *data = tester_get_data();
struct step *current_data_step = queue_peek_head(data->steps);
struct bt_action_data *action_data = current_data_step->set_data;
- struct step step;
+ struct step *step = g_new0(struct step, 1);
if (!action_data || !action_data->addr || !action_data->pin) {
tester_warn("Bad arguments for 'pin reply' req.");
return;
}
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->pin_reply(action_data->addr,
+ step->action_status = data->if_bluetooth->pin_reply(action_data->addr,
TRUE,
action_data->pin_len,
action_data->pin);
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_ssp_reply_accept_action(void)
struct test_data *data = tester_get_data();
struct step *current_data_step = queue_peek_head(data->steps);
struct bt_action_data *action_data = current_data_step->set_data;
- struct step step;
+ struct step *step = g_new0(struct step, 1);
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->ssp_reply(action_data->addr,
+ step->action_status = data->if_bluetooth->ssp_reply(action_data->addr,
action_data->ssp_variant,
action_data->accept, 0);
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_cancel_bond_action(void)
struct test_data *data = tester_get_data();
struct step *current_data_step = queue_peek_head(data->steps);
bt_bdaddr_t *addr = current_data_step->set_data;
- struct step step;
+ struct step *step = g_new0(struct step, 1);
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->cancel_bond(addr);
+ step->action_status = data->if_bluetooth->cancel_bond(addr);
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
void bt_remove_bond_action(void)
struct test_data *data = tester_get_data();
struct step *current_data_step = queue_peek_head(data->steps);
bt_bdaddr_t *addr = current_data_step->set_data;
- struct step step;
+ struct step *step = g_new0(struct step, 1);
- memset(&step, 0, sizeof(step));
- step.action_status = data->if_bluetooth->remove_bond(addr);
+ step->action_status = data->if_bluetooth->remove_bond(addr);
- verify_step(&step, NULL);
+ schedule_action_verification(step);
}
static void generic_test_function(const void *test_data)