From patchwork Tue Jan 8 16:29:59 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: 210430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 628932C0085 for ; Wed, 9 Jan 2013 03:30:04 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Tsc3v-000368-Kx; Tue, 08 Jan 2013 16:30:03 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Tsc3s-00035p-3R for fwts-devel@lists.ubuntu.com; Tue, 08 Jan 2013 16:30:00 +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 1Tsc3r-0007a9-Uq for fwts-devel@lists.ubuntu.com; Tue, 08 Jan 2013 16:30:00 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] acpi: method: refactor some of the passed messages Date: Tue, 8 Jan 2013 16:29:59 +0000 Message-Id: <1357662599-16843-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.8.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King We're using some common test passed messaged in a lot of the method tests, so add some helper functions and refactor the code a bit. Signed-off-by: Colin Ian King Acked-by: Keng-Yu Lin Acked-by: Ivan Hu --- src/acpi/method/method.c | 91 +++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c index f8330a7..170edb5 100644 --- a/src/acpi/method/method.c +++ b/src/acpi/method/method.c @@ -273,6 +273,31 @@ typedef void (*method_test_return)(fwts_framework *fw, char *name, /****************************************************************************/ /* + * method_passed_sane() + * helper function to report often used passed messages + */ +static void method_passed_sane( + fwts_framework *fw, + const char *name, + const char *type) +{ + fwts_passed(fw, "%s correctly returned a sane looking %s.", name, type); +} + +/* + * method_passed_sane_uint64() + * helper function to report often used passed uint64 values + */ +static void method_passed_sane_uint64( + fwts_framework *fw, + const char *name, + const uint64_t value) +{ + fwts_passed(fw, "%s correctly returned sane looking " + "value 0x%8.8" PRIx64 ".", name, value); +} + +/* * method_init() * initialize ACPI */ @@ -606,9 +631,7 @@ static void method_test_passed_failed_return( if (method_check_type(fw, name, buf, ACPI_TYPE_INTEGER) == FWTS_OK) { uint32_t val = (uint32_t)obj->Integer.Value; if ((val == 0) || (val == 1)) - fwts_passed(fw, - "%s correctly returned sane looking value " - "0x%8.8" PRIx32 ".", method, val); + method_passed_sane_uint64(fw, name, obj->Integer.Value); else { fwts_failed(fw, LOG_LEVEL_MEDIUM, "MethodReturnZeroOrOne", @@ -1743,9 +1766,7 @@ static void method_test_STA_return( } if (!failed) - fwts_passed(fw, - "_STA correctly returned sane looking " - "value 0x%8.8" PRIx64, obj->Integer.Value); + method_passed_sane_uint64(fw, name, obj->Integer.Value); } } @@ -1806,9 +1827,7 @@ static void method_test_SEG_return( obj->Integer.Value); fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN); } else - fwts_passed(fw, - "_SEG correctly returned sane looking " - "value 0x%8.8" PRIx64, obj->Integer.Value); + method_passed_sane_uint64(fw, name, obj->Integer.Value); } } @@ -2057,8 +2076,7 @@ static void method_test_Sx__return( obj->Package.Elements[1].Integer.Value); if (!failed) - fwts_passed(fw, "%s correctly returned sane looking package.", - name); + method_passed_sane(fw, name, "package"); } #define method_test_Sx_(name) \ @@ -2175,7 +2193,7 @@ static void method_test_CPC_return( method_test_type_mixed (fw, &failed, obj, 16, "EnableRegister"); if (!failed) - fwts_passed(fw, "_CPC correctly returned sane looking package."); + method_passed_sane(fw, name, "package"); } static int method_test_CPC(fwts_framework *fw) @@ -2301,8 +2319,7 @@ static void method_test_CSD_return( } if (!failed) - fwts_passed(fw, - "_CSD correctly returned sane looking package."); + method_passed_sane(fw, name, "package"); } static int method_test_CSD(fwts_framework *fw) @@ -2478,7 +2495,7 @@ static void method_test_CST_return( free(cst_elements_ok); if (!failed) - fwts_passed(fw, "%s correctly returned sane looking values.", name); + method_passed_sane(fw, name, "values"); } static int method_test_CST(fwts_framework *fw) @@ -2528,8 +2545,7 @@ static void method_test_PCT_return( } } if (!failed) - fwts_passed(fw, - "_PCT correctly returned sane looking package."); + method_passed_sane(fw, name, "package"); } static int method_test_PCT(fwts_framework *fw) @@ -2707,8 +2723,7 @@ static void method_test_PSS_return( } if (!failed) - fwts_passed(fw, - "_PSS correctly returned sane looking package."); + method_passed_sane(fw, name, "package"); } static int method_test_PSS(fwts_framework *fw) @@ -2864,8 +2879,7 @@ static void method_test_TSD_return( } if (!failed) - fwts_passed(fw, - "_TSD correctly returned sane looking package."); + method_passed_sane(fw, name, "package"); } static int method_test_TSD(fwts_framework *fw) @@ -3003,8 +3017,7 @@ static void method_test_TSS_return( free(tss_elements_ok); if (!failed) - fwts_passed(fw, - "_TSS correctly returned sane looking package."); + method_passed_sane(fw, name, "package"); } static int method_test_TSS(fwts_framework *fw) @@ -3043,9 +3056,7 @@ static void method_test_LID_return( FWTS_UNUSED(private); if (method_check_type(fw, name, buf, ACPI_TYPE_INTEGER) == FWTS_OK) - fwts_passed(fw, - "_LID correctly returned sane looking value 0x%8.8" PRIx64, - obj->Integer.Value); + method_passed_sane_uint64(fw, name, obj->Integer.Value); } static int method_test_LID(fwts_framework *fw) @@ -3077,9 +3088,7 @@ static void method_test_GCP_return( obj->Integer.Value); fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN); } else { - fwts_passed(fw, - "_GCP correctly returned sane looking " - "value 0x%8.8" PRIx64, obj->Integer.Value); + method_passed_sane_uint64(fw, name, obj->Integer.Value); } } } @@ -3143,9 +3152,7 @@ static void method_test_GWS_return( obj->Integer.Value); fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN); } else { - fwts_passed(fw, - "_GWS correctly returned sane looking " - "value 0x%8.8" PRIx64, obj->Integer.Value); + method_passed_sane_uint64(fw, name, obj->Integer.Value); } } } @@ -3812,9 +3819,7 @@ static void method_test_PSR_return( obj->Integer.Value); fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN); } else - fwts_passed(fw, - "_PSR correctly returned sane looking " - "value 0x%8.8" PRIx64, obj->Integer.Value); + method_passed_sane_uint64(fw, name, obj->Integer.Value); } } @@ -4006,9 +4011,7 @@ static void method_test_THERM_return( * should not test the value being returned. In this * case, just pass this as a valid return type. */ - fwts_passed(fw, - "%s correctly returned sane looking " - "return type.", name); + method_passed_sane(fw, name, "return type"); } else { /* * The evaluation probably was a hard-coded value, @@ -4074,12 +4077,8 @@ static void method_test_TCx_return( ACPI_OBJECT *obj, void *private) { - if (method_check_type(fw, name, buf, ACPI_TYPE_INTEGER) == FWTS_OK) { - char *method = (char *)private; - fwts_passed(fw, - "%s correctly returned sane looking value 0x%8.8x", - method, (uint32_t)obj->Integer.Value); - } + if (method_check_type(fw, name, buf, ACPI_TYPE_INTEGER) == FWTS_OK) + method_passed_sane_uint64(fw, (char*)private, obj->Integer.Value); } static int method_test_TC1(fwts_framework *fw) @@ -4164,9 +4163,7 @@ static void method_test_RTV_return( FWTS_UNUSED(private); if (method_check_type(fw, name, buf, ACPI_TYPE_INTEGER) == FWTS_OK) - fwts_passed(fw, - "_RTV correctly returned sane looking value 0x%8.8" PRIx64, - obj->Integer.Value); + method_passed_sane_uint64(fw, name, obj->Integer.Value); } static int method_test_RTV(fwts_framework *fw)