lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190920185804.GG4865@kernel.org>
Date:   Fri, 20 Sep 2019 15:58:04 -0300
From:   Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
To:     Jiri Olsa <jolsa@...hat.com>
Cc:     Mamatha Inamdar <mamatha4@...ux.vnet.ibm.com>,
        linux-kernel@...r.kernel.org, peterz@...radead.org,
        mingo@...hat.com, alexander.shishkin@...ux.intel.com,
        namhyung@...nel.org, kstewart@...uxfoundation.org,
        gregkh@...uxfoundation.org, jeremie.galarneau@...icios.com,
        shawn@....icu, tstoyanov@...are.com, tglx@...utronix.de,
        alexey.budankov@...ux.intel.com, adrian.hunter@...el.com,
        songliubraving@...com, ravi.bangoria@...ux.ibm.com
Subject: Re: [PATCH V2]Perf:Return error code for perf_session__new function
 on failure

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@...va perf]# ./perf c2c report -input
> failed to open nput: No such file or directory
> [root@...va perf]# echo $?
> 255
> 
> hum, not sure why I'm getting 255.. but it looks good now
> 
> Reviewed-by: Jiri Olsa <jolsa@...hat.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ