From patchwork Thu May 13 10:01:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1477984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FgnJ40gljz9sTD for ; Thu, 13 May 2021 20:01:56 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lh8AD-0000aU-Fr; Thu, 13 May 2021 10:01:53 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lh8AB-0000aO-MC for fwts-devel@lists.ubuntu.com; Thu, 13 May 2021 10:01:51 +0000 Received: from 112-104-30-83.adsl.dynamic.seed.net.tw ([112.104.30.83] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lh8AA-0005a1-R3 for fwts-devel@lists.ubuntu.com; Thu, 13 May 2021 10:01:51 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/4] uefirttime: check time services supported before testing (LP: #1913351) Date: Thu, 13 May 2021 18:01:42 +0800 Message-Id: <20210513100145.29713-1-ivan.hu@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" UEFI runtime tests are being done without checking RTPROT table which intruduced after UEFI 2.8a. This might lead to false alarm for those unsupported runtime service platforms. Add checking the time services supported status before runing the related tests. Signed-off-by: Ivan Hu Acked-by: Alex Hung Acked-by: Colin Ian King --- src/uefi/uefirttime/uefirttime.c | 84 ++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/uefi/uefirttime/uefirttime.c b/src/uefi/uefirttime/uefirttime.c index e2ab7d61..41503843 100644 --- a/src/uefi/uefirttime/uefirttime.c +++ b/src/uefi/uefirttime/uefirttime.c @@ -199,6 +199,12 @@ static int uefirttime_test1(fwts_framework *fw) EFI_TIME_CAPABILITIES efi_time_cap; uint64_t status = ~0ULL; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)) { + fwts_skipped(fw, "Skipping test, GetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + gettime.Capabilities = &efi_time_cap; gettime.Time = &efi_time; gettime.status = &status; @@ -234,6 +240,12 @@ static int uefirttime_test_gettime_invalid( struct efi_gettime gettime; uint64_t status = ~0ULL; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)) { + fwts_skipped(fw, "Skipping test, GetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + gettime.Capabilities = efi_time_cap; gettime.Time = efi_time; gettime.status = &status; @@ -286,6 +298,12 @@ static int uefirttime_test4(fwts_framework *fw) EFI_TIME time; EFI_TIME_CAPABILITIES efi_time_cap; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)) { + fwts_skipped(fw, "Skipping test, GetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + gettime.Capabilities = &efi_time_cap; gettime.Time = &oldtime; gettime.status = &status; @@ -330,6 +348,12 @@ static int uefirttime_test4(fwts_framework *fw) /* Unspecified timezone, local time */ time.TimeZone = 2047; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_TIME)) { + fwts_skipped(fw, "Skipping test, SetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + settime.Time = &time; status = ~0ULL; settime.status = &status; @@ -424,6 +448,12 @@ static int uefirttime_test_settime_invalid( long ioret; static uint64_t status; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_TIME)) { + fwts_skipped(fw, "Skipping test, SetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + status = ~0ULL; settime->status = &status; @@ -460,6 +490,12 @@ static int uefirttime_test_settime_invalid_time( uint64_t status = ~0ULL; int ret, ioret; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)) { + fwts_skipped(fw, "Skipping test, GetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + gettime.Time = &oldtime; gettime.status = &status; gettime.Capabilities = NULL; @@ -500,6 +536,9 @@ static int uefirttime_test_settime_invalid_time( ret = uefirttime_test_settime_invalid(fw, &settime); + if (ret == FWTS_SKIP) + return ret; + /* Restore original time */ settime.Time = &oldtime; status = ~0ULL; @@ -654,6 +693,12 @@ static int uefirttime_test18(fwts_framework *fw) uint8_t enabled, pending; EFI_TIME efi_time; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, GetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + getwakeuptime.Enabled = &enabled; getwakeuptime.Pending = &pending; getwakeuptime.Time = &efi_time; @@ -687,6 +732,12 @@ static int uefirttime_test_getwaketime_invalid( long ioret; static uint64_t status; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, GetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + status = ~0ULL; getwakeuptime->status = &status; @@ -777,6 +828,12 @@ static int uefirttime_test23(fwts_framework *fw) struct efi_getwakeuptime getwakeuptime; uint8_t enabled, pending; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_TIME)) { + fwts_skipped(fw, "Skipping test, GetTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + gettime.Capabilities = &efi_time_cap; gettime.Time = &oldtime; gettime.status = &status; @@ -795,6 +852,12 @@ static int uefirttime_test23(fwts_framework *fw) return FWTS_ERROR; } + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, SetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + /* change the hour, add 1 hour*/ addonehour(&oldtime); @@ -818,6 +881,12 @@ static int uefirttime_test23(fwts_framework *fw) sleep(1); + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, SetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + getwakeuptime.Enabled = &enabled; getwakeuptime.Pending = &pending; getwakeuptime.Time = &newtime; @@ -907,6 +976,12 @@ static int uefirttime_test_setwakeuptime_invalid( long ioret; static uint64_t status; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, SetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + status = ~0ULL; setwakeuptime->status = &status; @@ -954,6 +1029,12 @@ static int uefirttime_test_setwakeuptime_invalid_time( uint8_t pending, enabled; int ret, ioret; + if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_WAKEUP_TIME)) { + fwts_skipped(fw, "Skipping test, GetWakeupTime runtime " + "service is not supported on this platform."); + return FWTS_SKIP; + } + getwakeuptime.Enabled = &enabled; getwakeuptime.Pending = &pending; getwakeuptime.Time = &oldtime; @@ -996,6 +1077,9 @@ static int uefirttime_test_setwakeuptime_invalid_time( ret = uefirttime_test_setwakeuptime_invalid(fw, &setwakeuptime); + if (ret == FWTS_SKIP) + return ret; + /* Restore original time */ setwakeuptime.Time = &oldtime; status = ~0ULL;