From patchwork Sat Nov 7 07:03:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inga Stotland X-Patchwork-Id: 321186 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46197C388F9 for ; Sat, 7 Nov 2020 07:03:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2044206F9 for ; Sat, 7 Nov 2020 07:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727753AbgKGHD1 (ORCPT ); Sat, 7 Nov 2020 02:03:27 -0500 Received: from mga17.intel.com ([192.55.52.151]:45622 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725985AbgKGHD1 (ORCPT ); Sat, 7 Nov 2020 02:03:27 -0500 IronPort-SDR: qDb5PYy7FYbRLeAlID2TslUgeV5iZxtOFGKg0QEghQ5l545GyO+kV5nJ63fV++j7cRZJoIUEgB 7z5Nm9kDbjww== X-IronPort-AV: E=McAfee;i="6000,8403,9797"; a="149485511" X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="149485511" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:27 -0800 IronPort-SDR: pl1sFTxNSin2d6giilZyC+SJkK9cjt0RfLsaYByFqFKbDJdEAczKchlF/lwo0zcPPPdmgzIWDH G4b5zzRYpLiw== X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="359032008" Received: from ralassax-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.209.101.141]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:26 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, Inga Stotland Subject: [RFC PATCH BlueZ 01/10] shared/tester-ell: Create ell-based version of tester code Date: Fri, 6 Nov 2020 23:03:03 -0800 Message-Id: <20201107070312.8561-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201107070312.8561-1-inga.stotland@intel.com> References: <20201107070312.8561-1-inga.stotland@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Create a version of tester that uses ell primitives instead of glib: tester-ell.c. This source is included to generate lishared-ell library. The original tester.c is built as part of libshared-glib library. --- Makefile.am | 8 +- src/shared/tester-ell.c | 875 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 880 insertions(+), 3 deletions(-) create mode 100644 src/shared/tester-ell.c diff --git a/Makefile.am b/Makefile.am index 69b95828f..952b9cc5b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -191,7 +191,7 @@ shared_sources = src/shared/io.h src/shared/timeout.h \ src/shared/crypto.h src/shared/crypto.c \ src/shared/ecc.h src/shared/ecc.c \ src/shared/ringbuf.h src/shared/ringbuf.c \ - src/shared/tester.h src/shared/tester.c \ + src/shared/tester.h\ src/shared/hci.h src/shared/hci.c \ src/shared/hci-crypto.h src/shared/hci-crypto.c \ src/shared/hfp.h src/shared/hfp.c \ @@ -218,7 +218,8 @@ src_libshared_glib_la_SOURCES = $(shared_sources) \ src/shared/timeout-glib.c \ src/shared/mainloop-glib.c \ src/shared/mainloop-notify.h \ - src/shared/mainloop-notify.c + src/shared/mainloop-notify.c \ + src/shared/tester.c src_libshared_mainloop_la_SOURCES = $(shared_sources) \ src/shared/io-mainloop.c \ @@ -232,7 +233,8 @@ src_libshared_ell_la_SOURCES = $(shared_sources) \ src/shared/io-ell.c \ src/shared/timeout-ell.c \ src/shared/mainloop.h \ - src/shared/mainloop-ell.c + src/shared/mainloop-ell.c \ + src/shared/tester-ell.c endif attrib_sources = attrib/att.h attrib/att-database.h attrib/att.c \ diff --git a/src/shared/tester-ell.c b/src/shared/tester-ell.c new file mode 100644 index 000000000..4d7b794b9 --- /dev/null +++ b/src/shared/tester-ell.c @@ -0,0 +1,875 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2012-2014, 2020 Intel Corporation. All rights reserved. + * + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "lib/bluetooth.h" +#include "lib/hci.h" + +#ifdef HAVE_VALGRIND_MEMCHECK_H +#include +#endif + +#include "src/shared/mainloop.h" +#include "src/shared/util.h" +#include "src/shared/tester.h" +#include "src/shared/log.h" + +#define COLOR_OFF "\x1B[0m" +#define COLOR_BLACK "\x1B[0;30m" +#define COLOR_RED "\x1B[0;31m" +#define COLOR_GREEN "\x1B[0;32m" +#define COLOR_YELLOW "\x1B[0;33m" +#define COLOR_BLUE "\x1B[0;34m" +#define COLOR_MAGENTA "\x1B[0;35m" +#define COLOR_CYAN "\x1B[0;36m" +#define COLOR_WHITE "\x1B[0;37m" +#define COLOR_HIGHLIGHT "\x1B[1;39m" + +#define print_text(color, fmt, args...) \ + tester_log(color fmt COLOR_OFF, ## args) + +#define print_summary(label, color, value, fmt, args...) \ + tester_log("%-52s " color "%-10s" COLOR_OFF fmt, \ + label, value, ## args) + +#define print_progress(name, color, fmt, args...) \ + tester_log(COLOR_HIGHLIGHT "%s" COLOR_OFF " - " \ + color fmt COLOR_OFF, name, ## args) + +enum test_result { + TEST_RESULT_NOT_RUN, + TEST_RESULT_PASSED, + TEST_RESULT_FAILED, + TEST_RESULT_TIMED_OUT, +}; + +enum test_stage { + TEST_STAGE_INVALID, + TEST_STAGE_PRE_SETUP, + TEST_STAGE_SETUP, + TEST_STAGE_RUN, + TEST_STAGE_TEARDOWN, + TEST_STAGE_POST_TEARDOWN, +}; + +struct test_case { + char *name; + enum test_result result; + enum test_stage stage; + const void *test_data; + tester_data_func_t pre_setup_func; + tester_data_func_t setup_func; + tester_data_func_t test_func; + tester_data_func_t teardown_func; + tester_data_func_t post_teardown_func; + double start_time; + double end_time; + unsigned int timeout; + struct l_timeout *run_timer; + tester_destroy_func_t destroy; + void *user_data; + bool teardown; +}; + +static char *tester_name; + +static struct l_queue *test_list; +static const struct l_queue_entry *test_entry; +static struct timeval tester_start; + +static bool option_quiet; +static bool option_debug; +static bool option_monitor; +static bool option_list; +static const char *option_prefix; + +struct monitor_hdr { + uint16_t opcode; + uint16_t index; + uint16_t len; + uint8_t priority; + uint8_t ident_len; +} __attribute__((packed)); + +struct monitor_l2cap_hdr { + uint16_t cid; + uint16_t psm; +} __attribute__((packed)); + +static void test_destroy(void *data) +{ + struct test_case *test = data; + + l_timeout_remove(test->run_timer); + + if (test->destroy) + test->destroy(test->user_data); + + l_free(test->name); + l_free(test); +} + +static void tester_vprintf(const char *format, va_list ap) +{ + if (tester_use_quiet()) + return; + + printf(" %s", COLOR_WHITE); + vprintf(format, ap); + printf("%s\n", COLOR_OFF); +} + +static void tester_log(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + vprintf(format, ap); + printf("\n"); + va_end(ap); + + va_start(ap, format); + bt_log_vprintf(HCI_DEV_NONE, tester_name, LOG_INFO, format, ap); + va_end(ap); +} + +void tester_print(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + tester_vprintf(format, ap); + va_end(ap); + + va_start(ap, format); + bt_log_vprintf(HCI_DEV_NONE, tester_name, LOG_INFO, format, ap); + va_end(ap); +} + +void tester_debug(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + tester_vprintf(format, ap); + va_end(ap); + + va_start(ap, format); + bt_log_vprintf(HCI_DEV_NONE, tester_name, LOG_DEBUG, format, ap); + va_end(ap); +} + +void tester_warn(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + tester_vprintf(format, ap); + va_end(ap); + + va_start(ap, format); + bt_log_vprintf(HCI_DEV_NONE, tester_name, LOG_WARNING, format, ap); + va_end(ap); +} + +static void monitor_debug(const char *str, void *user_data) +{ + const char *label = user_data; + + tester_debug("%s: %s", label, str); +} + +static void monitor_log(char dir, uint16_t cid, uint16_t psm, const void *data, + size_t len) +{ + struct iovec iov[3]; + struct monitor_l2cap_hdr hdr; + uint8_t term = 0x00; + char label[16]; + + if (snprintf(label, sizeof(label), "%c %s", dir, tester_name) < 0) + return; + + hdr.cid = cpu_to_le16(cid); + hdr.psm = cpu_to_le16(psm); + + iov[0].iov_base = &hdr; + iov[0].iov_len = sizeof(hdr); + + iov[1].iov_base = (void *) data; + iov[1].iov_len = len; + + /* Kernel won't forward if data is no NULL terminated */ + iov[2].iov_base = &term; + iov[2].iov_len = sizeof(term); + + bt_log_sendmsg(HCI_DEV_NONE, label, LOG_INFO, iov, 3); +} + +void tester_monitor(char dir, uint16_t cid, uint16_t psm, const void *data, + size_t len) +{ + monitor_log(dir, cid, psm, data, len); + + if (!tester_use_debug()) + return; + + util_hexdump(dir, data, len, monitor_debug, (void *) tester_name); +} + +static void default_pre_setup(const void *test_data) +{ + tester_pre_setup_complete(); +} + +static void default_setup(const void *test_data) +{ + tester_setup_complete(); +} + +static void default_teardown(const void *test_data) +{ + tester_teardown_complete(); +} + +static void default_post_teardown(const void *test_data) +{ + tester_post_teardown_complete(); +} + +void tester_add_full(const char *name, const void *test_data, + tester_data_func_t pre_setup_func, + tester_data_func_t setup_func, + tester_data_func_t test_func, + tester_data_func_t teardown_func, + tester_data_func_t post_teardown_func, + unsigned int timeout, + void *user_data, tester_destroy_func_t destroy) +{ + struct test_case *test; + + if (!test_func) + return; + + if (option_prefix && !l_str_has_prefix(name, option_prefix)) { + if (destroy) + destroy(user_data); + return; + } + + if (option_list) { + tester_log("%s", name); + if (destroy) + destroy(user_data); + return; + } + + test = l_new(struct test_case, 1); + test->name = l_strdup(name); + test->result = TEST_RESULT_NOT_RUN; + test->stage = TEST_STAGE_INVALID; + + test->test_data = test_data; + + if (pre_setup_func) + test->pre_setup_func = pre_setup_func; + else + test->pre_setup_func = default_pre_setup; + + if (setup_func) + test->setup_func = setup_func; + else + test->setup_func = default_setup; + + test->test_func = test_func; + + if (teardown_func) + test->teardown_func = teardown_func; + else + test->teardown_func = default_teardown; + + if (post_teardown_func) + test->post_teardown_func = post_teardown_func; + else + test->post_teardown_func = default_post_teardown; + + test->timeout = timeout; + + test->destroy = destroy; + test->user_data = user_data; + + l_queue_push_tail(test_list, test); +} + +void tester_add(const char *name, const void *test_data, + tester_data_func_t setup_func, + tester_data_func_t test_func, + tester_data_func_t teardown_func) +{ + tester_add_full(name, test_data, NULL, setup_func, test_func, + teardown_func, NULL, 0, NULL, NULL); +} + +void *tester_get_data(void) +{ + struct test_case *test; + + if (!test_entry) + return NULL; + + test = test_entry->data; + + return test->user_data; +} + +static double get_elapsed_time(struct timeval *base) +{ + static struct timeval now, elapsed; + + gettimeofday(&now, NULL); + timersub(&now, base, &elapsed); + + return elapsed.tv_sec + ((double) elapsed.tv_usec) / 1000000; +} + +static int tester_summarize(void) +{ + unsigned int not_run = 0, passed = 0, failed = 0; + double execution_time; + const struct l_queue_entry *entry; + + tester_log(""); + print_text(COLOR_HIGHLIGHT, ""); + print_text(COLOR_HIGHLIGHT, "Test Summary"); + print_text(COLOR_HIGHLIGHT, "------------"); + + entry = l_queue_get_entries(test_list); + + for (; entry; entry = entry->next) { + struct test_case *test = entry->data; + double exec_time; + + exec_time = test->end_time - test->start_time; + + switch (test->result) { + case TEST_RESULT_NOT_RUN: + print_summary(test->name, COLOR_YELLOW, "Not Run", ""); + not_run++; + break; + case TEST_RESULT_PASSED: + print_summary(test->name, COLOR_GREEN, "Passed", + "%8.3f seconds", exec_time); + passed++; + break; + case TEST_RESULT_FAILED: + print_summary(test->name, COLOR_RED, "Failed", + "%8.3f seconds", exec_time); + failed++; + break; + case TEST_RESULT_TIMED_OUT: + print_summary(test->name, COLOR_RED, "Timed out", + "%8.3f seconds", exec_time); + failed++; + break; + } + } + + tester_log("Total: %d, " + COLOR_GREEN "Passed: %d (%.1f%%)" COLOR_OFF ", " + COLOR_RED "Failed: %d" COLOR_OFF ", " + COLOR_YELLOW "Not Run: %d" COLOR_OFF, + not_run + passed + failed, passed, + (not_run + passed + failed) ? + (float) passed * 100 / (not_run + passed + failed) : 0, + failed, not_run); + + execution_time = get_elapsed_time(&tester_start); + tester_log("Overall execution time: %.3g seconds", execution_time); + + return failed; +} + +static void teardown_callback(void *user_data) +{ + struct test_case *test = user_data; + + test->stage = TEST_STAGE_TEARDOWN; + test->teardown = false; + + print_progress(test->name, COLOR_MAGENTA, "teardown"); + test->teardown_func(test->test_data); + +#ifdef HAVE_VALGRIND_MEMCHECK_H + VALGRIND_DO_ADDED_LEAK_CHECK; +#endif +} + +static void test_timeout(struct l_timeout *timer, void *user_data) +{ + struct test_case *test = user_data; + + l_timeout_remove(timer); + test->run_timer = NULL; + + test->result = TEST_RESULT_TIMED_OUT; + print_progress(test->name, COLOR_RED, "test timed out"); + + l_idle_oneshot(teardown_callback, test, NULL); +} + +static void next_test_case(void) +{ + struct test_case *test; + + if (test_entry) + test_entry = test_entry->next; + else + test_entry = l_queue_get_entries(test_list); + + if (!test_entry) { + mainloop_quit(); + return; + } + + test = test_entry->data; + + tester_log(""); + print_progress(test->name, COLOR_BLACK, "init"); + + test->start_time = get_elapsed_time(&tester_start); + + if (test->timeout > 0) + test->run_timer = l_timeout_create(test->timeout, test_timeout, + test, NULL); + + test->stage = TEST_STAGE_PRE_SETUP; + + test->pre_setup_func(test->test_data); +} + +static void setup_callback(void *user_data) +{ + struct test_case *test = user_data; + + test->stage = TEST_STAGE_SETUP; + + print_progress(test->name, COLOR_BLUE, "setup"); + test->setup_func(test->test_data); +} + +static void run_callback(void *user_data) +{ + struct test_case *test = user_data; + + test->stage = TEST_STAGE_RUN; + + print_progress(test->name, COLOR_BLACK, "run"); + test->test_func(test->test_data); +} + +static void done_callback(void *user_data) +{ + struct test_case *test = user_data; + + test->end_time = get_elapsed_time(&tester_start); + + print_progress(test->name, COLOR_BLACK, "done"); + next_test_case(); +} + +void tester_pre_setup_complete(void) +{ + struct test_case *test; + + if (!test_entry) + return; + + test = test_entry->data; + + if (test->stage != TEST_STAGE_PRE_SETUP) + return; + + l_idle_oneshot(setup_callback, test, NULL); +} + +void tester_pre_setup_failed(void) +{ + struct test_case *test; + + if (!test_entry) + return; + + test = test_entry->data; + + if (test->stage != TEST_STAGE_PRE_SETUP) + return; + + print_progress(test->name, COLOR_RED, "pre setup failed"); + + l_idle_oneshot(done_callback, test, NULL); +} + +void tester_setup_complete(void) +{ + struct test_case *test; + + if (!test_entry) + return; + + test = test_entry->data; + + if (test->stage != TEST_STAGE_SETUP) + return; + + print_progress(test->name, COLOR_BLUE, "setup complete"); + + l_idle_oneshot(run_callback, test, NULL); +} + +void tester_setup_failed(void) +{ + struct test_case *test; + + if (!test_entry) + return; + + test = test_entry->data; + + if (test->stage != TEST_STAGE_SETUP) + return; + + test->stage = TEST_STAGE_POST_TEARDOWN; + + l_timeout_remove(test->run_timer); + test->run_timer = NULL; + + print_progress(test->name, COLOR_RED, "setup failed"); + print_progress(test->name, COLOR_MAGENTA, "teardown"); + + test->post_teardown_func(test->test_data); +} + +static void test_result(enum test_result result) +{ + struct test_case *test; + + if (!test_entry) + return; + + test = test_entry->data; + + if (test->stage != TEST_STAGE_RUN) + return; + + l_timeout_remove(test->run_timer); + test->run_timer = NULL; + + test->result = result; + switch (result) { + case TEST_RESULT_PASSED: + print_progress(test->name, COLOR_GREEN, "test passed"); + break; + case TEST_RESULT_FAILED: + print_progress(test->name, COLOR_RED, "test failed"); + break; + case TEST_RESULT_NOT_RUN: + print_progress(test->name, COLOR_YELLOW, "test not run"); + break; + case TEST_RESULT_TIMED_OUT: + print_progress(test->name, COLOR_RED, "test timed out"); + break; + } + + if (test->teardown) + return; + + test->teardown = true; + + l_idle_oneshot(teardown_callback, test, NULL); +} + +void tester_test_passed(void) +{ + test_result(TEST_RESULT_PASSED); +} + +void tester_test_failed(void) +{ + test_result(TEST_RESULT_FAILED); +} + +void tester_test_abort(void) +{ + test_result(TEST_RESULT_NOT_RUN); +} + +void tester_teardown_complete(void) +{ + struct test_case *test; + + if (!test_entry) + return; + + test = test_entry->data; + + if (test->stage != TEST_STAGE_TEARDOWN) + return; + + test->stage = TEST_STAGE_POST_TEARDOWN; + + test->post_teardown_func(test->test_data); +} + +void tester_teardown_failed(void) +{ + struct test_case *test; + + if (!test_entry) + return; + + test = test_entry->data; + + if (test->stage != TEST_STAGE_TEARDOWN) + return; + + test->stage = TEST_STAGE_POST_TEARDOWN; + + tester_post_teardown_failed(); +} + +void tester_post_teardown_complete(void) +{ + struct test_case *test; + + if (!test_entry) + return; + + test = test_entry->data; + + if (test->stage != TEST_STAGE_POST_TEARDOWN) + return; + + print_progress(test->name, COLOR_MAGENTA, "teardown complete"); + + l_idle_oneshot(done_callback, test, NULL); +} + +void tester_post_teardown_failed(void) +{ + struct test_case *test; + + if (!test_entry) + return; + + test = test_entry->data; + + if (test->stage != TEST_STAGE_POST_TEARDOWN) + return; + + print_progress(test->name, COLOR_RED, "teardown failed"); + + l_idle_oneshot(done_callback, test, NULL); +} + +static void start_tester(void *user_data) +{ + gettimeofday(&tester_start, NULL); + next_test_case(); +} + +struct wait_data { + unsigned int seconds; + struct test_case *test; + tester_wait_func_t func; + void *user_data; +}; + +static void wait_callback(struct l_timeout *timer, void *user_data) +{ + struct wait_data *wait = user_data; + struct test_case *test = wait->test; + + wait->seconds--; + + if (wait->seconds > 0) { + print_progress(test->name, COLOR_BLACK, "%u seconds left", + wait->seconds); + return; + } + + print_progress(test->name, COLOR_BLACK, "waiting done"); + + wait->func(wait->user_data); + + free(wait); + + l_timeout_remove(timer); +} + +void tester_wait(unsigned int seconds, tester_wait_func_t func, + void *user_data) +{ + struct test_case *test; + struct wait_data *wait; + + if (!func || seconds < 1) + return; + + if (!test_entry) + return; + + test = test_entry->data; + + wait = new0(struct wait_data, 1); + wait->seconds = seconds; + wait->test = test; + wait->func = func; + wait->user_data = user_data; + + l_timeout_create(1000, wait_callback, wait, NULL); + + print_progress(test->name, COLOR_BLACK, "waiting %u seconds", seconds); +} + +static void signal_callback(int signum, void *user_data) +{ + static bool terminated = false; + + switch (signum) { + case SIGINT: + case SIGTERM: + if (!terminated) + mainloop_quit(); + + terminated = true; + break; + } +} + +bool tester_use_quiet(void) +{ + return option_quiet; +} + +bool tester_use_debug(void) +{ + return option_debug; +} + +static const struct option options[] = { + { "version", no_argument, NULL, 'v' }, + { "quiet", no_argument, NULL, 'q' }, + { "debug", no_argument, NULL, 'd' }, + { "monitor", no_argument, NULL, 'm' }, + { "list", no_argument, NULL, 'l' }, + { "prefix", required_argument, NULL, 'p' }, + { } +}; + +static void usage(void) +{ + fprintf(stderr, + "Usage:\n" + "\%s [options]\n", tester_name); + fprintf(stderr, + "Options:\n" + "\t--version Show version information and exit\n" + "\t--quiet Run tests without logging\n" + "\t--debug Run tests with debug output\n" + "\t--monitor Enable monitor output\n" + "\t--list Only list the tests to be run\n" + "\t--prefix Run tests matching provided prefix\n"); +} + +void tester_init(int *argc, char ***argv) +{ + tester_name = strrchr(*argv[0], '/'); + if (!tester_name) + tester_name = strdup(*argv[0]); + else + tester_name = strdup(++tester_name); + + for (;;) { + int opt; + + opt = getopt_long(*argc, *argv, "p:vqdml", options, NULL); + if (opt < 0) + break; + + switch (opt) { + case 'v': + printf("%s\n", VERSION); + exit(EXIT_SUCCESS); + case 'q': + option_quiet = true; + break; + case 'd': + option_debug = true; + break; + case 'm': + option_monitor = true; + break; + case 'l': + option_list = true; + break; + case 'p': + option_prefix = optarg; + break; + default: + usage(); + exit(EXIT_SUCCESS); + } + } + + mainloop_init(); + + test_list = l_queue_new(); +} + +int tester_run(void) +{ + int ret; + + if (option_list) { + mainloop_quit(); + return EXIT_SUCCESS; + } + + l_idle_oneshot(start_tester, NULL, NULL); + + mainloop_run_with_signal(signal_callback, NULL); + + ret = tester_summarize(); + + l_queue_destroy(test_list, test_destroy); + + if (option_monitor) + bt_log_close(); + + return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; +} From patchwork Sat Nov 7 07:03:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inga Stotland X-Patchwork-Id: 321185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90E37C5517A for ; Sat, 7 Nov 2020 07:03:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3223D20888 for ; Sat, 7 Nov 2020 07:03:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727809AbgKGHD3 (ORCPT ); Sat, 7 Nov 2020 02:03:29 -0500 Received: from mga17.intel.com ([192.55.52.151]:45622 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725985AbgKGHD3 (ORCPT ); Sat, 7 Nov 2020 02:03:29 -0500 IronPort-SDR: V/0cWZcYEfSyEEiZaJxycQLTjA4xE/6r2/v2NtNVNC8+8uK6fC3ypirfA9dwvJy9kPPaSEiBSo W1XbW/MRu1bg== X-IronPort-AV: E=McAfee;i="6000,8403,9797"; a="149485514" X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="149485514" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:29 -0800 IronPort-SDR: sV8pnVHdorLtD3X4e9DyGW0njEJ1xe+gu0dlP1uPpxTlvbEoOdvmBD8AT/Mh6Jc2j4VhwSbKJt TQZmfYQXthFQ== X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="359032019" Received: from ralassax-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.209.101.141]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:29 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, Inga Stotland Subject: [RFC PATCH BlueZ 04/10] tools/sco-tester: Convert to use ELL library Date: Fri, 6 Nov 2020 23:03:06 -0800 Message-Id: <20201107070312.8561-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201107070312.8561-1-inga.stotland@intel.com> References: <20201107070312.8561-1-inga.stotland@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This reworks the source code to use ELL primitives and removes dependecies on GLib. --- Makefile.tools | 4 ++-- tools/sco-tester.c | 33 ++++++++++++++------------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Makefile.tools b/Makefile.tools index 259427443..15613a5c9 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -154,12 +154,12 @@ tools_gap_tester_LDADD = lib/libbluetooth-internal.la \ src/libshared-ell.la $(ell_ldadd) tools_sco_tester_SOURCES = tools/sco-tester.c monitor/bt.h \ - emulator/hciemu.h emulator/hciemu.c \ + emulator/hciemu.h emulator/hciemu-ell.c \ emulator/btdev.h emulator/btdev.c \ emulator/bthost.h emulator/bthost.c \ emulator/smp.c tools_sco_tester_LDADD = lib/libbluetooth-internal.la \ - src/libshared-glib.la $(GLIB_LIBS) + src/libshared-ell.la $(ell_ldadd) tools_hci_tester_SOURCES = tools/hci-tester.c monitor/bt.h tools_hci_tester_LDADD = src/libshared-glib.la $(GLIB_LIBS) diff --git a/tools/sco-tester.c b/tools/sco-tester.c index 2b8dc0d4a..c3c43a1c3 100644 --- a/tools/sco-tester.c +++ b/tools/sco-tester.c @@ -17,7 +17,7 @@ #include #include -#include +#include #include "lib/bluetooth.h" #include "lib/sco.h" @@ -36,7 +36,7 @@ struct test_data { uint16_t mgmt_index; struct hciemu *hciemu; enum hciemu_type hciemu_type; - unsigned int io_id; + struct l_io *io; bool disable_esco; }; @@ -196,20 +196,21 @@ static void test_data_free(void *test_data) { struct test_data *data = test_data; - if (data->io_id > 0) - g_source_remove(data->io_id); + if (data->io) { + l_io_destroy(data->io); + data->io = NULL; + } - free(data); + l_free(data); } #define test_sco_full(name, data, setup, func, _disable_esco) \ do { \ struct test_data *user; \ - user = malloc(sizeof(struct test_data)); \ + user = l_new(struct test_data, 1); \ if (!user) \ break; \ user->hciemu_type = HCIEMU_TYPE_BREDRLE; \ - user->io_id = 0; \ user->test_data = data; \ user->disable_esco = _disable_esco; \ tester_add_full(name, data, \ @@ -474,17 +475,14 @@ static int connect_sco_sock(struct test_data *data, int sk) return 0; } -static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond, - gpointer user_data) +static bool sco_connect_cb(struct l_io *io, void *user_data) { struct test_data *data = tester_get_data(); const struct sco_client_data *scodata = data->test_data; int err, sk_err, sk; socklen_t len = sizeof(sk_err); - data->io_id = 0; - - sk = g_io_channel_unix_get_fd(io); + sk = l_io_get_fd(io); if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0) err = -errno; @@ -501,13 +499,12 @@ static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond, else tester_test_passed(); - return FALSE; + return false; } static void test_connect(const void *test_data) { struct test_data *data = tester_get_data(); - GIOChannel *io; int sk; sk = create_sco_sock(data); @@ -522,12 +519,10 @@ static void test_connect(const void *test_data) return; } - io = g_io_channel_unix_new(sk); - g_io_channel_set_close_on_unref(io, TRUE); - - data->io_id = g_io_add_watch(io, G_IO_OUT, sco_connect_cb, NULL); + data->io = l_io_new(sk); + l_io_set_close_on_destroy(data->io, true); - g_io_channel_unref(io); + l_io_set_write_handler(data->io, sco_connect_cb, NULL, NULL); tester_print("Connect in progress"); } From patchwork Sat Nov 7 07:03:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inga Stotland X-Patchwork-Id: 321184 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15C61C388F9 for ; Sat, 7 Nov 2020 07:03:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCE5E20872 for ; Sat, 7 Nov 2020 07:03:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727813AbgKGHDa (ORCPT ); Sat, 7 Nov 2020 02:03:30 -0500 Received: from mga17.intel.com ([192.55.52.151]:45622 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725985AbgKGHDa (ORCPT ); Sat, 7 Nov 2020 02:03:30 -0500 IronPort-SDR: tEKwUxU8A+jU6Z5BqXPdUT7vl0QNHIok9bzta4AqLBGXp6Wg+a9JcJoy0WAge7HeQrr8H2gU09 kkmphk9kD0Og== X-IronPort-AV: E=McAfee;i="6000,8403,9797"; a="149485515" X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="149485515" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:30 -0800 IronPort-SDR: t/QIq2jT4TazEDnX7BRxEpEOzn+SiZtEcJyR3PcHfPTjHANRGbvqi5gQLEaqEF/IUnR11f7a9h P61MazvqfpNA== X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="359032023" Received: from ralassax-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.209.101.141]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:29 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, Inga Stotland Subject: [RFC PATCH BlueZ 05/10] tools/userchan-tester: Convert to use ELL library Date: Fri, 6 Nov 2020 23:03:07 -0800 Message-Id: <20201107070312.8561-6-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201107070312.8561-1-inga.stotland@intel.com> References: <20201107070312.8561-1-inga.stotland@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This reworks the source code to use ELL primitives and removes dependecies on GLib. --- Makefile.tools | 4 ++-- tools/userchan-tester.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile.tools b/Makefile.tools index 15613a5c9..7c29e115b 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -165,12 +165,12 @@ tools_hci_tester_SOURCES = tools/hci-tester.c monitor/bt.h tools_hci_tester_LDADD = src/libshared-glib.la $(GLIB_LIBS) tools_userchan_tester_SOURCES = tools/userchan-tester.c monitor/bt.h \ - emulator/hciemu.h emulator/hciemu.c \ + emulator/hciemu.h emulator/hciemu-ell.c \ emulator/btdev.h emulator/btdev.c \ emulator/bthost.h emulator/bthost.c \ emulator/smp.c tools_userchan_tester_LDADD = lib/libbluetooth-internal.la \ - src/libshared-glib.la $(GLIB_LIBS) + src/libshared-ell.la $(ell_ldadd) endif if TOOLS diff --git a/tools/userchan-tester.c b/tools/userchan-tester.c index c17644fb8..21c853221 100644 --- a/tools/userchan-tester.c +++ b/tools/userchan-tester.c @@ -18,8 +18,6 @@ #include #include -#include - #include "lib/bluetooth.h" #include "lib/hci.h" #include "lib/mgmt.h" From patchwork Sat Nov 7 07:03:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inga Stotland X-Patchwork-Id: 321183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 383CBC5517A for ; Sat, 7 Nov 2020 07:03:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF03620872 for ; Sat, 7 Nov 2020 07:03:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727829AbgKGHDc (ORCPT ); Sat, 7 Nov 2020 02:03:32 -0500 Received: from mga17.intel.com ([192.55.52.151]:45628 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727824AbgKGHDb (ORCPT ); Sat, 7 Nov 2020 02:03:31 -0500 IronPort-SDR: BqVMcGsCafbJSSAEoXkIj9+P8yAr6ihIOlrBHuIgFGjzZ2lxZGVnI2L977TE/06iZaA2y3CQuH qZVms5Bn58Ag== X-IronPort-AV: E=McAfee;i="6000,8403,9797"; a="149485518" X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="149485518" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:31 -0800 IronPort-SDR: upLVFUf7HTEO/HlFMAD/MZFS72CX9FM4iRjIQmF5GECpAe/1P94yZWE1uWP8XKvMbXuiNLQE84 ehSilGM+hFzQ== X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="359032035" Received: from ralassax-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.209.101.141]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:31 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, Inga Stotland Subject: [RFC PATCH BlueZ 07/10] tools/bnep-tester: Convert to use ELL library Date: Fri, 6 Nov 2020 23:03:09 -0800 Message-Id: <20201107070312.8561-8-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201107070312.8561-1-inga.stotland@intel.com> References: <20201107070312.8561-1-inga.stotland@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This reworks the source code to use ELL primitives and removes dependecies on GLib. --- Makefile.tools | 4 ++-- tools/bnep-tester.c | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Makefile.tools b/Makefile.tools index 83c30252d..8c79a528d 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -130,12 +130,12 @@ tools_rfcomm_tester_LDADD = lib/libbluetooth-internal.la \ src/libshared-glib.la $(GLIB_LIBS) tools_bnep_tester_SOURCES = tools/bnep-tester.c monitor/bt.h \ - emulator/hciemu.h emulator/hciemu.c \ + emulator/hciemu.h emulator/hciemu-ell.c \ emulator/btdev.h emulator/btdev.c \ emulator/bthost.h emulator/bthost.c \ emulator/smp.c tools_bnep_tester_LDADD = lib/libbluetooth-internal.la \ - src/libshared-glib.la $(GLIB_LIBS) + src/libshared-ell.la $(ell_ldadd) tools_smp_tester_SOURCES = tools/smp-tester.c monitor/bt.h \ emulator/hciemu.h emulator/hciemu-ell.c \ diff --git a/tools/bnep-tester.c b/tools/bnep-tester.c index 5e4d7fb6d..dab913862 100644 --- a/tools/bnep-tester.c +++ b/tools/bnep-tester.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include "lib/bluetooth.h" #include "lib/bnep.h" @@ -37,7 +37,6 @@ struct test_data { struct hciemu *hciemu; enum hciemu_type hciemu_type; const void *test_data; - unsigned int io_id; uint16_t conn_handle; }; @@ -192,11 +191,6 @@ static void test_post_teardown(const void *test_data) { struct test_data *data = tester_get_data(); - if (data->io_id > 0) { - g_source_remove(data->io_id); - data->io_id = 0; - } - hciemu_unref(data->hciemu); data->hciemu = NULL; } @@ -282,7 +276,6 @@ static void test_basic(const void *test_data) break; \ user->hciemu_type = HCIEMU_TYPE_BREDR; \ user->test_data = data; \ - user->io_id = 0; \ tester_add_full(name, data, \ test_pre_setup, setup, func, NULL, \ test_post_teardown, 2, user, test_data_free); \ From patchwork Sat Nov 7 07:03:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inga Stotland X-Patchwork-Id: 321182 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71B95C388F7 for ; Sat, 7 Nov 2020 07:03:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26DBE20872 for ; Sat, 7 Nov 2020 07:03:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbgKGHDe (ORCPT ); Sat, 7 Nov 2020 02:03:34 -0500 Received: from mga17.intel.com ([192.55.52.151]:45630 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727830AbgKGHDd (ORCPT ); Sat, 7 Nov 2020 02:03:33 -0500 IronPort-SDR: zDK7wJFGdaBCNb5q9yJikTT3Ow1SJGeHVGPAKXc0w/iZ0gucdJ0FoNH2xAmW3l5uBDl5LHa+iX BnA5YKipIJiw== X-IronPort-AV: E=McAfee;i="6000,8403,9797"; a="149485520" X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="149485520" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:33 -0800 IronPort-SDR: a8ln/8/M3Nn2eqo/0e2EcVg8SymcH4SVsEFGFmkER1De5ymuOgUlZL/3Aop/+RrNAO5T4zZg/S 3zLYywbGXuzw== X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="359032054" Received: from ralassax-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.209.101.141]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:33 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, Inga Stotland Subject: [RFC PATCH BlueZ 09/10] tools/mgmt-tester: Convert to use ELL library Date: Fri, 6 Nov 2020 23:03:11 -0800 Message-Id: <20201107070312.8561-10-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201107070312.8561-1-inga.stotland@intel.com> References: <20201107070312.8561-1-inga.stotland@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This reworks the source code to use ELL primitives and removes dependecies on GLib. --- Makefile.tools | 4 ++-- tools/mgmt-tester.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile.tools b/Makefile.tools index 03264cff9..e65547c3f 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -106,12 +106,12 @@ tools_3dsp_SOURCES = tools/3dsp.c monitor/bt.h tools_3dsp_LDADD = src/libshared-mainloop.la tools_mgmt_tester_SOURCES = tools/mgmt-tester.c monitor/bt.h \ - emulator/hciemu.h emulator/hciemu.c \ + emulator/hciemu.h emulator/hciemu-ell.c \ emulator/btdev.h emulator/btdev.c \ emulator/bthost.h emulator/bthost.c \ emulator/smp.c tools_mgmt_tester_LDADD = lib/libbluetooth-internal.la \ - src/libshared-glib.la $(GLIB_LIBS) + src/libshared-ell.la $(ell_ldadd) tools_l2cap_tester_SOURCES = tools/l2cap-tester.c monitor/bt.h \ emulator/hciemu.h emulator/hciemu-ell.c \ diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index d8554411f..75f6457d2 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include "lib/bluetooth.h" #include "lib/hci.h" @@ -130,7 +130,8 @@ static void read_info_callback(uint8_t status, uint16_t length, tester_print(" Name: %s", rp->name); tester_print(" Short name: %s", rp->short_name); - if (strcmp(hciemu_get_address(data->hciemu), addr)) { + if (!hciemu_get_address(data->hciemu) || + (strcmp(hciemu_get_address(data->hciemu), addr))) { tester_pre_setup_failed(); return; }