From patchwork Wed Oct 18 16:13:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 827703 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yHHK92P8vz9sBd for ; Thu, 19 Oct 2017 03:17:49 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 0A3BDC21EE8; Wed, 18 Oct 2017 16:14:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E320AC21F01; Wed, 18 Oct 2017 16:13:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 02FF2C21E68; Wed, 18 Oct 2017 16:13:39 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lists.denx.de (Postfix) with ESMTPS id BB3C1C21EF3 for ; Wed, 18 Oct 2017 16:13:35 +0000 (UTC) Received: from workstation4.fritz.box ([94.114.42.150]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MVvi4-1dkvTC2m3E-00X16a; Wed, 18 Oct 2017 18:13:34 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Wed, 18 Oct 2017 18:13:16 +0200 Message-Id: <20171018161320.7231-15-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171018161320.7231-1-xypron.glpk@gmx.de> References: <20171018161320.7231-1-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:0fETWxJZo31vTrFv4GGeT4XB539Tumg/DzDZ7bMFRJjqwx8K0Xg sIqvhryG09/i+qHUgjocu+cLKmN/2D0TvXuGx+rucV18+V3XXclmdcVP4jC8taKyLxX8bs3 4NSGnAPSvDzItOEpee9aXqktscIoKbt36ue/EKQo/2nEh/ood04gbscGvsUhOZgh2/e/WR0 OI9yN8i1FvKAkdKwfjo/g== X-UI-Out-Filterresults: notjunk:1; V01:K0:xy1pA2q+j1U=:c1KMIxzJWI+GnC/eBB290U 9y63hV1K/EWdx3kq6J9XYJ7OnARnX8RX8j7ZfGrbTdWAaoOkw51aL4mGm4/GKNkb2vntKg4Y+ Jlk3WG9+t0XeTHDWDCT/XK/2TzLWNLvMJ+lAEh/a+qc15IqAvuXsEpN99/iCXbd6Rii2vAk81 BmPYv/OifaCqN6RGPWQGJgSRR5sbcp8bBV9b12qy4aUcfSbUlbDvhtcpHE4DQUhXNqEqXpQsn 4CyeQw9608nQyPgGnQSU+NYvBzum0wK+JUz8aU+f60w7cL7z1Nq5Qv5ay0aefkyt7Xm5S6aGI 48HxlVovPTJ6BtQXZ+DVP+ZQ8Zs4iqyLhRiWH7r9tn5uwHCQIleIGsD1O7EyWd0g0lghNHfqQ k5fFd3f5FP5MUEApZhqq0ILWkIesDNNAiD0ANX3SMTgydoTUJVW10x8beZ9TxcwHtvibaRlI7 QEAx4APPK72Ta4je0/fSoQb6YrY/MJH9dS7NlhHLN9vZPAB6dTAHNJTsV46XHdq1kg1BPvEFn nfl+6Xs0UzyIGMQEZt1KoxV/LQTqj/Ackl4Yoozm3fX9OU3x38Yr7Y48FKH0r84JiiwTWmNBd w/aFWGwxUtDyB9zrMEWL8gjsXSW1wEWVdOjL650K7CALZKT8d7wq9+5+75XcUKkfCLrGfLlNc 0mljUp3RHwIiPLKdtJ9X6m1BZm6qLqtMnk0Xv8UbEJTILq1fd7Thwb3agdTW+NiNLCq4wiVh6 4oqsaMWzGwRumvC8WvqeDC2txDmenUsUyBvqEse8UJik1k9UvFUNO5N615c/xm0YzNtAzGTCl HsBAhOXxDwb3VAhh1PplvtE+FWGxg== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v4 14/18] efi_selftest: test reboot by watchdog X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" A test is added that verifies that the watchdog timer actually causes a reboot upon timeout. The test is only executed on request using setenv efi_selftest watchdog reboot bootefi selftest Signed-off-by: Heinrich Schuchardt --- v4 no change v3 correct comments v2 no change --- lib/efi_selftest/efi_selftest_watchdog.c | 68 ++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_watchdog.c b/lib/efi_selftest/efi_selftest_watchdog.c index f8c5404000..e4af38407f 100644 --- a/lib/efi_selftest/efi_selftest_watchdog.c +++ b/lib/efi_selftest/efi_selftest_watchdog.c @@ -5,11 +5,16 @@ * * SPDX-License-Identifier: GPL-2.0+ * - * This unit test checks that the watchdog timer will not cause - * a system restart during the timeout period after a timer reset. + * The 'watchdog timer' unit test checks that the watchdog timer + * will not cause a system restart during the timeout period after + * a timer reset. * - * Testing that the watchdog timer actually will reset the system - * after a timeout is not possible within the used framework. + * The 'watchdog reboot' unit test checks that the watchdog timer + * actually reboots the system after a timeout. The test is only + * executed on explicit request. Use the following commands: + * + * setenv efi_selftest watchdog reboot + * bootefi selftest */ #include @@ -28,6 +33,7 @@ static struct efi_event *event_notify; static struct efi_event *event_wait; static struct efi_boot_services *boottime; static struct notify_context notification_context; +static bool watchdog_reset; /* * Notification function, increments the notfication count if parameter @@ -88,6 +94,34 @@ static int setup(const efi_handle_t handle, return EFI_ST_SUCCESS; } +/* + * Execute the test resetting the watchdog in a timely manner. No reboot occurs. + * + * @handle: handle of the loaded image + * @systable: system table + * @return: EFI_ST_SUCCESS for success + */ +static int setup_timer(const efi_handle_t handle, + const struct efi_system_table *systable) +{ + watchdog_reset = true; + return setup(handle, systable); +} + +/* + * Execute the test without resetting the watchdog. A system reboot occurs. + * + * @handle: handle of the loaded image + * @systable: system table + * @return: EFI_ST_SUCCESS for success + */ +static int setup_reboot(const efi_handle_t handle, + const struct efi_system_table *systable) +{ + watchdog_reset = false; + return setup(handle, systable); +} + /* * Tear down unit test. * @@ -146,11 +180,14 @@ static int execute(void) efi_st_error("Setting watchdog timer failed\n"); return EFI_ST_FAILURE; } - /* Set 600 ms timer */ - ret = boottime->set_timer(event_notify, EFI_TIMER_PERIODIC, 6000000); - if (ret != EFI_SUCCESS) { - efi_st_error("Could not set timer\n"); - return EFI_ST_FAILURE; + if (watchdog_reset) { + /* Set 600 ms timer */ + ret = boottime->set_timer(event_notify, EFI_TIMER_PERIODIC, + 6000000); + if (ret != EFI_SUCCESS) { + efi_st_error("Could not set timer\n"); + return EFI_ST_FAILURE; + } } /* Set 1350 ms timer */ ret = boottime->set_timer(event_wait, EFI_TIMER_RELATIVE, 13500000); @@ -176,10 +213,19 @@ static int execute(void) return EFI_ST_SUCCESS; } -EFI_UNIT_TEST(watchdog) = { +EFI_UNIT_TEST(watchdog1) = { .name = "watchdog timer", .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, - .setup = setup, + .setup = setup_timer, + .execute = execute, + .teardown = teardown, +}; + +EFI_UNIT_TEST(watchdog2) = { + .name = "watchdog reboot", + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + .setup = setup_reboot, .execute = execute, .teardown = teardown, + .on_request = true, };