From patchwork Wed Jan 26 08:57:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1584388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=hDuMmCSD; dkim-atps=neutral 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JkHff6L2Hz9t6h for ; Wed, 26 Jan 2022 19:57:30 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nCe7K-0006Xv-HB; Wed, 26 Jan 2022 08:57:26 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nCe7I-0006Xo-HX for fwts-devel@lists.ubuntu.com; Wed, 26 Jan 2022 08:57:24 +0000 Received: from canonical.com (unknown [175.182.110.232]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id A265940E51 for ; Wed, 26 Jan 2022 08:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1643187444; bh=VgRSDyiiAGGM0wOQMz5CvB28LbcccG1+l7ujhT0H63M=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=hDuMmCSDuLQ4Dler3afnMJ66WrkOIbk37HECjmlNqwGEz4WIixneI3zp/wz3mxTYG ulFWASLJyY5T3yTVIRjkVzQuhJ5z9PpsVZzU2tG2RYDwwD4GnesvkvhfXFWvWL6OkB Z2vdCYx9pNeWSb+N4uFCZNG52oTWK2hCStk3g1s+f4mxcJOTGF+GC0axaRkuIDO9Pb F9Zv5vAxSpFSj840ms+7HNn15gnqkMJwbyTyjbT1b2IT/rG6oCdgCC7XY5K+2RmBdH IZJ2SAb2R8yJcyNdU1YU7T12hGcX7TMGavVQt8dLwD7xAJbiWJbtglsV3NWEL8I2o9 Nqrs6Xzd6rR9A== From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] uefirtmisc: add option to specify iterations get next high monitonic count Date: Wed, 26 Jan 2022 16:57:16 +0800 Message-Id: <20220126085716.57274-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" BugLink: https://bugs.launchpad.net/fwts/+bug/1958206 Set the default of get next high monotonic count stress test to 50, and add option to specify iterations. ex: $sudo fwts --uefitests --uefi-get-mn-count-multiple=5 Signed-off-by: Ivan Hu Reviewed-by: Sunny Wang Signed-off-by: Ivan Hu Acked-by: Alex Hung --- src/uefi/uefirtmisc/uefirtmisc.c | 54 ++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/uefi/uefirtmisc/uefirtmisc.c b/src/uefi/uefirtmisc/uefirtmisc.c index f6038f5f..b3ee56ca 100644 --- a/src/uefi/uefirtmisc/uefirtmisc.c +++ b/src/uefi/uefirtmisc/uefirtmisc.c @@ -34,6 +34,9 @@ #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 +static uint32_t uefi_get_mn_count_multiple = 50; +#define UEFI_GET_NEXT_HIGH_MN_COUNT_MULTIPLE_MAX (10000) + #define EFI_CAPSULE_GUID \ { \ 0x3B6686BD, 0x0D76, 0x4030, {0xB7, 0x0E, 0xB5, \ @@ -197,7 +200,7 @@ static int uefirtmisc_test1(fwts_framework *fw) static int uefirtmisc_test2(fwts_framework *fw) { int ret; - uint32_t multitesttime = 512; + uint32_t multitesttime = uefi_get_mn_count_multiple; uint32_t i; static const uint32_t flag[] = { @@ -214,7 +217,9 @@ static int uefirtmisc_test2(fwts_framework *fw) return FWTS_SKIP; } - fwts_log_info(fw, "Stress testing for UEFI runtime service GetNextHighMonotonicCount interface."); + fwts_log_info(fw, "Stress testing for UEFI runtime service " + "GetNextHighMonotonicCount interface %" PRIu32 " times.", + multitesttime); ret = getnexthighmonotoniccount_test(fw, multitesttime); if (ret == FWTS_OK) fwts_passed(fw, "UEFI runtime service GetNextHighMonotonicCount" @@ -331,7 +336,47 @@ static int uefirtmisc_test4(fwts_framework *fw) return FWTS_OK; } +static int options_check(fwts_framework *fw) +{ + FWTS_UNUSED(fw); + + if ((uefi_get_mn_count_multiple < 1) || + (uefi_get_mn_count_multiple > + UEFI_GET_NEXT_HIGH_MN_COUNT_MULTIPLE_MAX)) { + fprintf(stderr, "uefi_get_mn_count_multiple is %" + PRIu32 ", it should be 1..%" PRIu32 "\n", + uefi_get_mn_count_multiple, + UEFI_GET_NEXT_HIGH_MN_COUNT_MULTIPLE_MAX); + return FWTS_ERROR; + } + return FWTS_OK; +} + +static int options_handler( + fwts_framework *fw, + int argc, + char * const argv[], + int option_char, + int long_index) +{ + FWTS_UNUSED(fw); + FWTS_UNUSED(argc); + FWTS_UNUSED(argv); + + if (option_char == 0) { + switch (long_index) { + case 0: /* --uefi_get_mn_count_multiple */ + uefi_get_mn_count_multiple = strtoul(optarg, NULL, 10); + break; + } + } + return FWTS_OK; +} +static fwts_option options[] = { + { "uefi-get-mn-count-multiple", "", 1, "Run uefirtmisc getnexthighmonotoniccount test multiple times." }, + { NULL, NULL, 0, NULL } +}; static fwts_framework_minor_test uefirtmisc_tests[] = { { uefirtmisc_test1, "Test for UEFI miscellaneous runtime service interfaces." }, { uefirtmisc_test2, "Stress test for UEFI miscellaneous runtime service interfaces." }, @@ -344,7 +389,10 @@ static fwts_framework_ops uefirtmisc_ops = { .description = "UEFI miscellaneous runtime service interface tests.", .init = uefirtmisc_init, .deinit = uefirtmisc_deinit, - .minor_tests = uefirtmisc_tests + .minor_tests = uefirtmisc_tests, + .options = options, + .options_handler = options_handler, + .options_check = options_check }; FWTS_REGISTER("uefirtmisc", &uefirtmisc_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_UEFI | FWTS_FLAG_UNSAFE | FWTS_FLAG_ROOT_PRIV | FWTS_FLAG_XBBR)