diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 1afff3b..07a483b 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
#include "lib/bluetooth.h"
#include "lib/mgmt.h"
+#include "monitor/bt.h"
+
#include "src/shared/tester.h"
#include "src/shared/mgmt.h"
#include "src/shared/hciemu.h"
uint16_t mgmt_revision;
uint16_t mgmt_index;
struct hciemu *hciemu;
+ bool hci_commands_complete;
};
static void mgmt_debug(const char *str, void *user_data)
user->expected_manufacturer = 0x003f; \
user->expected_supported_settings = 0x000002ff; \
user->initial_settings = 0x00000080; \
+ user->hci_commands_complete = false; \
tester_add_full(name, data, \
test_pre_setup, setup, func, NULL, \
test_post_teardown, user, free); \
const void *expect_param;
uint16_t expect_len;
uint32_t expect_settings_set;
+ uint16_t expect_hci_command;
+ const void *expect_hci_param;
+ uint8_t expect_hci_len;
};
static const char dummy_data[] = { 0x00 };
mgmt_unregister_index(data->mgmt_alt, index);
+ if (test->expect_hci_command && !data->hci_commands_complete) {
+ tester_warn("Settings received without expected HCI command");
+ tester_test_failed();
+ return;
+ }
+
tester_test_passed();
}
if (test->expect_settings_set)
return;
+ if (test->expect_hci_command && !data->hci_commands_complete) {
+ tester_warn("Command completed without expected HCI command");
+ tester_test_failed();
+ return;
+ }
+
tester_test_passed();
}
+static void command_hci_callback(uint16_t opcode, const void *param,
+ uint8_t length, void *user_data)
+{
+ struct test_data *data = user_data;
+ const struct generic_data *test = data->test_data;
+
+ tester_print("HCI Command 0x%04x length %u", opcode, length);
+
+ if (opcode != test->expect_hci_command)
+ return;
+
+ if (length != test->expect_hci_len) {
+ tester_warn("Invalid parameter size for HCI command");
+ tester_test_failed();
+ return;
+ }
+
+ if (memcmp(param, test->expect_hci_param, length) != 0) {
+ tester_warn("Unexpected HCI command parameter value");
+ tester_test_failed();
+ return;
+ }
+
+ data->hci_commands_complete = true;
+}
+
static void test_command_generic(const void *test_data)
{
struct test_data *data = tester_get_data();
command_generic_new_settings_alt, NULL, NULL);
}
+ if (test->expect_hci_command) {
+ tester_print("Registering HCI command callback");
+ hciemu_add_master_post_command_hook(data->hciemu,
+ command_hci_callback, data);
+ }
+
tester_print("Sending command 0x%04x", test->send_opcode);
mgmt_send(data->mgmt, test->send_opcode, index,