linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	James Clark <james.clark@linaro.org>,
	Collin Funk <collin.funk1@gmail.com>,
	Ravi Bangoria <ravi.bangoria@amd.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 1/2] perf test: Add an 'import perf' test shell script
Date: Wed, 1 Oct 2025 10:42:19 -0300	[thread overview]
Message-ID: <aN0vu4yoVWjmTbtJ@x1> (raw)
In-Reply-To: <CAP-5=fV-3d1EzYfZq6s9M2NrLFFVOrWOTx_k5tByScA4Sfqq-g@mail.gmail.com>

On Tue, Sep 30, 2025 at 01:02:55PM -0700, Ian Rogers wrote:
> On Wed, Sep 3, 2025 at 11:42 AM Ian Rogers <irogers@google.com> wrote:
> >
> > The 'import perf' test needs to set up a path to the python module as
> > well as to know the python command to invoke. These are hard coded at
> > build time to be build a directory and the python used in the build,
> > which is less than desirable. Avoid the hard coded values by reusing
> > the existing shell script python setup and determine a potential built
> > python module via the path of the perf executable.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> 
> Ping.

There is another patch in this area to make it work, right?

After applying this one I get a failure, only when I set PYTHONPATH it
works:

⬢ [acme@toolbx perf-tools-next]$ export PYTHONPATH=/tmp/build/perf-tools-next/python_ext_build/lib/
⬢ [acme@toolbx perf-tools-next]$ perf test -v pytho
Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
 88: 'import perf' in python                                         : Ok
⬢ [acme@toolbx perf-tools-next]$

- Arnaldo


 
> Thanks,
> Ian
> 
> > ---
> >  tools/perf/tests/shell/python-use.sh | 36 ++++++++++++++++++++++++++++
> >  1 file changed, 36 insertions(+)
> >  create mode 100755 tools/perf/tests/shell/python-use.sh
> >
> > diff --git a/tools/perf/tests/shell/python-use.sh b/tools/perf/tests/shell/python-use.sh
> > new file mode 100755
> > index 000000000000..fd2ee5390060
> > --- /dev/null
> > +++ b/tools/perf/tests/shell/python-use.sh
> > @@ -0,0 +1,36 @@
> > +#!/bin/bash
> > +# 'import perf' in python
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Just test if we can load the python binding.
> > +set -e
> > +
> > +shelldir=$(dirname "$0")
> > +# shellcheck source=lib/setup_python.sh
> > +. "${shelldir}"/lib/setup_python.sh
> > +
> > +MODULE_DIR=$(dirname "$(which perf)")/python
> > +
> > +if [ -d "$MODULE_DIR" ]
> > +then
> > +    CMD=$(cat <<EOF
> > +import sys
> > +sys.path.insert(0, '$MODULE_DIR')
> > +import perf
> > +print('success!')
> > +EOF
> > +    )
> > +else
> > +    CMD=$(cat <<EOF
> > +import perf
> > +print('success!')
> > +EOF
> > +    )
> > +fi
> > +
> > +echo -e "Testing 'import perf' with:\n$CMD"
> > +
> > +if ! echo "$CMD" | $PYTHON | grep -q "success!"
> > +then
> > +  exit 1
> > +fi
> > +exit 0
> > --
> > 2.51.0.338.gd7d06c2dae-goog
> >

  reply	other threads:[~2025-10-01 13:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-03 18:42 [PATCH v1 1/2] perf test: Add an 'import perf' test shell script Ian Rogers
2025-09-03 18:42 ` [PATCH v1 2/2] perf test: Remove C python_use test Ian Rogers
2025-09-30 20:02 ` [PATCH v1 1/2] perf test: Add an 'import perf' test shell script Ian Rogers
2025-10-01 13:42   ` Arnaldo Carvalho de Melo [this message]
2025-10-01 13:44     ` Arnaldo Carvalho de Melo
2025-10-01 14:55     ` Ian Rogers
2025-10-01 18:23       ` Arnaldo Carvalho de Melo
2025-10-01 18:29         ` Ian Rogers
2025-09-30 23:10 ` Collin Funk

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=aN0vu4yoVWjmTbtJ@x1 \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=collin.funk1@gmail.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).