Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2450640rdb; Mon, 20 Nov 2023 11:04:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHsHGVTNbEkTaFTSINj5NB8B70JADglQXdXWIgwl2mp0J77gvtBABerJPLOFrd/aBKJK5w8 X-Received: by 2002:a17:902:8209:b0:1cd:fbc7:2737 with SMTP id x9-20020a170902820900b001cdfbc72737mr5943591pln.52.1700507080827; Mon, 20 Nov 2023 11:04:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700507080; cv=none; d=google.com; s=arc-20160816; b=gqsyIqNMhfBbU4OwIxvFhUmbzwwen3E5ZYVp4LAtWajxsBkBRdFKuuGO2RyDaiejs/ 2BplbOjYqK/tVpBLIwPxbO2gXadBlmoCTs5dqORqmNgAbJCqPzGk4DfiWAJxNKrBtb+M n07+V/mzOijhOWBSfbC1JVhwfXuhHYcwDo38gEasRMgGXg0iVDsG3sGsFpoDhgpZmpnW oeQCKTV7k4Xumx+C6fB/+VLfVnjU9B28rxeW7XI1or+eTbDfrmGd9Re8ZVaxO0qgGQHB JKJYXE53TucJaqUpwdOK/NQapM3NXi91sgnY7vZKB8QhW88Oq44HigGPSrCP1uUk6iO7 +AbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=NwegP4grp+NKVnXxnLCbPPhC1AoQpO7Vl3AwS2tf1V0=; fh=tiLqfmzNRYSlCV2j/3i37cFvDEKyi7VYmURap7T6tj8=; b=XJ3+m0ZVQ4uluAdhc5LtBXrqHhuvZEYHaGJ6iZ1bqiZSVTviLMorXXv9WP1+6v+aDY o4cJxITu7gZ77CQkucMNkmSs2H4OSOHk/MqTAYF3tbNdS0RxYLEn1MaB+OvaLeBzMbrw mPkEGcv7WKJvIIKP7lVbHATYBMTOSfzBgrAjXW7LpxOM9xTem5CvAxVTwHPHUrlVqeF/ Tmt+V6ugWN3mS+FOAUFU7gaTECr/PEx2fSBMpXUHMM0A+k8FNec46oBmGgqMkIDsDpXl sDRvT35nL4xiP8UgnypGEJxiumiQDO7CiuOrIUFG8C9PZ0YstbHaX+fYGRWqshkBqScc m79g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TywSXqEv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id g2-20020a170902868200b001cf50ef35besi5697249plo.51.2023.11.20.11.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 11:04:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TywSXqEv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id C70F48087275; Mon, 20 Nov 2023 11:04:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229623AbjKTTES (ORCPT + 99 others); Mon, 20 Nov 2023 14:04:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjKTTER (ORCPT ); Mon, 20 Nov 2023 14:04:17 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 101429C for ; Mon, 20 Nov 2023 11:04:14 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5c934524a61so32428517b3.2 for ; Mon, 20 Nov 2023 11:04:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700507053; x=1701111853; darn=vger.kernel.org; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=NwegP4grp+NKVnXxnLCbPPhC1AoQpO7Vl3AwS2tf1V0=; b=TywSXqEvMpo5ZbZuXWqr18X4YXCVS6DIXbLqZQq38nST77LY4YihWyoVsW4V9hLNEN IU0m2q02LZeVounQQk5uMDWd+ky1U+qJAIAwI90ovxUpbxzLk2pkLyU9RRCuhp622qKA OKD+FU/kbYrL79cXE7g29//7sGIZb2bW0U6TStW2S0IKUiSGMYSjpWYrSyX3soKVTXcM D8kIbOwYzzPRBtaYxWW9XaAVmKevuE0rVKkpErAuVfWmapXB5Hl4chT4fHCTFcIlyheH /nNdmiKg7QnPpSomfOqfIcihXwxcTKmeZZvi0uxZW3we596GY3ps6SZt3W623SOciLxn AKqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700507053; x=1701111853; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NwegP4grp+NKVnXxnLCbPPhC1AoQpO7Vl3AwS2tf1V0=; b=E8Bvx2CUT/wZEHLtr8+lf1eldadwnHSeQr+wIKRSOrXNVCZpIiB32CY/tTWW6l4FJO UMWhaBH/h+SUvfLM/IcIbi7Ge2wbglJNZAbayecQwvkzeoil5OA6PxrxrqZC3enx8FkK So0mKozpFDQkFDeOlj0k/ZmojfELHC+f+WcLQgFnIlnWz3ux6UfIuxZRKWtFsKIFZLm/ 0zZj9humG9ccQQFErKNbudoUA1DljIkjtUf5AEQzF3uQPGW2G6awJsvdZvKPYxnbssTc /6euZg6UqQKN867PeEqq3O1wKlaG3lTTBCpNRiBmhT4ZbpcC0cPNkFv5vmzkL+oFHrMJ HyvQ== X-Gm-Message-State: AOJu0YwsFAhLfjtFZCXxzv6AeAK9fqmJOQ9WPjGHYxhHBRZ0u2pIBrg0 PQYc+H8e26Co6YRAHiTX6Kf0+gVqvNN2 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:274d:270:40a9:df3f]) (user=irogers job=sendgmr) by 2002:a81:6dc9:0:b0:59b:c6bb:bab9 with SMTP id i192-20020a816dc9000000b0059bc6bbbab9mr227590ywc.3.1700507053127; Mon, 20 Nov 2023 11:04:13 -0800 (PST) Date: Mon, 20 Nov 2023 11:04:08 -0800 Message-Id: <20231120190408.281826-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Subject: [PATCH v1] perf test: Add basic perf diff test From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, atrajeev@linux.vnet.ibm.com Cc: Ian Rogers Content-Type: text/plain; charset="UTF-8" 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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 20 Nov 2023 11:04:28 -0800 (PST) There are some old bug reports on perf diff crashing: https://rhaas.blogspot.com/2012/06/perf-good-bad-ugly.html Happening across them I was prompted to add two very basic tests that will give some perf diff coverage. Signed-off-by: Ian Rogers --- tools/perf/tests/shell/diff.sh | 101 +++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100755 tools/perf/tests/shell/diff.sh diff --git a/tools/perf/tests/shell/diff.sh b/tools/perf/tests/shell/diff.sh new file mode 100755 index 000000000000..213185763688 --- /dev/null +++ b/tools/perf/tests/shell/diff.sh @@ -0,0 +1,101 @@ +#!/bin/sh +# perf diff tests +# SPDX-License-Identifier: GPL-2.0 + +set -e + +err=0 +perfdata1=$(mktemp /tmp/__perf_test.perf.data.XXXXX) +perfdata2=$(mktemp /tmp/__perf_test.perf.data.XXXXX) +perfdata3=$(mktemp /tmp/__perf_test.perf.data.XXXXX) +testprog="perf test -w thloop" +testsym="test_loop" + +cleanup() { + rm -rf "${perfdata1}" + rm -rf "${perfdata1}".old + rm -rf "${perfdata2}" + rm -rf "${perfdata2}".old + rm -rf "${perfdata3}" + rm -rf "${perfdata3}".old + + trap - EXIT TERM INT +} + +trap_cleanup() { + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +make_data() { + file="$1" + if ! perf record -o "${file}" ${testprog} 2> /dev/null + then + echo "Workload record [Failed record]" + echo 1 + return + fi + if ! perf report -i "${file}" -q | grep -q "${testsym}" + then + echo "Workload record [Failed missing output]" + echo 1 + return + fi + echo 0 +} + +test_two_files() { + echo "Basic two file diff test" + err=$(make_data "${perfdata1}") + if [ $err != 0 ] + then + return + fi + err=$(make_data "${perfdata2}") + if [ $err != 0 ] + then + return + fi + + if ! perf diff "${perfdata1}" "${perfdata2}" | grep -q "${testsym}" + then + echo "Basic two file diff test [Failed diff]" + err=1 + return + fi + echo "Basic two file diff test [Success]" +} + +test_three_files() { + echo "Basic three file diff test" + err=$(make_data "${perfdata1}") + if [ $err != 0 ] + then + return + fi + err=$(make_data "${perfdata2}") + if [ $err != 0 ] + then + return + fi + err=$(make_data "${perfdata3}") + if [ $err != 0 ] + then + return + fi + + if ! perf diff "${perfdata1}" "${perfdata2}" "${perfdata3}" | grep -q "${testsym}" + then + echo "Basic three file diff test [Failed diff]" + err=1 + return + fi + echo "Basic three file diff test [Success]" +} + +test_two_files +test_three_files + +cleanup +exit $err -- 2.43.0.rc1.413.gea7ed67945-goog