From patchwork Thu Dec 7 17:40:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 175310 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4951619vqy; Thu, 7 Dec 2023 09:41:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsoVvnE+/E+0h5u4ruRbdW/ydp9HhmVUb+HeCV0dcrQvgVvAYH51E7JQkeOBHfmk+26Gya X-Received: by 2002:a05:6a00:1c8b:b0:6cb:d24b:878d with SMTP id y11-20020a056a001c8b00b006cbd24b878dmr2793907pfw.2.1701970916450; Thu, 07 Dec 2023 09:41:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701970916; cv=none; d=google.com; s=arc-20160816; b=BHgTkwFjfVF8zCPvHUDzr+9gNaUknPy6D7JGXOiQTfFovxnDrd78VR3EB5n8P74Mle csM5Qxn0MgdNId/vOWwT5swy47S1wPb6hQ/bnFtTWrvSKxh3RB91vFlcMxCENFTee0Oe vox9lmtlVFm40Hv8L/l8WLOhvnac1leVqYjgJrxmw2OWU50nz9W4Eb5tsXm8y7PWdxEN qzhinTdmpgGBCFi4nw7BnpFUSJ8t4i3kaZ5q7bHXoBz1tS144dUcQUOsxszdYPnGqaNe 78Z5eNI0AysAfSjT/xZ/eukGqNgQ71Jcu9aP6l0A9Ty2cxtWMmNcWsn660OaqmTaDb2X prLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=niYg5A4Vl8wxZvl0dW0Aqla8QlNk079TUHdjvbyyS3A=; fh=lALIcgLI0Vqnqhn+7gobKe+Q/OtgOL0UjEPgLJtwaA0=; b=mu0gVTdGTO+4Rodq8v0u90/pjnKRz01fn5DAu4kWSvGBN5UK/2MBFTgiWvq4REWmcV Y3ws1x/7/CrX9tK4xWc/Il4xLquXUW7HbINSst2a8F13uCSLiPlmNw44BluNNfeXFX7f 3N9d3ohZci2gIRiFmTlkAJEpH4UBkIqWed4TaiQLiwz8ul88bLjVmfhkCiqMwwvP1/ml ukVQwy+/e4XNsJjZq2oB971HxKzLJHzFQKADprhOzKNhCPtTEVq0SYAm8GDqmpLhFnrq 4DOooERTa+kd4Ag0oxqF/NFHYaGhTdrTj1kWMjsiWw+oBiLublj5fMUEAjzu373UGpSM 7j+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=csTA5Sv8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id j8-20020a056a00234800b006cdefbf53besi66679pfj.104.2023.12.07.09.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:41:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=csTA5Sv8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1C4A0808A960; Thu, 7 Dec 2023 09:41:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443385AbjLGRlA (ORCPT + 99 others); Thu, 7 Dec 2023 12:41:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235237AbjLGRk6 (ORCPT ); Thu, 7 Dec 2023 12:40:58 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13687170C for ; Thu, 7 Dec 2023 09:41:03 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-db410931c23so1434799276.2 for ; Thu, 07 Dec 2023 09:41:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701970862; x=1702575662; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=niYg5A4Vl8wxZvl0dW0Aqla8QlNk079TUHdjvbyyS3A=; b=csTA5Sv80llF1L+RpndLQs6eQOSGNQQAPW/I60QLdwD7sxMVJ57OpaGkJkWUR6yroI 2qRXjppG1hB/F54bppq/sZKLXEjpDPEjdmA00Ckl5S6dVjs8FOn6+Lb5OrS2SkkUruhE GbaXCeM5gyG/pwDWTw95hLKGx7ga5dJLApG/Vbpp3uFXmD7AlHY4aK0gdVxkbyeGuPAH /M0FJOHhzg8bK/dHVJgiw1l60I0snKbGAiDuWKBksoUwQugdoh7kJ9FAzRIbNzWCATAO JCszczlpqqq1dHOCir6p6t2xz/KQbi36ZgfkvgN5XeP5yshjJ1/UUiiXfu/0k3QcIpxH 26tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701970862; x=1702575662; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=niYg5A4Vl8wxZvl0dW0Aqla8QlNk079TUHdjvbyyS3A=; b=RYeAnzqJOeCElzzYlBH4JiF077tRybcntE0+dvMieVDzgv0wBChy+wQbsSSoZENQyP 5ba6r2qI7AdA2jJfVu/ZbJZspSR8PMw5+zaAJISiGiZtYHyeHIUmQylbn/ciu4kTnPlD RCLWB/C8/huD+Vbno+y/thVeoWaghdRmHvlNI+FeGu+V3wsH4y0QKsVuV/s9EWxakqJd 9EbhKwZFHJq5kh52iI3mb8nMqdRw3sGi+o8HjNqBMX5BOzgtlw1jBoq5aPQRsRxgYmK/ DVzuh4Qr39YeAHOTIZ1YcWMjtMB5L5AAbbix+GW2cmURjvzGiidc82312OJYaH9+DlzO AEnw== X-Gm-Message-State: AOJu0YwobJrhCl46OayJFYnZMVhT8EC2jLvDfKWFfstzkEHRJEZbhslM jrkNY9iuiEE1PfILsaGvuKWgYLCHT1d3 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:35bf:293e:7696:34e9]) (user=irogers job=sendgmr) by 2002:a25:df06:0:b0:d9a:520f:1988 with SMTP id w6-20020a25df06000000b00d9a520f1988mr35484ybg.4.1701970862296; Thu, 07 Dec 2023 09:41:02 -0800 (PST) Date: Thu, 7 Dec 2023 09:40:57 -0800 Message-Id: <20231207174057.1482161-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Subject: [PATCH v1] perf tests: Add perf script test From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Ben Gainey X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 07 Dec 2023 09:41:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784645855986712126 X-GMAIL-MSGID: 1784645855986712126 Start a new set of shell tests for testing perf script. The initial contribution is checking that some perf db-export functionality works as reported in this regression by Ben Gainey : https://lore.kernel.org/lkml/20231207140911.3240408-1-ben.gainey@arm.com/ Signed-off-by: Ian Rogers Tested-By: Ben Gainey --- tools/perf/tests/shell/script.sh | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 tools/perf/tests/shell/script.sh diff --git a/tools/perf/tests/shell/script.sh b/tools/perf/tests/shell/script.sh new file mode 100755 index 000000000000..5ae7bd0031a8 --- /dev/null +++ b/tools/perf/tests/shell/script.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# perf script tests +# SPDX-License-Identifier: GPL-2.0 + +set -e + +temp_dir=$(mktemp -d /tmp/perf-test-script.XXXXXXXXXX) + +perfdatafile="${temp_dir}/perf.data" +db_test="${temp_dir}/db_test.py" + +err=0 + +cleanup() +{ + trap - EXIT TERM INT + sane=$(echo "${temp_dir}" | cut -b 1-21) + if [ "${sane}" = "/tmp/perf-test-script" ] ; then + echo "--- Cleaning up ---" + rm -f "${temp_dir}/"* + rmdir "${temp_dir}" + fi +} + +trap_cleanup() +{ + cleanup + exit 1 +} + +trap trap_cleanup EXIT TERM INT + + +test_db() +{ + echo "DB test" + + # Check if python script is supported + libpython=$(perf version --build-options | grep python | grep -cv OFF) + if [ "${libpython}" != "1" ] ; then + echo "SKIP: python scripting is not supported" + err=2 + return + fi + + cat << "_end_of_file_" > "${db_test}" +perf_db_export_mode = True +perf_db_export_calls = False +perf_db_export_callchains = True + +def sample_table(*args): + print(f'sample_table({args})') + +def call_path_table(*args): + print(f'call_path_table({args}') +_end_of_file_ + perf record -g -o "${perfdatafile}" true + perf script -i "${perfdatafile}" -s "${db_test}" + echo "DB test [Success]" +} + +test_db + +cleanup + +exit $err