Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1479847lqp; Mon, 15 Apr 2024 07:44:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWwHIjz75fHJVX3rhu3qIdi/WHPNrLvH1l0tn1VPzgC4XeLhn/uEAlZ/5eLfM6Ih4owghQdF9yGEfENaoHF4kzQUNFVzNX1pNCaDL+Qow== X-Google-Smtp-Source: AGHT+IFBY/EMEeNv49ftxpvlf7O96G+AgmrQ7kKIdFUgZr3qKPfUoqTpt8zlqVC9xJ8R0XuPpGrw X-Received: by 2002:a17:907:97c6:b0:a51:fef6:b7d6 with SMTP id js6-20020a17090797c600b00a51fef6b7d6mr8683068ejc.19.1713192254676; Mon, 15 Apr 2024 07:44:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713192254; cv=pass; d=google.com; s=arc-20160816; b=bubA0jgkhQDLt53J7ekceSWGl1wMPGAl3jLMnGIGcPT6MtVSre4DUd6gZC/FRbUgtE q+Dj+vIwVI4dIyDlqR+OSEgMB/wkJE7UpRHkSHRvH6h8MfLwmGXbbsEOzpOzJekY6fjB b65tCM8/hn46QpBmRWYBmSkcBBXTDuz8zswRCcDXLytXEsHNMFr/gBVhbMVnHHGmbRyZ AvtKvPldmsOdRJ/K5pGYLAl6y4Yym7JXuNgrLkFsNsJ7FaLkJU2IgWXwkGJdro6MngtC AytEVB4sG+jY/IdA2vS1IUFxW7cWC0oc0vekYj8wbhvLr6uy1tlfi55Yp6cBBgh/KM18 7fyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=0bmcD1dsKmxdOPG1Zb6XlpeF2OhOoXu9RprsqunU6bk=; fh=hGD5PiIeKWSuF3E5wGOd8JcXQbMEFp8ytDzd5H0XPpM=; b=d+Cm426qNxwz/OocYG81QnLTNpko7GSzMHgYB+WjQL3o/TNi7X8wpyciwqTPdMeIN5 +hN+F8SA/B50Sma8FbT5HJBxy7tY0OBKQwLC119SStLp3GdRkrbZFTC2aDaXJSciNnfu 7eW9NF7oY+xmROVW9otncRPb++UN4ZL61ktmQvDYW4QU23195dzHO8alhSSmK+AXiez1 TCDKV61BBK00rwFGnawIRriBmD/OF+bVXp5KAsYyG/ZYOx2uEwSpOerI/oh+aY+R52Kh 1z6YQlFRbHz/Vjln1KybhhdIaSW4L5F2hXQIfFTYR3lB113n16bybAfudkmEyB5dOmiE 01ng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YtBpYTUZ; arc=pass (i=1 spf=pass spfdomain=flex--jackmanb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-145379-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145379-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x24-20020a170906441800b00a5210b288fbsi4646179ejo.785.2024.04.15.07.44.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 07:44:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145379-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YtBpYTUZ; arc=pass (i=1 spf=pass spfdomain=flex--jackmanb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-145379-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145379-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 39DD01F2260E for ; Mon, 15 Apr 2024 14:44:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF73E71B4F; Mon, 15 Apr 2024 14:44:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YtBpYTUZ" Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 861D81D52B for ; Mon, 15 Apr 2024 14:44:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713192244; cv=none; b=i7URrc8gqVVGpZeN3NLCBESYlU3LZU/6dqMJRL6cNwL3y/U56yGerETWSueRoV08bx084LyIF89irKNrUkC4KTf0sJwBBIRCUbJ2/qG5LV/WE7Kr1ly888P5b8qx2iDVG/Xzaz1s6bJLwgsnZQJlzgS5XAWA2qau73gV/agSZG0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713192244; c=relaxed/simple; bh=KehpfQl+nFVwyeBbKTZT+XW0EbxiUmM5b6iOnH+si1k=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=thii35psp6ZFwtBtLmAdo3IA/hDR/Vg7/tN0xQ3agkOqGrCZuMO8pT6nZyO24lJWJcHRaJg/ShtVKED7jWG33NMn0Dg+oLuueYIw21qbS9Nnxr92lLbbvkH2RyJXN0IPDP4OTiNGLPIPdKe2UCriSMNy31TUnV0n5K9WeWlTdyc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=YtBpYTUZ; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-41634d6c008so10896105e9.1 for ; Mon, 15 Apr 2024 07:44:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713192241; x=1713797041; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=0bmcD1dsKmxdOPG1Zb6XlpeF2OhOoXu9RprsqunU6bk=; b=YtBpYTUZMBbri/hmJ5zxlLFpf7YBqdISk+18XFkh+nFFjaeOsNfXfLmswIdU8UnoTh EVO8YaKQSjN3PFoQNbplnaPRLqFMAR3mrmU8WaDBB+TDSxrbTZIAk+8jm1sj3fG6WItn j7V70Y2siCesj6mcdo187WBOJrcfVLu4RfImvEve8vkia11SQLFgUvV32fU1n++XMpj1 oiHeYUG6mt5rVtjF8hkj7RHxl6pZCMOrlkUDvT47lP0WcXqc9XXygNmry8PUyPOSO6wk iJckUWhfXJazU5/LGqfFaj0pjm5gL+ideoyXozsAfhCDwzmMtTVaADokMjOtxEwRHdJu pV4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713192241; x=1713797041; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=0bmcD1dsKmxdOPG1Zb6XlpeF2OhOoXu9RprsqunU6bk=; b=qO64sHqnht57xxrbRIWj0PYlZXCSvwecrTP2RWDobJhu5Ogjme0bYIgpTY5tffA547 AQK5OKR1l0l6CMKlxPAjamhz0zuu2ytd+lnMCVlMK43QSFfnFPbNR3xrDtR6V/8Ee9Y+ uGEElVIhMTWalcLr1XEhH3WL8LuU/XVcFAxDAuHQLnVO2cQxuYE7xC0/GqE28D/vrqlC QfR9eLSZVswA/M6bmIADD5hZ6IoSpLUbmGvD188KrNN82Gt9T2zx1js3QFfa/Jvu+KiB Mt5v8BMHXj+P/5DXEyUONzzT4vBzQnSiyq1WGpO0ObouBW6IUenP0eR3hHbBdFsUgPvv SdJg== X-Forwarded-Encrypted: i=1; AJvYcCWteCG6SsF052+EYJAJO0KD1qOu0ZckZS3d7ADYkWjfi+yG0XCSlhjM9x0mQmNFP1UJ0cblBzUb9VT6WTOUkDLXgAoMaiKmPYGg8jDu X-Gm-Message-State: AOJu0YwgBAZF1QWoRHYHhGYpfJ0+/FTM5G5tKMyNbHYMtyixP1tpnh6o WSbWsHFgFDPk8RXz6pzgn5yt6bQ2ODBVVeCQUKM4e6x7ba3bk9jRva4GBrC0wpputhm4D54kNvb d92vOfpaZBg== X-Received: from beeg.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:11db]) (user=jackmanb job=sendgmr) by 2002:a05:600c:458d:b0:416:a53f:38fd with SMTP id r13-20020a05600c458d00b00416a53f38fdmr32504wmo.1.1713192240874; Mon, 15 Apr 2024 07:44:00 -0700 (PDT) Date: Mon, 15 Apr 2024 14:43:54 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIACk9HWYC/x3MQQqAIBBA0avErBtIS5CuEi2ixhoqDackiO6et HyL/x8QikwCbfFApMTCwWeosoBxGfxMyFM26Eo3VaMMrmlHoc2dJKegDyjXFFANxjhbK2ethtw ekRzf/7fr3/cDxrlkFWcAAAA= X-Mailer: b4 0.14-dev Message-ID: <20240415-kvm-selftests-no-sudo-v1-1-95153ad5f470@google.com> Subject: [PATCH] KVM: selftests: Avoid assuming "sudo" exists From: Brendan Jackman To: Sean Christopherson , Paolo Bonzini , Shuah Khan Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" I ran into a failure running this test on a minimal rootfs. Can be fixed by just skipping the "sudo" in case we are already root. Signed-off-by: Brendan Jackman --- tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh index 7cbb409801eea..0e56822e8e0bf 100755 --- a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh +++ b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh @@ -13,10 +13,21 @@ NX_HUGE_PAGES_RECOVERY_RATIO=$(cat /sys/module/kvm/parameters/nx_huge_pages_reco NX_HUGE_PAGES_RECOVERY_PERIOD=$(cat /sys/module/kvm/parameters/nx_huge_pages_recovery_period_ms) HUGE_PAGES=$(cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages) +# If we're already root, the host might not have sudo. +if [ $(whoami) == "root" ]; then + function maybe_sudo () { + "$@" + } +else + function maybe_sudo () { + sudo "$@" + } +fi + set +e function sudo_echo () { - echo "$1" | sudo tee -a "$2" > /dev/null + echo "$1" | maybe_sudo tee -a "$2" > /dev/null } NXECUTABLE="$(dirname $0)/nx_huge_pages_test" --- base-commit: 2c71fdf02a95b3dd425b42f28fd47fb2b1d22702 change-id: 20240415-kvm-selftests-no-sudo-1a55f831f882 Best regards, -- Brendan Jackman