diff --git a/emulator/hciemu.c b/emulator/hciemu.c
index 3557efc..4752c8a 100644
--- a/emulator/hciemu.c
+++ b/emulator/hciemu.c
return true;
}
+struct vhci *hciemu_get_vhci(struct hciemu *hciemu)
+{
+ if (!hciemu)
+ return NULL;
+
+ return hciemu->vhci;
+}
+
struct hciemu_client *hciemu_get_client(struct hciemu *hciemu, int num)
{
const struct queue_entry *entry;
diff --git a/emulator/hciemu.h b/emulator/hciemu.h
index 3d3d93b..338fa84 100644
--- a/emulator/hciemu.h
+++ b/emulator/hciemu.h
bool hciemu_set_debug(struct hciemu *hciemu, hciemu_debug_func_t callback,
void *user_data, hciemu_destroy_func_t destroy);
+struct vhci *hciemu_get_vhci(struct hciemu *hciemu);
struct bthost *hciemu_client_get_host(struct hciemu *hciemu);
const char *hciemu_get_address(struct hciemu *hciemu);
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 8bddf6b..64a5e1c 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
#include "lib/l2cap.h"
#include "monitor/bt.h"
+#include "emulator/vhci.h"
#include "emulator/bthost.h"
#include "emulator/hciemu.h"
uint8_t adv_data_len;
};
-static int set_debugfs_force_suspend(int index, bool enable)
-{
- int fd, n, err;
- char val, path[64];
-
- err = 0;
-
- /* path for the debugfs file
- * /sys/kernel/debug/bluetooth/hciX/force_suspend
- */
- memset(path, 0, sizeof(path));
- sprintf(path, "/sys/kernel/debug/bluetooth/hci%d/force_suspend", index);
-
- fd = open(path, O_RDWR);
- if (fd < 0)
- return -errno;
-
- val = (enable) ? 'Y' : 'N';
-
- n = write(fd, &val, sizeof(val));
- if (n < (ssize_t) sizeof(val))
- err = -errno;
-
- close(fd);
-
- return err;
-}
-
-static int set_debugfs_force_wakeup(int index, bool enable)
-{
- int fd, n, err;
- char val, path[64];
-
- err = 0;
-
- /* path for the debugfs file
- * /sys/kernel/debug/bluetooth/hciX/force_suspend
- */
- memset(path, 0, sizeof(path));
- sprintf(path, "/sys/kernel/debug/bluetooth/hci%d/force_wakeup", index);
-
- fd = open(path, O_RDWR);
- if (fd < 0)
- return -errno;
-
- val = (enable) ? 'Y' : 'N';
-
- n = write(fd, &val, sizeof(val));
- if (n < (ssize_t) sizeof(val))
- err = -errno;
-
- close(fd);
-
- return err;
-}
-
static const uint8_t set_exp_feat_param_debug[] = {
0x1c, 0xda, 0x47, 0x1c, 0x48, 0x6c, 0x01, 0xab, /* UUID - Debug */
0x9f, 0x46, 0xec, 0xb9, 0x30, 0x25, 0x99, 0xd4,
static void test_suspend_resume_success_1(const void *test_data)
{
- bool suspend;
+ struct test_data *data = tester_get_data();
+ struct vhci *vhci = hciemu_get_vhci(data->hciemu);
int err;
/* Triggers the suspend */
- suspend = true;
- err = set_debugfs_force_suspend(0, suspend);
+ err = vhci_set_force_suspend(vhci, true);
if (err) {
tester_warn("Unable to enable the force_suspend");
tester_test_failed();
static void test_suspend_resume_success_2(const void *test_data)
{
- bool suspend;
+ struct test_data *data = tester_get_data();
+ struct vhci *vhci = hciemu_get_vhci(data->hciemu);
int err;
/* Triggers the suspend */
- suspend = true;
- err = set_debugfs_force_suspend(0, suspend);
+ err = vhci_set_force_suspend(vhci, true);
if (err) {
tester_warn("Unable to enable the force_suspend");
tester_test_failed();
}
/* Triggers the resume */
- suspend = false;
- err = set_debugfs_force_suspend(0, suspend);
+ err = vhci_set_force_suspend(vhci, false);
if (err) {
tester_warn("Unable to enable the force_suspend");
tester_test_failed();
static void test_suspend_resume_success_3(const void *test_data)
{
- bool suspend;
+ struct test_data *data = tester_get_data();
+ struct vhci *vhci = hciemu_get_vhci(data->hciemu);
int err;
/* Triggers the suspend */
- suspend = true;
- err = set_debugfs_force_suspend(0, suspend);
+ err = vhci_set_force_suspend(vhci, true);
if (err) {
tester_warn("Unable to enable the force_suspend");
tester_test_failed();
static void test_suspend_resume_success_4(const void *test_data)
{
- bool suspend;
+ struct test_data *data = tester_get_data();
+ struct vhci *vhci = hciemu_get_vhci(data->hciemu);
int err;
test_command_generic(test_data);
/* Triggers the suspend */
- suspend = true;
tester_print("Set the system into Suspend via force_suspend");
- err = set_debugfs_force_suspend(0, suspend);
+ err = vhci_set_force_suspend(vhci, true);
if (err) {
tester_warn("Unable to enable the force_suspend");
tester_test_failed();
static void trigger_force_suspend(void *user_data)
{
- bool suspend;
+ struct test_data *data = tester_get_data();
+ struct vhci *vhci = hciemu_get_vhci(data->hciemu);
int err;
/* Triggers the suspend */
- suspend = true;
tester_print("Set the system into Suspend via force_suspend");
- err = set_debugfs_force_suspend(0, suspend);
+ err = vhci_set_force_suspend(vhci, true);
if (err) {
tester_warn("Unable to enable the force_suspend");
return;
static void trigger_force_resume(void *user_data)
{
- bool suspend;
+ struct test_data *data = tester_get_data();
+ struct vhci *vhci = hciemu_get_vhci(data->hciemu);
int err;
/* Triggers the suspend */
- suspend = false;
tester_print("Set the system into Resume via force_suspend");
- err = set_debugfs_force_suspend(0, suspend);
+ err = vhci_set_force_suspend(vhci, false);
if (err) {
tester_warn("Unable to disable the force_suspend");
return;
static void test_suspend_resume_success_7(const void *test_data)
{
- bool suspend;
+ struct test_data *data = tester_get_data();
+ struct vhci *vhci = hciemu_get_vhci(data->hciemu);
int err;
/* Set Force Wakeup */
- suspend = true;
- err = set_debugfs_force_wakeup(0, suspend);
+ err = vhci_set_force_wakeup(vhci, true);
if (err) {
tester_warn("Unable to enable the force_wakeup");
tester_test_failed();
}
/* Triggers the suspend */
- suspend = true;
- err = set_debugfs_force_suspend(0, suspend);
+ err = vhci_set_force_suspend(vhci, true);
if (err) {
tester_warn("Unable to enable the force_suspend");
tester_test_failed();