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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E245C43217 for ; Sun, 31 Oct 2021 05:56:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FF3360FBF for ; Sun, 31 Oct 2021 05:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbhJaF7T (ORCPT ); Sun, 31 Oct 2021 01:59:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbhJaF7R (ORCPT ); Sun, 31 Oct 2021 01:59:17 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B1B0C061570 for ; Sat, 30 Oct 2021 22:56:46 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id n18so9550318plc.2 for ; Sat, 30 Oct 2021 22:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bO1N9Zxka8xPPjy7oAD9PdbIBCgxedCv6giVOzcBrEo=; b=j28CygT/ZpQn9InIn1/xNT6zmecpXfZ1dT/Oy91/kUTkbsSGmZKH3gh5CmpHs7FbgO 3rwpdhWYlV+T+G08NZIRHfWsY9dIsVyvZhzg1A2Vf1+ouzEFAF9aYhjD1rCsB1TZuHSX D0sMuBBqAQIHwNgzZ7jiM8xf/Fr2pnvN2Ln6p+AYEbIPbOuIi1UBOdu6xpFhjBnKvyFZ PuSYcSvOav+qHqC4P9CzW6duIVmGUuuY8hOzMPxub/a4ue4Egzus9crLT3uOz71uifut 83GxfqtDm2qVNz99j4TNm6SeRKc+lYpqDTwfa/4JPhkKM+u9SCFJ2DNNQORF2/GKT7Ki bxfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bO1N9Zxka8xPPjy7oAD9PdbIBCgxedCv6giVOzcBrEo=; b=YEXzsjiz+gdjV4G0mXzphWekYVM4CkhQD/FDSWl7CbjWuC1YDWHVjqGThlpyDS2Fmt ZA1DxFkAmI+2AAb1HoSKI+h5uByXQIXmvvuh19RTLEN3ecHkvYrAJv3jpQ9OZt52Z6YM QqmZbTiqMyl4c+84YQxWaULISYbe/hFkOSQ0bkMhTuiSi0tGfNEaMBv4stw0u3hT9kfi jutGTjlZKPQmMc3lsdlNYDswsO4FydfVAPjqC75+h2lfPbk0erPH+KIOz0UNjkjx4M5J RG0S2kYExdtWBn9CytQEb1Nb86GpEN93/PlqnxKbVHl+8OcnDEJMB2OTYUkSf6p7o3+t FCVw== X-Gm-Message-State: AOAM533EnvWL245z5O7TgTYGzbg8PXXwNjXMBZBsaJIqR4ypcqNKNy8h ESJGfWNd9evzWAPFHWQOFTFpEGTZlXzxeQ== X-Google-Smtp-Source: ABdhPJxbNfV9ix53yVOMFyoGQQXpL5lukS4AaLgTqtSFhXZHwpHR3BB0cZc2GhAvNdC/legwTEwIjg== X-Received: by 2002:a17:90a:1649:: with SMTP id x9mr29964507pje.70.1635659805805; Sat, 30 Oct 2021 22:56:45 -0700 (PDT) Received: from localhost.localdomain (netadmin.ucsd.edu. [137.110.160.224]) by smtp.gmail.com with ESMTPSA id j19sm11403179pfj.127.2021.10.30.22.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Oct 2021 22:56:45 -0700 (PDT) From: Zixuan Wang To: kvm@vger.kernel.org, pbonzini@redhat.com, drjones@redhat.com Cc: marcorr@google.com, erdemaktas@google.com, rientjes@google.com, seanjc@google.com, brijesh.singh@amd.com, Thomas.Lendacky@amd.com, varad.gautam@suse.com, jroedel@suse.de, bp@suse.de Subject: [kvm-unit-tests PATCH v1 6/7] scripts: Generalize EFI check Date: Sat, 30 Oct 2021 22:56:33 -0700 Message-Id: <20211031055634.894263-7-zxwang42@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211031055634.894263-1-zxwang42@gmail.com> References: <20211031055634.894263-1-zxwang42@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Marc Orr Previously, the scripts distinguish between seabios and UEFI via a hard-coded env var in the EFI run script, `arch/x86/efi/run`. Furthermore, this var is passed to the x86 run script, `arch/x86/run`, and then not available in other scripts (or to other architectures). Replace the previous approach with a common helper function to check whether the repo has been configured to run under EFI. The helper does this by probing the `config.mak` file generated by `configure`. Signed-off-by: Marc Orr --- scripts/common.bash | 5 +++++ x86/efi/run | 1 - x86/run | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/common.bash b/scripts/common.bash index 7b983f7..6f45843 100644 --- a/scripts/common.bash +++ b/scripts/common.bash @@ -1,5 +1,10 @@ source config.mak +function running_under_efi() +{ + [[ ${TARGET_EFI} == "y" ]] && echo "y" || echo "" +} + function for_each_unittest() { local unittests="$1" diff --git a/x86/efi/run b/x86/efi/run index 922b266..aacc691 100755 --- a/x86/efi/run +++ b/x86/efi/run @@ -52,7 +52,6 @@ popd || exit 2 # run in UEFI, some test cases, e.g. `x86/pmu.c`, require more free memory. A # simple fix is to increase the QEMU default memory size to 256MiB so that # UEFI's largest allocatable memory region is large enough. -EFI_RUN=y \ "$TEST_DIR/run" \ -drive file="$EFI_UEFI",format=raw,if=pflash,readonly=on \ -drive file.dir="$EFI_TEST/$EFI_CASE/",file.driver=vvfat,file.rw=on,format=raw,if=virtio \ diff --git a/x86/run b/x86/run index 4eba2b9..95b56b6 100755 --- a/x86/run +++ b/x86/run @@ -1,5 +1,7 @@ #!/usr/bin/env bash +source scripts/common.bash + if [ -z "$STANDALONE" ]; then if [ ! -f config.mak ]; then echo "run ./configure && make first. See ./configure -h" @@ -39,12 +41,12 @@ fi command="${qemu} --no-reboot -nodefaults $pc_testdev -vnc none -serial stdio $pci_testdev" command+=" -machine accel=$ACCEL" -if ! [ "$EFI_RUN" ]; then +if ! [ "$(running_under_efi)" ]; then command+=" -kernel" fi command="$(timeout_cmd) $command" -if [ "$EFI_RUN" ]; then +if [ "$(running_under_efi)" ]; then # Set ENVIRON_DEFAULT=n to remove '-initrd' flag for QEMU (see # 'scripts/arch-run.bash' for more details). This is because when using # UEFI, the test case binaries are passed to QEMU through the disk -- 2.33.0