Skip to contentSkip to conversation

libperf tests: If a test fails return non-zero

PATCH Applied Ian Rogers 3 participants 4 messages Jan 14, 2021 – Jan 15, 2021 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/2 libperf tests: If a test fails return non-zero

If a test fails return -1 rather than 0. This is consistent with the return value in test-cpumap.c

---
 tools/lib/perf/tests/test-cpumap.c    | 2 +-
 tools/lib/perf/tests/test-evlist.c    | 2 +-
 tools/lib/perf/tests/test-evsel.c     | 2 +-
 tools/lib/perf/tests/test-threadmap.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
tools/lib/perf/tests/test-cpumap.c +1 -1
index c8d45091e7c2..c70e9e03af3e 100644
@@ -27,5 +27,5 @@ int main(int argc, char **argv)
 	perf_cpu_map__put(cpus);
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
tools/lib/perf/tests/test-evlist.c +1 -1
index 6d8ebe0c2504..d913241d4135 100644
@@ -409,5 +409,5 @@ int main(int argc, char **argv)
 	test_mmap_cpus();
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
tools/lib/perf/tests/test-evsel.c +1 -1
index 135722ac965b..0ad82d7a2a51 100644
@@ -131,5 +131,5 @@ int main(int argc, char **argv)
 	test_stat_thread_enable();
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
tools/lib/perf/tests/test-threadmap.c +1 -1
index 7dc4d6fbedde..384471441b48 100644
@@ -27,5 +27,5 @@ int main(int argc, char **argv)
 	perf_thread_map__put(threads);
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
author reviewer
#1 lore raw

PATCH 2/2 libperf tests: Fail when failing to get a tracepoint id

Permissions are necessary to get a tracepoint id. Fail the test when the read fails.

---
 tools/lib/perf/tests/test-evlist.c | 1 +
 1 file changed, 1 insertion(+)
tools/lib/perf/tests/test-evlist.c +1 -0
index d913241d4135..bd19cabddaf6 100644
@@ -215,6 +215,7 @@ static int test_mmap_thread(void)
 		 sysfs__mountpoint());
 
 	if (filename__read_int(path, &id)) {
+		tests_failed++;
 		fprintf(stderr, "error: failed to get tracepoint id: %s\n", path);
 		return -1;
 	}
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
Acked-by on v1 1/2
#2 lore raw
In reply to Ian Rogers
Quoted 4 lines · Ian Rogers

If a test fails return -1 rather than 0. This is consistent with the return value in test-cpumap.c

for the patchset

thanks,
jirka

Quoted 54 lines
---
 tools/lib/perf/tests/test-cpumap.c    | 2 +-
 tools/lib/perf/tests/test-evlist.c    | 2 +-
 tools/lib/perf/tests/test-evsel.c     | 2 +-
 tools/lib/perf/tests/test-threadmap.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
tools/lib/perf/tests/test-cpumap.c +1 -1
index c8d45091e7c2..c70e9e03af3e 100644
@@ -27,5 +27,5 @@ int main(int argc, char **argv)
 	perf_cpu_map__put(cpus);
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
tools/lib/perf/tests/test-evlist.c +1 -1
index 6d8ebe0c2504..d913241d4135 100644
@@ -409,5 +409,5 @@ int main(int argc, char **argv)
 	test_mmap_cpus();
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
tools/lib/perf/tests/test-evsel.c +1 -1
index 135722ac965b..0ad82d7a2a51 100644
@@ -131,5 +131,5 @@ int main(int argc, char **argv)
 	test_stat_thread_enable();
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
tools/lib/perf/tests/test-threadmap.c +1 -1
index 7dc4d6fbedde..384471441b48 100644
@@ -27,5 +27,5 @@ int main(int argc, char **argv)
 	perf_thread_map__put(threads);
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
maintainer Applied
#3 lore raw
In reply to Ian Rogers

Em Thu, Jan 14, 2021 at 10:02:49AM -0800, Ian Rogers escreveu:

Quoted 2 lines

If a test fails return -1 rather than 0. This is consistent with the return value in test-cpumap.c

Thanks, applied both patches.

- Arnaldo

Quoted 55 lines
---
 tools/lib/perf/tests/test-cpumap.c    | 2 +-
 tools/lib/perf/tests/test-evlist.c    | 2 +-
 tools/lib/perf/tests/test-evsel.c     | 2 +-
 tools/lib/perf/tests/test-threadmap.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
tools/lib/perf/tests/test-cpumap.c +1 -1
index c8d45091e7c2..c70e9e03af3e 100644
@@ -27,5 +27,5 @@ int main(int argc, char **argv)
 	perf_cpu_map__put(cpus);
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
tools/lib/perf/tests/test-evlist.c +1 -1
index 6d8ebe0c2504..d913241d4135 100644
@@ -409,5 +409,5 @@ int main(int argc, char **argv)
 	test_mmap_cpus();
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
tools/lib/perf/tests/test-evsel.c +1 -1
index 135722ac965b..0ad82d7a2a51 100644
@@ -131,5 +131,5 @@ int main(int argc, char **argv)
 	test_stat_thread_enable();
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
tools/lib/perf/tests/test-threadmap.c +1 -1
index 7dc4d6fbedde..384471441b48 100644
@@ -27,5 +27,5 @@ int main(int argc, char **argv)
 	perf_thread_map__put(threads);
 
 	__T_END;
-	return 0;
+	return tests_failed == 0 ? 0 : -1;
 }
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
Signature · 1 line
- Arnaldo