linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org, peterz@infradead.org,
	mingo@redhat.com, alexander.shishkin@linux.intel.com,
	namhyung@kernel.org, kstewart@linuxfoundation.org,
	gregkh@linuxfoundation.org, jeremie.galarneau@efficios.com,
	shawn@git.icu, tstoyanov@vmware.com, tglx@linutronix.de,
	alexey.budankov@linux.intel.com, adrian.hunter@intel.com,
	songliubraving@fb.com, ravi.bangoria@linux.ibm.com
Subject: Re: [PATCH V2]Perf:Return error code for perf_session__new function on failure
Date: Fri, 20 Sep 2019 15:58:04 -0300	[thread overview]
Message-ID: <20190920185804.GG4865@kernel.org> (raw)
In-Reply-To: <20190822100718.GD28439@krava>

Em Thu, Aug 22, 2019 at 12:07:18PM +0200, Jiri Olsa escreveu:
> On Thu, Aug 22, 2019 at 12:50:49PM +0530, Mamatha Inamdar wrote:
> > This Patch is to return error code of perf_new_session function
> > on failure instead of NULL
> > ----------------------------------------------
> > Test Results:
> > 
> > Before Fix:
> > 
> > $ perf c2c report -input
> > failed to open nput: No such file or directory
> > 
> > $ echo $?
> > 0
> > ------------------------------------------
> > After Fix:
> > 
> > $ ./perf c2c report -input
> > failed to open nput: No such file or directory
> > 
> > $ echo $?
> > 254
> 
> [root@krava perf]# ./perf c2c report -input
> failed to open nput: No such file or directory
> [root@krava perf]# echo $?
> 255
> 
> hum, not sure why I'm getting 255.. but it looks good now
> 
> Reviewed-by: Jiri Olsa <jolsa@redhat.com>

You guys missed this one, that I've corrected in my tree, i.e.
TEST_ASSERT_VAL expects that second arg to be NULL in case of failure,
so we need to invert the result of IS_ERR(session) to keep the
expectation.

- Arnaldo

diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
index 7d845d913d7d..4a800499d7c3 100644
--- a/tools/perf/tests/topology.c
+++ b/tools/perf/tests/topology.c
@@ -8,6 +8,7 @@
 #include "session.h"
 #include "evlist.h"
 #include "debug.h"
+#include <linux/err.h>
 
 #define TEMPL "/tmp/perf-test-XXXXXX"
 #define DATA_SIZE	10
@@ -39,7 +40,7 @@ static int session_write_header(char *path)
 	};
 
 	session = perf_session__new(&data, false, NULL);
-	TEST_ASSERT_VAL("can't get session", session);
+	TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
 
 	session->evlist = perf_evlist__new_default();
 	TEST_ASSERT_VAL("can't get evlist", session->evlist);
@@ -70,7 +71,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)
 	int i;
 
 	session = perf_session__new(&data, false, NULL);
-	TEST_ASSERT_VAL("can't get session", session);
+	TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
 
 	/* On platforms with large numbers of CPUs process_cpu_topology()
 	 * might issue an error while reading the perf.data file section

  parent reply	other threads:[~2019-09-20 18:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22  7:20 [PATCH V2]Perf:Return error code for perf_session__new function on failure Mamatha Inamdar
2019-08-22 10:07 ` Jiri Olsa
2019-08-22 10:20   ` Mamatha Inamdar
2019-09-20 18:58   ` Arnaldo Carvalho de Melo [this message]
2019-09-22 10:52 ` [tip: perf/urgent] perf session: Return error code for perf_session__new() " tip-bot2 for Mamatha Inamdar

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=20190920185804.GG4865@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexey.budankov@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeremie.galarneau@efficios.com \
    --cc=jolsa@redhat.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mamatha4@linux.vnet.ibm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=shawn@git.icu \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    --cc=tstoyanov@vmware.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).