Return-Path: From: Bruna Moreira To: linux-bluetooth@vger.kernel.org Cc: Bruna Moreira Subject: [PATCH BlueZ 0/8] Hook mechanism for discovery tests Date: Sat, 20 Jul 2013 20:17:12 -0400 Message-Id: <1374365840-14651-1-git-send-email-bruna.moreira@openbossa.org> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: This series contains the hook mechanism implementation that will be used for discovery tests. The hook mechanism is a way to run custom code from tests before/after processing HCI commands and building events. It is also possible to "cancel" events if the post event hook returns false. This is necessary because the current emulator implementation is sequential and does not let having control about emulator behaviour. The hooks will only intercept the events which were registered previously using the hooks API exported by hciemu. If no hooks are added, the emulator will work as before. To simplify implementation, default_cmd() was split in two parts: the command response (command status/complete events) was kept in default_cmd() and "extra" events were moved to default_cmd completion(). There are four hooks types: - pre command: before default_cmd() function. - post command: before sending packet in command status and command complete. - pre event: before default_cmd_completion() function. - post event: in send_event() function, before sending the packet. They can used in external applications like tools/mgmt-tester. To illustrate this purpose, the following discovery test was implemented using this new infrastructure: - Stop discovery for BR/EDR only: this test sends stop command during inquiry, checks if inquiry cancel is sent and discovering event is disabled. Note that in current implementation it is not possible to send a stop discovery before the discovery is finished due to emulator running sequentially during same mainloop iteration, i.e., the inquiry complete HCI command is sent immediately after inquiry command. Comments and suggestions are welcome. BR, Bruna Moreira. Bruna Moreira (2): emulator: Add new function for running all hooks tools/mgmt-tester: Add stop discovery for BR/EDR only Eder Ruiz Maria (6): emulator: Add support for pre/post command/event hooks emulator: Add hook only if there aren't other with same type and opcode emulator: Export command and event hooks for hciemu user emulator: Add support for delete a hook emulator: Split default_cmd() for better command and event handler emulator: cmd_status() using send_packet() for run hooks easily emulator/btdev.c | 271 +++++++++++++++++++++++++++++++++++++++++++-------- emulator/btdev.h | 18 ++++ src/shared/hciemu.c | 58 +++++++++++ src/shared/hciemu.h | 17 ++++ tools/mgmt-tester.c | 72 +++++++++++++- 5 files changed, 395 insertions(+), 41 deletions(-) -- 1.7.9.5