From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796213706; b=P06kRjVALMuvOMbpW/Wn0DFEd7X4jnc3wIsYyf6FBImD0p2Wo0TheBRnZTCkUEsLhty2 8ztV0OhUHPWnzmtrOWdYwxBDY0dUP6mKOY9f67mrq588EYuOO0vOxoQdSSGtyW6H0ryd5 JAWwRomdKx+8CICR3wdMkWwZAR6VGXZtwOmmenrekoh3rL39ZC0dX1kDnlR/V298HDYUD fyIftVYdyEWzXTJdfzgTBvnjJWbqH8VSsTvO3JTJaCdqs/civVjSoxs+OqyvaSMpCfVZ9 a6oMcJxFosfDQs6NJwVn1iW3/zwEKc5vpYpvIY4jnXsGiKml2W8LFeH+AJCWVselROA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796213706; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=BUHIPgchgtghdzQa8PzESd3SL8VDxPhhlVBbRLur6Hs=; b=wQ97Z+sNNLGIoswao7T6mqcy1Ka2XmGd/484++MyBLmIJsV1+Gh78q7ATe1BUC/la9OW P0uwXc2mNHgGUwH0yHqK9pLXGr7Fo5zQ8DKDbT80wC7PvGL7a9g6DNao65HED82D85pB8 dgmgGnawxETYB8GbCC6odEEGyOkANIeDOkqgxnH517Xd54qT8byGCs7vQWal7O4fqgJM7 KLrZWc9b+1lIDH51y8bSgm/MugjD3VkfSrOszk/88RI0DRs9kqTW4GMuNnEM95qpHC0Id VrkwLnymknPurHPJPb5MLH+puBx6WiJdkov+Jmxqd8637/l2dhKKztjLhsT5Rf37IWQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lw64djsV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0783606A329 for ; Wed, 2 Dec 2026 12:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lw64djsV Received: by smtp.kernel.org (Postfix) with ESMTPSA id E08F21F00896; Wed, 2 Dec 2026 12:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796213706; bh=BUHIPgchgtghdzQa8PzESd3SL8VDxPhhlVBbRLur6Hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lw64djsVPt8i+v6J11yr31pO85w7AOwg0BDLBVBOPY5n6WQY5mRJ9fM1yfYexPOuM +/H/wt6hD/MpbOy/x64CDDqkVgNiRbh78n20zQKcuawMxc6SWfED6YFQSnN9oTIG33 rl2rXxrClJcSyqQOpJoIemZlPXbczhMHzRdnjDwYFaArlGRs4slj1l8aGhiNMa0FqK PFefRDTUAjsTz9zhVDvhP8zq1tuT9RVAfuJ2wp+9aCEqouQDNRjGIqnGMt6pmlACQ+ o6G5d6xDMw3RH0hOyeVK6d9dJJvOMVYAW4mLZO6wA9dN9vah9FfcPNrPbOC+WFb0d3 rg/Kbbp1cgArw== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , James Clark , Jiri Olsa , Ian Rogers , Adrian Hunter , Clark Williams , linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Athira Rajeev Subject: [PATCH v3 05/18] perf tests config: Exercise the config file and list options Date: Wed, 2 Dec 2026 09:14:21 -0300 Message-ID: <20261202121434.2224-6-acme@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261202121434.2224-1-acme@kernel.org> References: <20261202121434.2224-1-acme@kernel.org> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnaldo Carvalho de Melo Set, read back, update and list two variables under a private HOME, and check the --user/--system conflict and the invalid key errors. perf test exports PERF_CONFIG=/dev/null to the shell tests, unset it so perf config uses the private file. Reviewed-by: Athira Rajeev Tested-by: Athira Rajeev Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/shell/config.sh | 134 +++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100755 tools/perf/tests/shell/config.sh diff --git a/tools/perf/tests/shell/config.sh b/tools/perf/tests/shell/config.sh new file mode 100755 index 0000000000000000..fc035bbec2e2ea18 --- /dev/null +++ b/tools/perf/tests/shell/config.sh @@ -0,0 +1,134 @@ +#!/bin/bash +# perf config tests +# SPDX-License-Identifier: GPL-2.0 + +set -e + +err=0 +tmpdir=$(mktemp -d /tmp/__perf_test_config.XXXXXX) +out="${tmpdir}/out" + +# perf test exports PERF_CONFIG=/dev/null to the shell tests, use a +# private HOME instead so the file written here is the one being read. +unset PERF_CONFIG +export HOME="${tmpdir}" + +cleanup() { + rm -rf "${tmpdir}" + + trap - EXIT TERM INT +} + +trap_cleanup() { + echo "Unexpected signal in ${FUNCNAME[1]}" + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +test_config_empty() { + echo "Empty config test" + if ! perf config --user --list > "${out}" 2>&1; then + echo "Empty config [Failed: perf config --user --list failed]" + cat "${out}" + err=1 + return + fi + if [ -s "${out}" ]; then + echo "Empty config [Failed: unexpected output]" + cat "${out}" + err=1 + return + fi + echo "Empty config [Success]" +} + +test_config_set_get() { + echo "Config set and get test" + if ! perf config report.show-nr-samples=true call-graph.print-limit=5; then + echo "Config set [Failed: perf config failed]" + err=1 + return + fi + if [ ! -s "${HOME}/.perfconfig" ]; then + echo "Config set [Failed: no config file]" + err=1 + return + fi + + if ! perf config --user report.show-nr-samples | grep -qx "report.show-nr-samples=true"; then + echo "Config get [Failed: wrong report.show-nr-samples]" + err=1 + return + fi + if ! perf config --user call-graph.print-limit | grep -qx "call-graph.print-limit=5"; then + echo "Config get [Failed: wrong call-graph.print-limit]" + err=1 + return + fi + + if ! perf config --user --list > "${out}" 2>&1 || + ! grep -qx "report.show-nr-samples=true" "${out}" || + ! grep -qx "call-graph.print-limit=5" "${out}"; then + echo "Config list [Failed: missing variables]" + cat "${out}" + err=1 + return + fi + if ! perf config --list > "${out}" 2>&1 || + ! grep -qx "report.show-nr-samples=true" "${out}"; then + echo "Config list [Failed: missing user variable in the merged view]" + cat "${out}" + err=1 + return + fi + + if ! perf config report.show-nr-samples=false; then + echo "Config update [Failed: perf config failed]" + err=1 + return + fi + if ! perf config report.show-nr-samples | grep -qx "report.show-nr-samples=false"; then + echo "Config update [Failed: value not updated]" + err=1 + return + fi + echo "Config set and get test [Success]" +} + +test_config_errors() { + echo "Config error test" + if perf config --user --system --list > "${out}" 2>&1; then + echo "Config error [Failed: --user --system succeeded]" + cat "${out}" + err=1 + return + fi + if ! grep -q "only one config file at a time" "${out}"; then + echo "Config error [Failed: missing file option error]" + cat "${out}" + err=1 + return + fi + + if perf config nosection > "${out}" 2>&1; then + echo "Config error [Failed: invalid variable succeeded]" + cat "${out}" + err=1 + return + fi + if ! grep -q "does not contain a section name" "${out}"; then + echo "Config error [Failed: missing invalid variable error]" + cat "${out}" + err=1 + return + fi + echo "Config error test [Success]" +} + +test_config_empty +test_config_set_get +test_config_errors + +cleanup +exit $err -- 2.56.0