All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	James Clark <james.clark@linaro.org>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 2/2] perf test: Add test that command line period overrides sysfs/json values
Date: Wed, 5 Nov 2025 21:50:18 -0800	[thread overview]
Message-ID: <aQw3GqjU4GRLfjIF@google.com> (raw)
In-Reply-To: <CAP-5=fWtixi8ykDp_BO1nz_yj_1wZfUUWrCVb+6WbVE7vON6Eg@mail.gmail.com>

On Mon, Nov 03, 2025 at 09:22:00PM -0800, Ian Rogers wrote:
> On Mon, Nov 3, 2025 at 7:37 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > On Wed, Oct 29, 2025 at 03:26:38PM -0700, Ian Rogers wrote:
> > > The behavior of weak terms is subtle, add a test that they aren't
> > > accidentally broken.
> > >
> > > Signed-off-by: Ian Rogers <irogers@google.com>
> > > ---
> > >  tools/perf/tests/shell/record_weak_term.sh | 25 ++++++++++++++++++++++
> > >  1 file changed, 25 insertions(+)
> > >  create mode 100755 tools/perf/tests/shell/record_weak_term.sh
> > >
> > > diff --git a/tools/perf/tests/shell/record_weak_term.sh b/tools/perf/tests/shell/record_weak_term.sh
> > > new file mode 100755
> > > index 000000000000..7b747b383796
> > > --- /dev/null
> > > +++ b/tools/perf/tests/shell/record_weak_term.sh
> > > @@ -0,0 +1,25 @@
> > > +#!/bin/bash
> > > +# record weak terms
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +# Test that command line options override weak terms from sysfs or inbuilt json.
> > > +set -e
> > > +
> > > +shelldir=$(dirname "$0")
> > > +# shellcheck source=lib/setup_python.sh
> > > +. "${shelldir}"/lib/setup_python.sh
> > > +
> > > +
> > > +event=$(perf list --json | $PYTHON -c "import json,sys; next((print(e['EventName']) for e in json.load(sys.stdin) if e.get('Encoding') and 'period=' in e.get('Encoding')))")
> >
> > This line is too long
> 
> Is there a good way to split such a line?

Wouldn't this work?

  event=$(perf list --json | python -c '
  import sys, json
  for e in json.load(sys.stdin):
    if e.get("Encoding") and "period=" in e.get("Encoding"):
      print(e["EventName"])')

> 
> > and needs some explanation like what's like the original text and what it does.
> 
> I thought that was covered in the "if" below:

Yeah, but I think it's useful to have an example JSON text.

Thanks,
Namhyung

> 
> > > +if [[ "$?" != "0" ]]
> > > +then
> > > +  echo "No sysfs/json events with inbuilt period."
> > > +  exit 2
> > > +fi
> 
> Thanks,
> Ian
> 
> > > +
> > > +if ! perf record -c 1000 -vv -e "$event" -o /dev/null true 2>&1 | \
> > > +  grep -q -F '{ sample_period, sample_freq }   1000'
> > > +then
> > > +  echo "Unexpected verbose output and sample period"
> > > +  exit 1
> > > +fi
> > > +exit 0
> > > --
> > > 2.51.1.851.g4ebd6896fd-goog
> > >

  reply	other threads:[~2025-11-06  5:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29 22:26 [PATCH v1 1/2] perf pmu: Make pmu_alias_terms weak again Ian Rogers
2025-10-29 22:26 ` [PATCH v1 2/2] perf test: Add test that command line period overrides sysfs/json values Ian Rogers
2025-11-04  3:37   ` Namhyung Kim
2025-11-04  5:22     ` Ian Rogers
2025-11-06  5:50       ` Namhyung Kim [this message]
2025-10-30  5:46 ` [PATCH v1 1/2] perf pmu: Make pmu_alias_terms weak again Namhyung Kim
2025-10-30 15:08   ` Ian Rogers
2025-11-04  3:30     ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aQw3GqjU4GRLfjIF@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.