[LTP] [PATCH RFC] perf_event_open02: check if PERF_COUNT_HW_INSTRUCTIONS is supported

Li Wang liwang@redhat.com
Tue Mar 12 06:32:36 CET 2019


The testcase is broken on system with PERF_COUNT_HW_INSTRUCTIONS not supported.
Previously, it does the event check in count_hardware_counters, but that has
been filtered out on s390 platform via commit 6730475ba5. So now test break
as follow:
  perf_event_open02    1  TBROK  :  perf_event_open02.c:275: perf_event_open failed: errno=ENOENT(2): No such file or directory
  perf_event_open02    2  TBROK  :  perf_event_open02.c:275: Remaining cases broken

Signed-off-by: Li Wang <liwang@redhat.com>
---
 .../perf_event_open/perf_event_open02.c         | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
index cdaa5c80c..95e30519f 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
@@ -268,9 +268,20 @@ static void setup(void)
 		tsk_event.disabled = 0;
 		for (i = 0; i < n; ++i) {
 			hwfd[i] = perf_event_open(&hw_event, 0, -1, -1, 0);
-			tskfd[i] = perf_event_open(&tsk_event, 0, -1,
-						   hwfd[i], 0);
-			if (tskfd[i] == -1 || hwfd[i] == -1) {
+			if (hwfd[i] == -1) {
+				if (errno == ENOENT || errno == ENODEV) {
+					tst_brkm(TCONF | TERRNO, cleanup,
+						"PERF_COUNT_HW_INSTRUCTIONS not supported");
+				}
+				tst_brkm(TBROK | TERRNO, cleanup,
+					 "perf_event_open failed");
+			}
+			tskfd[i] = perf_event_open(&tsk_event, 0, -1, hwfd[i], 0);
+			if (tskfd[i] == -1) {
+				if (errno == ENOENT || errno == ENODEV) {
+					tst_brkm(TCONF | TERRNO, cleanup,
+						"PERF_COUNT_SW_TASK_CLOCK not supported");
+				}
 				tst_brkm(TBROK | TERRNO, cleanup,
 					 "perf_event_open failed");
 			}
-- 
2.20.1



More information about the ltp mailing list