From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5ADBC433EF for ; Wed, 16 Mar 2022 03:27:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CB9BF83946; Wed, 16 Mar 2022 04:27:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="sXpv7Wkv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 76E3483947; Wed, 16 Mar 2022 04:27:07 +0100 (CET) Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 606428393D for ; Wed, 16 Mar 2022 04:27:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x62c.google.com with SMTP id n2so768228plf.4 for ; Tue, 15 Mar 2022 20:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=buVa7FPBKvg0JPcbi6xStTgGXREoQO57Cvfhn0xSLEU=; b=sXpv7WkvlcToCBT7Y/IvbeDRco9SRMZjwCFlQ73CzckJaddaxRIqLr9S6e9FXyrJm5 53BWnWmEM/0AxBt3zIVrcJ/AaA9gjHrlegSebFDG8kiysh7qyWKLDv6Fnpwx+AW1ADIT zxDuCd3cu6jIVvfoHAk9DUvUOrlGvxzg94V/TY9yvMRDENbJRcCVSiW5J+l0YMWBfgJY q/iV1vefHEKOE2WhOMU0zLHWxlsa+dv8InWfKWGuu2B0s2SjcKjjqutUglj618TqJQMl Zyyx5HWPdQ818MykAOFVmjjSQyu/5SJUYM2sbk1UXPZUQ5ENGaCU+4PlVutQ04oJl8bL Lg9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=buVa7FPBKvg0JPcbi6xStTgGXREoQO57Cvfhn0xSLEU=; b=SMYx5PcZjXrczLYmUdibZQubYOCDjjHMvxmHNtMMQbg3OqMJxW9bF44YkZDgvJIW9d ldRoq97yyqVKV0JNXmqgXPA4JE88l2+gKiqrechaohWSEzLI94N2XBJiXtaGrRvQOGgW clKuKbZdLoUsmXNgfHZDtTlICMQENOwfcAXivnhYYQXlQCipXXg9BYXvzJZCaa0gfoQz hg91uPsiGFF2rT3UM9AwPn677u8DK3ZL/Z99Go8Nwwo3678ag9IcOBLkqfJ4Um3yaNTP Wq8yW6RdBPzEXZfGgHXDGKoQCR375uMJHKFWsAz0RMwbk0saLrpqhlK1qrZl+pGdbEgq hKXA== X-Gm-Message-State: AOAM532OC7WP75XZDWrpeV74dYwuOZccth93Mcg5MB1pkCy/BzKwzKqJ gM0k398OlXqhFALlCyx5R+EOCw== X-Google-Smtp-Source: ABdhPJwq7L4+ExCVds+glurStbW5ng7LpkyTC91Z9ILlvlXPsVG6NAeQPNTDbZTsAOD9bxwgEAg61w== X-Received: by 2002:a17:902:ec8f:b0:152:939:ac45 with SMTP id x15-20020a170902ec8f00b001520939ac45mr32114215plg.61.1647401220490; Tue, 15 Mar 2022 20:27:00 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:6c72:8981:bafe:71f4]) by smtp.gmail.com with ESMTPSA id x15-20020a056a00188f00b004f7675962d5sm647135pfh.175.2022.03.15.20.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 20:27:00 -0700 (PDT) Date: Wed, 16 Mar 2022 12:26:54 +0900 From: AKASHI Takahiro To: Simon Glass Cc: Masami Hiramatsu , Heinrich Schuchardt , Tom Rini , U-Boot Mailing List , Patrick Delaunay , Patrice Chotard , Alexander Graf , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: Re: [PATCH] test/py: efi_capsule: Handle expected reset after capsule on disk Message-ID: <20220316032654.GA23816@laputa> Mail-Followup-To: AKASHI Takahiro , Simon Glass , Masami Hiramatsu , Heinrich Schuchardt , Tom Rini , U-Boot Mailing List , Patrick Delaunay , Patrice Chotard , Alexander Graf , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Etienne Carriere , Sughosh Ganu , Paul Liu References: <20220314010813.GA37492@laputa> <20220314024258.GC37492@laputa> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On Tue, Mar 15, 2022 at 09:13:15PM -0600, Simon Glass wrote: > Hi Masami, > > On Tue, 15 Mar 2022 at 02:36, Masami Hiramatsu > wrote: > > > > Hi Simon, > > > > 2022年3月15日(火) 14:04 Simon Glass : > > > > > > Hi Masami, > > > > > > On Mon, 14 Mar 2022 at 18:40, Masami Hiramatsu > > > wrote: > > > > > > > > Hi Simon, > > > > > > > > 2022年3月15日(火) 3:24 Simon Glass : > > > > > > > > > > > > OK, well 'reset by a user' presumably starts the board up and then > > > > > > > runs some code to do the update in U-Boot? Is that right? If so, we > > > > > > > just need to trigger that update from the test. We don't need to test > > > > > > > the actual reset, at least not with sandbox. As I said, we need to > > > > > > > write the code so that it is easy to test. > > > > > > > > > > > > Actually, we already have that command, "efidebug capsule disk-update" > > > > > > which kicks the capsule update code even without the 'reset by a > > > > > > user'. So we can just kick this command for checking whether the > > > > > > U-Boot UEFI code correctly find the capsule file from ESP which > > > > > > specified by UEFI vars. > > > > > > > > > > > > However, the 'capsule update on-disk' feature is also expected (and > > > > > > defined in the spec?) to run when the UEFI subsystem is initialized. > > > > > > This behavior will not be tested if we skip the 'reset by a user'. I > > > > > > guess Takahiro's current test case tries to check it. > > > > > > > > > > The 'UEFI subsystem is intialised' is a problem, actually, since if it > > > > > were better integrated into driver model, it would not have separate > > > > > structures or they would be present and enabled when driver model is. > > > > > I hope that it can be fixed and Takahiro's series is a start in that > > > > > direction. > > > > > > > > OK. > > > > > > > > > But as to a test that an update is called when UEFI starts, that seems > > > > > like a single line of code. Sure it is nice to test it, but it is much > > > > > more important to test the installation of the update and the > > > > > execution of the update. I suppose another way to test that is to > > > > > shut down the UEFI subsystem and start it up? > > > > > > > > Yes, currently we call do_reset() after install the capsule file. > > > > (This reset can be avoided if we replace it with > > > > sysreset_walk_halt(SYSRESET_COLD) as you said, right?) > > > > > > > > Here is how I tested it on my machine; > > > > > > > > > usb start > > > > > fatload usb 0 $kernel_addr_r test.cap > > > > > fatwrite mmc 0 $fileaddr EFI/UpdateCapsule/test.cap $filesize > > > > > efidebug capsule disk-update > > > > (run install process and reboot the machine) > > > > > > > > So, if we can avoid the last reset, we can test the below without > > > > reset on sandbox (depends on scenarios). > > > > - confirm that the capsule update on disk can find the capsule file > > > > from ESP specified by the BOOTXXXX EFI variable. > > > > - confirm that the capsule update on disk writes the firmware > > > > correctly to the storage which specified by DFU. > > > > - confirm that the capsule update on disk success if the capsule image > > > > type is supported. > > > > - confirm that the capsule update on disk fails if the capsule image > > > > type is not supported. > > > > - confirm that the capsule update on disk will reboot after update > > > > even if the update is failed. > > > > > > > > The only spec we can not test is > > > > - confirm that the capsule update on disk is kicked when the UEFI is > > > > initialized. > > > > > > Even that could be tested, by installing an update and then initing UEFI? > > > > yeah, if the UEFI is not initialized yet, we can run some UEFI related > > command (e.g. printenv -e) instead of efidebug capsule... to execute > > the capsule update on disk. > > But anyway, this is only available at the first time. We need a way to > > reset UEFI subsystem without system reset. > > Yes. It is certainly possible, but I'm not sure how easy it is. > Perhaps just drop all the EFI data structures and run the EFI init > again? We have something similar with driver model. See > dm_test_pre_run() > > > > > > > > > > > > > > > Anyway we should design subsystems so they are easy to test. > > > > > > > > Here I guess you mean the unit test, not system test, am I correct? > > > > > > Yes. Easy testing is so important for developer productivity and > > > happiness. It is fine to have large system/functional tests as a fall > > > back or catch-all, but they tend to test the happy path only. When > > > they fail, they are hard to debug because they cover such as large > > > area of the code and they often have complex setup requirements so are > > > hard to run manually. > > > > > > My hope is that all the functionality should be covered by unit tests > > > or integration tests, so that system/functional almost never fail. > > > > My another question is how small is the granularity of the unit test. > > As I showed, the UEFI capsule update needs to prepare a capsule file > > installed in the storage. > > That seems to be very system-level. But you think that is still be a unit test? > > (I expected that the 'Unit test' is something like KUnit in Linux) > > Well I am using your terminology here. Technically many of the U-Boot > tests (executed by 'ut' command) are not really unit tests. They bring > in a lot of code and run one test case using it. > > For example, one of the tests brings up the USB subsystem, including a > fake USB stick, then checks it can read data from the stick, using the > USB stack. > > Another one writes some things to the emulated display and then checks > that the correct pixels are there. > > Perhaps a better name would be integration test. But the point is that > we can run these tests very, very quickly and (setup aside) without > outside influence, or without restarting the executable, etc. I don't really understand why you want and need to avoid a real reset in, what you call, integration test. -Takahiro Akashi > > > > > > > > > > > > > > > > > > > > > > > > > > Masami's patch (this series) fixes issues around those two resets > > > > > > > > in pytest. > > > > > > > > > > > > > > Yes and that is the problem I have, at least on sandbox. > > > > > > > > > > > > So If I I call sysreset_walk_halt(SYSRESET_COLD) after capsule update, > > > > > > it could help? > > > > > > > > > > Yes that can help, because sandbox can detect that and turn it into a nop. > > > > > > > > OK, let me submit a patch to update it. > > > > > > OK thank you. > > Regards, > SImon