From patchwork Fri Jun 7 08:41:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 249619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 0219E2C007B for ; Fri, 7 Jun 2013 18:41:52 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UksF4-0007mX-PE; Fri, 07 Jun 2013 08:41:50 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UksEw-0007mF-5a for fwts-devel@lists.ubuntu.com; Fri, 07 Jun 2013 08:41:42 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1UksEw-0000dJ-0N for fwts-devel@lists.ubuntu.com; Fri, 07 Jun 2013 08:41:42 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 3/3] lib: acpica + fwts_framework: add --acpica-debug option Date: Fri, 7 Jun 2013 09:41:39 +0100 Message-Id: <1370594499-25991-4-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1370594499-25991-1-git-send-email-colin.king@canonical.com> References: <1370594499-25991-1-git-send-email-colin.king@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King fwts_acpica had some ACPICA debug helpers that were originally intended to dump out ACPICA debug messages, but it was never fully implemented. Remove these helpers fwts_acpica_set_log_callback and fwts_acpica_debug_command as well as the callback func pointer fwts_acpica_log_callback_func as we can implement the debug in a better way. Re-work fwts_acpica_vprintf to now dump directly to the fwts log if fw->flags has FWTS_FLAG_ACPICA_DEBUG set. Add the new --acpica-debug option to the framework and documentation. The --acpica-debug option is to help the fwts developers to see the ACPICA internal warning and error messages rather than trying to guess why fwts has caused ACPICA to misfunction. Signed-off-by: Colin Ian King Acked-by: Acked-by: Keng-Yu Lin --- doc/fwts.1 | 4 ++++ src/acpica/fwts_acpica.c | 39 +++++++++++++++------------------------ src/lib/include/fwts_acpica.h | 2 -- src/lib/include/fwts_framework.h | 1 + src/lib/src/fwts_framework.c | 4 ++++ 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/doc/fwts.1 b/doc/fwts.1 index b6ef362..187751c 100644 --- a/doc/fwts.1 +++ b/doc/fwts.1 @@ -60,6 +60,10 @@ fwts options are as follow: .B \- output results to stdout. .TP +.B \-\-acpica\-debug +enable ACPICA debug warning and error messages when invoking the ACPICA subsystem. This is mainly +for fwts developers to help track down any ACPICA interfacing issues with fwts. +.TP .B \-a, \-\-all run all the tests. .TP diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c index 42b68f1..e396cd9 100644 --- a/src/acpica/fwts_acpica.c +++ b/src/acpica/fwts_acpica.c @@ -17,6 +17,8 @@ * */ +#define _GNU_SOURCE + #include #include #include @@ -96,7 +98,6 @@ static void *fwts_acpica_DSDT; static fwts_framework *fwts_acpica_fw; /* acpica context copy of fw */ static bool fwts_acpica_init_called; /* > 0, ACPICA initialised */ -static fwts_acpica_log_callback fwts_acpica_log_callback_func = NULL; /* logging call back func */ /* Semaphore Tracking */ @@ -384,25 +385,6 @@ ACPI_PHYSICAL_ADDRESS AeLocalGetRootPointer(void) } /* - * fwts_acpica_set_log_callback() - * define logging callback function as used by fwts_acpica_vprintf() - */ -void fwts_acpica_set_log_callback(fwts_framework *fw, fwts_acpica_log_callback func) -{ - fwts_acpica_log_callback_func = func; -} - -/* - * fwts_acpica_debug_command() - * run a debugging command, requires a logging callback function (or set to NULL for none). - */ -void fwts_acpica_debug_command(fwts_framework *fw, fwts_acpica_log_callback func, char *command) -{ - fwts_acpica_set_log_callback(fw, func); - AcpiDbCommandDispatch(command, NULL, NULL); -} - -/* * fwts_acpica_vprintf() * accumulate prints from ACPICA engine, emit them when we hit terminal '\n' */ @@ -411,10 +393,18 @@ void fwts_acpica_vprintf(const char *fmt, va_list args) static char *buffer; static size_t buffer_len; - char tmp[4096]; + char *tmp; size_t tmp_len; - vsnprintf(tmp, sizeof(tmp), fmt, args); + /* Only emit messages if in ACPICA debug mode */ + if (!(fwts_acpica_fw->flags & FWTS_FLAG_ACPICA_DEBUG)) + return; + + if (vasprintf(&tmp, fmt, args) < 0) { + fwts_log_info(fwts_acpica_fw, "Out of memory allocating ACPICA printf buffer."); + return; + } + tmp_len = strlen(tmp); if (buffer_len == 0) { @@ -434,11 +424,12 @@ void fwts_acpica_vprintf(const char *fmt, va_list args) } if (index(buffer, '\n') != NULL) { - if (fwts_acpica_log_callback_func) - fwts_acpica_log_callback_func(fwts_acpica_fw, buffer); + fwts_log_info(fwts_acpica_fw, "%s", buffer); free(buffer); buffer_len = 0; } + + free(tmp); } /* diff --git a/src/lib/include/fwts_acpica.h b/src/lib/include/fwts_acpica.h index 17a5988..ab492e7 100644 --- a/src/lib/include/fwts_acpica.h +++ b/src/lib/include/fwts_acpica.h @@ -26,8 +26,6 @@ typedef void (*fwts_acpica_log_callback)(fwts_framework *fw, const char *buffer) int fwts_acpica_init(fwts_framework *fw); int fwts_acpica_deinit(void); -void fwts_acpica_set_log_callback(fwts_framework *fw, fwts_acpica_log_callback func); -void fwts_acpica_debug_command(fwts_framework *fw, fwts_acpica_log_callback func, char *command); fwts_list *fwts_acpica_get_object_names(int type); void fwts_acpica_sem_count_clear(void); void fwts_acpica_sem_count_get(int *acquired, int *released); diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h index 7a540ad..ab831a9 100644 --- a/src/lib/include/fwts_framework.h +++ b/src/lib/include/fwts_framework.h @@ -36,6 +36,7 @@ typedef enum { FWTS_FLAG_FORCE_CLEAN = 0x00000004, FWTS_FLAG_SHOW_TESTS = 0x00000008, FWTS_FLAG_SHOW_PROGRESS_DIALOG = 0x00000010, + FWTS_FLAG_ACPICA_DEBUG = 0x00000020, FWTS_FLAG_BATCH = 0x00001000, FWTS_FLAG_INTERACTIVE = 0x00002000, FWTS_FLAG_BATCH_EXPERIMENTAL = 0x00004000, diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c index ff1e3b3..1cf49fc 100644 --- a/src/lib/src/fwts_framework.c +++ b/src/lib/src/fwts_framework.c @@ -82,6 +82,7 @@ static fwts_option fwts_framework_options[] = { { "unsafe", "U", 0, "Unsafe tests (tests that can potentially cause kernel oopses." }, { "filter-error-discard", "", 1, "Discard errors that match any of the specified labels." }, { "filter-error-keep", "", 1, "Keep errors that match any of the specified labels." }, + { "acpica-debug", "", 0, "Enable ACPICA debug/warning messages." }, { NULL, NULL, 0, NULL } }; @@ -1099,6 +1100,9 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar if (fwts_framework_filter_error_parse(optarg, &fw->errors_filter_keep) != FWTS_OK) return FWTS_ERROR; break; + case 36: /* --acpica-debug */ + fw->flags |= FWTS_FLAG_ACPICA_DEBUG; + break; } break; case 'a': /* --all */