linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Jinli Xiao <jinli.xiao@nyu.edu>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Leo Yan <leo.yan@linaro.org>,
	Suzuki Poulouse <suzuki.poulose@arm.com>,
	James Clark <james.clark@arm.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf python: Set error messages on call failure
Date: Wed, 3 May 2023 10:16:27 -0700	[thread overview]
Message-ID: <CAP-5=fWy5AztcN3MZyiNcSkbpdNws0cevarfYwt0TWqhyf3eEw@mail.gmail.com> (raw)
In-Reply-To: <CAExMFzgmcQqnVSBj9+YVr2UAkUg8CHdpLjQJF6CuOaWdcMbqDQ@mail.gmail.com>

On Tue, May 2, 2023 at 7:27 PM Jinli Xiao <jinli.xiao@nyu.edu> wrote:
>
> Thanks for the prompt response!
>
> On Tue, May 2, 2023 at 4:37 PM Ian Rogers <irogers@google.com> wrote:
> >
> > Nice! Would it be possible to test this? We could do a shell test
>
> All my changes in this patch is just setting the error message that
> can be interpreted by Python just before the bindings return.
>
> I am not sure about shell test, but I can do something like
>
> [root@nyu-lexis linux]# export PYTHONPATH=~jinli/linux/tools/perf/python/
> [root@nyu-lexis linux]# python3
> Python 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red
> Hat 12.2.1-4)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import perf
> >>> thread_map = perf.thread_map(9999)   # a non-existent pid in /proc
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> FileNotFoundError: [Errno 2] No such file or directory
>
> whereas the original output is
>
> >>> thread_map = perf.thread_map(9999)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> SystemError: <class 'perf.thread_map'> returned NULL without setting
> an exception
>
> Upon testing I did find some of the changes unnecessary. I will submit
> a new patch to this.
>
> This is my first time contributing so please let me know if I did
> anything wrong :)

Everything is good with your patch. I'm keen that we try to make sure
we have coverage with tests. We have other shell tests that run
python:
https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/perf/tests/shell/stat+json_output.sh?h=perf-tools-next
So I wonder we can start doing what you did in your example and then
just assert we get a FileNotFoundError in the python. The shell script
is really just a way to run the python and can follow the example in
the link. Sound good?

Thanks,
Ian

> Best wishes,
> Jinli

      reply	other threads:[~2023-05-03 17:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02 20:31 [PATCH] perf python: Set error messages on call failure Jinli Xiao
2023-05-02 20:37 ` Ian Rogers
2023-05-03  2:27   ` Jinli Xiao
2023-05-03 17:16     ` Ian Rogers [this message]

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='CAP-5=fWy5AztcN3MZyiNcSkbpdNws0cevarfYwt0TWqhyf3eEw@mail.gmail.com' \
    --to=irogers@google.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=james.clark@arm.com \
    --cc=jinli.xiao@nyu.edu \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=suzuki.poulose@arm.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).