Skip to contentSkip to conversation

perf tests: Fix to get negative exit codes

PATCH Applied He Kuang 4 participants 7 messages May 11, 2015 – May 15, 2015 perf events

lore
Share & tools
lore

He Kuang

author
#0 lore raw

PATCH 1/2 perf tests: Fix to get negative exit codes

WEXITSTATUS consists of the least significant 8 bits of the status argument, so we should convert the value to signed char if we have valid negative exit codes. And the return value of test->func() contains negative values:

  enum {
          TEST_OK   =  0,
          TEST_FAIL = -1,
          TEST_SKIP = -2,
  };

Before this patch:

  $ perf test -v 1
  ...
  test child finished with 254
  ---- end ----
  vmlinux symtab matches kallsyms: FAILED!

After this patch:

  $ perf test -v 1
  ...
  test child finished with -2
  ---- end ----
  vmlinux symtab matches kallsyms: Skip
---
 tools/perf/tests/builtin-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/builtin-test.c +1 -1
index 4f40981..f42af98 100644
@@ -219,7 +219,7 @@ static int run_test(struct test *test)
 	wait(&status);
 
 	if (WIFEXITED(status)) {
-		err = WEXITSTATUS(status);
+		err = (signed char)WEXITSTATUS(status);
 		pr_debug("test child finished with %d\n", err);
 	} else if (WIFSIGNALED(status)) {
 		err = -1;
Signature · 1 line
1.8.5.2
author
#1 lore raw

PATCH 2/2 perf trace: Fix typo in builtin-trace.c

Duplication NULL test for trace.evlist.

---
 tools/perf/builtin-trace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/builtin-trace.c +1 -2
index bb05e44..ca39530 100644
@@ -2715,11 +2715,10 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
 	signal(SIGFPE, sighandler_dump_stack);
 
 	trace.evlist = perf_evlist__new();
-	if (trace.evlist == NULL)
-		return -ENOMEM;
 
 	if (trace.evlist == NULL) {
 		pr_err("Not enough memory to run!\n");
+		err = -ENOMEM;
 		goto out;
 	}
 
Signature · 1 line
1.8.5.2
maintainer Applied
#2 lore raw

Re: [PATCH 2/2] perf trace: Fix typo in builtin-trace.c

Em Mon, May 11, 2015 at 12:28:36PM +0000, He Kuang escreveu:

Quoted 1 line

Duplication NULL test for trace.evlist.

Thanks, applied.

#3 lore raw

[tip:perf/core] perf trace: Removed duplicated NULL test

In reply to He Kuang
perf trace: Removed duplicated NULL test
Commit-ID:  ff8f695c0ec9d73d8a9f92fe634d6476ad74e3a1
Gitweb:     http://git.kernel.org/tip/ff8f695c0ec9d73d8a9f92fe634d6476ad74e3a1
Author:     He Kuang <[email protected]>
AuthorDate: Mon, 11 May 2015 12:28:36 +0000
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 12 May 2015 09:59:49 -0300

perf trace: Removed duplicated NULL test

No need to test trace.evlist against NULL twice.

---
 tools/perf/builtin-trace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/builtin-trace.c +1 -2
index cbfdb95..96a2eba 100644
@@ -2721,11 +2721,10 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
 	signal(SIGFPE, sighandler_dump_stack);
 
 	trace.evlist = perf_evlist__new();
-	if (trace.evlist == NULL)
-		return -ENOMEM;
 
 	if (trace.evlist == NULL) {
 		pr_err("Not enough memory to run!\n");
+		err = -ENOMEM;
 		goto out;
 	}
 
Acked-by on v1 1/2
#4 lore raw
In reply to He Kuang
Quoted 19 lines · He Kuang

WEXITSTATUS consists of the least significant 8 bits of the status argument, so we should convert the value to signed char if we have valid negative exit codes. And the return value of test->func() contains negative values:

  enum {
          TEST_OK   =  0,
          TEST_FAIL = -1,
          TEST_SKIP = -2,
  };

Before this patch:

  $ perf test -v 1
  ...
  test child finished with 254
  ---- end ----
  vmlinux symtab matches kallsyms: FAILED!
Quoted 7 lines

After this patch:

  $ perf test -v 1
  ...
  test child finished with -2
  ---- end ----
  vmlinux symtab matches kallsyms: Skip

thanks,
jirka

Quoted 22 lines
---
 tools/perf/tests/builtin-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/builtin-test.c +1 -1
index 4f40981..f42af98 100644
@@ -219,7 +219,7 @@ static int run_test(struct test *test)
 	wait(&status);
 
 	if (WIFEXITED(status)) {
-		err = WEXITSTATUS(status);
+		err = (signed char)WEXITSTATUS(status);
 		pr_debug("test child finished with %d\n", err);
 	} else if (WIFSIGNALED(status)) {
 		err = -1;
Signature · 1 line
1.8.5.2
maintainer Applied
#5 lore raw

Em Mon, May 11, 2015 at 03:17:07PM +0200, Jiri Olsa escreveu:

Quoted 10 lines · He Kuang
Quoted 7 lines

After this patch:

  $ perf test -v 1
  ...
  test child finished with -2
  ---- end ----
  vmlinux symtab matches kallsyms: Skip

Thanks, applied,

- Arnaldo

#6 lore raw
In reply to He Kuang
perf tests: Fix to get negative exit codes
Commit-ID:  189c466f77d421aef5c196454ab2e9517af7abc9
Gitweb:     http://git.kernel.org/tip/189c466f77d421aef5c196454ab2e9517af7abc9
Author:     He Kuang <[email protected]>
AuthorDate: Mon, 11 May 2015 12:28:35 +0000
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 12 May 2015 09:59:50 -0300

perf tests: Fix to get negative exit codes

WEXITSTATUS consists of the least significant 8 bits of the status argument, so we should convert the value to signed char if we have valid negative exit codes. And the return value of test->func() contains negative values:

  enum {
          TEST_OK   =  0,
          TEST_FAIL = -1,
          TEST_SKIP = -2,
  };

Before this patch:

  $ perf test -v 1
  ...
  test child finished with 254
  ---- end ----
  vmlinux symtab matches kallsyms: FAILED!

After this patch:

  $ perf test -v 1
  ...
  test child finished with -2
  ---- end ----
  vmlinux symtab matches kallsyms: Skip
---
 tools/perf/tests/builtin-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/builtin-test.c +1 -1
index 4f40981..f42af98 100644
@@ -219,7 +219,7 @@ static int run_test(struct test *test)
 	wait(&status);
 
 	if (WIFEXITED(status)) {
-		err = WEXITSTATUS(status);
+		err = (signed char)WEXITSTATUS(status);
 		pr_debug("test child finished with %d\n", err);
 	} else if (WIFSIGNALED(status)) {
 		err = -1;