linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 perf-tools-next 0/4] 'perf test' fixes/improvements
@ 2024-11-05 14:26 Arnaldo Carvalho de Melo
  2024-11-05 14:26 ` [PATCH v2 1/4] perf test python: Robustify the 'perf test python' test case Arnaldo Carvalho de Melo
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-05 14:26 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
	linux-perf-users, Arnaldo Carvalho de Melo, Athira Rajeev,
	Howard Chu, James Clark, Leo Yan, Thomas Richter,
	Veronika Molnarova

Hi,

        While evaluating what is needed for having shell tests that test
python functionality conditionally, i.e. so that we don't try to test
the python binding if NO_LIBPYTHON=1 is used, I stumbled into these
problems.

        The first patch its more for documenting that strange system()
behaviour and to check if this was something that would have
implications in other 'perf test' cases besides this python one, maybe
somebody will spot the problem, but at least it seems more compact now
using 'python -c inline-python-source'.

v2:

- Don't suppress the python binding test, instead skip it and tell the
  reason: the binding isn't available.

- Treat NO_LIBTRACEVENT=1 like NO_LIBPYTHON=1, not suppressing tests, just
  skipping them, warn the user on explicit suppression of the library.

- Also reduce a patch description verbosity, as noted by Ian.

- Arnaldo

Arnaldo Carvalho de Melo (4):
  perf test python: Robustify the 'perf test python' test case
  perf test: Skip the python binding builtin test case with NO_LIBPYTHON=1
  perf test: Don't suppress the libtraceevent tests, skip them
  perf build: Emit a warning when libtraceevent is explicitely disabled

 tools/perf/Makefile.config                  |  4 +++-
 tools/perf/tests/Build                      | 12 +++++-----
 tools/perf/tests/builtin-test.c             |  6 -----
 tools/perf/tests/evsel-tp-sched.c           | 16 +++++++++++--
 tools/perf/tests/mmap-basic.c               | 26 +++++++++++++++++++--
 tools/perf/tests/openat-syscall-all-cpus.c  | 11 ++++++++-
 tools/perf/tests/openat-syscall-tp-fields.c | 11 ++++++++-
 tools/perf/tests/openat-syscall.c           | 11 ++++++++-
 tools/perf/tests/python-use.c               | 24 ++++++++++++++++---
 tools/perf/tests/switch-tracking.c          | 23 +++++++++++++++++-
 10 files changed, 120 insertions(+), 24 deletions(-)

-- 
2.47.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/4] perf test python: Robustify the 'perf test python' test case
  2024-11-05 14:26 [PATCH v2 perf-tools-next 0/4] 'perf test' fixes/improvements Arnaldo Carvalho de Melo
@ 2024-11-05 14:26 ` Arnaldo Carvalho de Melo
  2024-11-05 14:26 ` [PATCH v2 2/4] perf test: Skip the python binding builtin test case with NO_LIBPYTHON=1 Arnaldo Carvalho de Melo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-05 14:26 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
	linux-perf-users, Arnaldo Carvalho de Melo, Athira Rajeev,
	Howard Chu, James Clark, Leo Yan, Thomas Richter,
	Veronika Molnarova

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Even without any python binding or support for loading it present in
perf, the 'import perf' 'perf test' says that testing that feature
somehow "passes":

  $ strace -s1024 -f -e execve perf test 17
  execve("/home/acme/bin/perf", ["perf", "test", "17"], 0x7ffe99ae5d50 /* 38 vars */) = 0
  strace: Process 519319 attached
   17: 'import perf' in python                                         : Running (1 active)
  strace: Process 519320 attached
  [pid 519320] execve("/bin/sh", ["sh", "-c", "--", "echo \"import sys ; sys.path.insert(0, '/tmp/build/perf-tools-next/python'); import perf\" |  2> /dev/null"], 0x377ba9a0 /* 40 vars */) = 0
  strace: Process 519321 attached
  strace: Process 519322 attached
<SNIP>
   17: 'import perf' in python                                         : Ok
  +++ exited with 0 +++
  $

It doesn't matter if we fork a new perf process to run just that test
entry or if we don't (using -F).

The system() call (that execve) will return zero even with that echo
being piped into nothing:

  # sh -c -- echo \"import sys ; sys.path.insert(0, '/tmp/build/perf-tools-next/python'); import perf\" |  2> /dev/null
  -bash: syntax error near unexpected token `0,'
  # echo $?
  2
  #

If we instead avoid the echo and use 'python -c' to pass that simple
python script just trying to load the non-existent perf binding we get
less processes and a more consistent result even in this pathological
case where PYTHON="":

  $ perf test 17
   17: 'import perf' in python                                         : FAILED!
  $ perf test -F 17
   17: 'import perf' in python                                         : FAILED!
  $
  $ perf test -vv 17
  Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
   17: 'import perf' in python:
  --- start ---
  test child forked, pid 522859
  python usage test: " -c "import sys ; sys.path.insert(0, '/tmp/build/perf-tools-next/python'); import perf" "
  sh: line 1: -c: command not found
  ---- end(-1) ----
   17: 'import perf' in python                                         : FAILED!
  $

The next patch will sidestep all this by plain not building the python
binding test when the binding isn't built, i.e. with NO_LIBPYTHON=1.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/python-use.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c
index 0ebc22ac8d5b47ed..b7325caad22bab10 100644
--- a/tools/perf/tests/python-use.c
+++ b/tools/perf/tests/python-use.c
@@ -14,8 +14,8 @@ static int test__python_use(struct test_suite *test __maybe_unused, int subtest
 	char *cmd;
 	int ret;
 
-	if (asprintf(&cmd, "echo \"import sys ; sys.path.insert(0, '%s'); import perf\" | %s %s",
-		     PYTHONPATH, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0)
+	if (asprintf(&cmd, "%s -c \"import sys ; sys.path.insert(0, '%s'); import perf\" %s",
+		     PYTHON, PYTHONPATH, verbose > 0 ? "" : "2> /dev/null") < 0)
 		return -1;
 
 	pr_debug("python usage test: \"%s\"\n", cmd);
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/4] perf test: Skip the python binding builtin test case with NO_LIBPYTHON=1
  2024-11-05 14:26 [PATCH v2 perf-tools-next 0/4] 'perf test' fixes/improvements Arnaldo Carvalho de Melo
  2024-11-05 14:26 ` [PATCH v2 1/4] perf test python: Robustify the 'perf test python' test case Arnaldo Carvalho de Melo
@ 2024-11-05 14:26 ` Arnaldo Carvalho de Melo
  2024-11-05 14:26 ` [PATCH v2 3/4] perf test: Don't suppress the libtraceevent tests, skip them Arnaldo Carvalho de Melo
  2024-11-05 14:26 ` [PATCH v2 4/4] perf build: Emit a warning when libtraceevent is explicitely disabled Arnaldo Carvalho de Melo
  3 siblings, 0 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-05 14:26 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
	linux-perf-users, Arnaldo Carvalho de Melo, Athira Rajeev,
	Howard Chu, James Clark, Leo Yan, Thomas Richter,
	Veronika Molnarova

From: Arnaldo Carvalho de Melo <acme@redhat.com>

The python_use test suite was being built and tested even when the
python binding that it is designed to test is not being built, fix it by
making it skip the test with an informative message.

Testing this patch:

When building with NO_LIBPYTHON=1, i.e. explicitely disabling linking
against libpython and thus not building the python binding:

  $ perf test 17
  17: 'import perf' in python     : Skip (No python binding, enable by not using NO_LIBPYTHON=1.)
  $

Not disabling linking with libpython, the default, that results in the
python binding being built:

  $ perf test 17
  17: 'import perf' in python     : Ok
  $

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/python-use.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c
index b7325caad22bab10..7a86e59ebb27fa75 100644
--- a/tools/perf/tests/python-use.c
+++ b/tools/perf/tests/python-use.c
@@ -11,6 +11,7 @@
 
 static int test__python_use(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
 {
+#ifdef HAVE_LIBPYTHON_SUPPORT
 	char *cmd;
 	int ret;
 
@@ -22,6 +23,23 @@ static int test__python_use(struct test_suite *test __maybe_unused, int subtest
 	ret = system(cmd) ? -1 : 0;
 	free(cmd);
 	return ret;
+#else
+	return TEST_SKIP;
+#endif // HAVE_LIBPYTHON_SUPPORT
 }
 
-DEFINE_SUITE("'import perf' in python", python_use);
+static struct test_case tests__python_use[] = {
+	{
+		.name	   = "python_use",
+		.desc	   = "'import perf' in python",
+		.run_case  = test__python_use,
+#ifndef HAVE_LIBPYTHON_SUPPORT
+		.skip_reason = "No python binding, enable by not using NO_LIBPYTHON=1",
+#endif
+       },
+};
+
+struct test_suite suite__python_use = {
+	.desc = "'import perf' in python",
+	.test_cases = tests__python_use,
+};
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/4] perf test: Don't suppress the libtraceevent tests, skip them
  2024-11-05 14:26 [PATCH v2 perf-tools-next 0/4] 'perf test' fixes/improvements Arnaldo Carvalho de Melo
  2024-11-05 14:26 ` [PATCH v2 1/4] perf test python: Robustify the 'perf test python' test case Arnaldo Carvalho de Melo
  2024-11-05 14:26 ` [PATCH v2 2/4] perf test: Skip the python binding builtin test case with NO_LIBPYTHON=1 Arnaldo Carvalho de Melo
@ 2024-11-05 14:26 ` Arnaldo Carvalho de Melo
  2024-11-05 15:50   ` Ian Rogers
  2024-11-09  0:14   ` Namhyung Kim
  2024-11-05 14:26 ` [PATCH v2 4/4] perf build: Emit a warning when libtraceevent is explicitely disabled Arnaldo Carvalho de Melo
  3 siblings, 2 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-05 14:26 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
	linux-perf-users, Arnaldo Carvalho de Melo, Athira Rajeev,
	Howard Chu, James Clark, Leo Yan, Thomas Richter,
	Veronika Molnarova

From: Arnaldo Carvalho de Melo <acme@redhat.com>

As suggested by Namhyung for the "import perf" python binding test, skip
the tests that require perf being linked with libtraceevent, telling the
reason:

  $ make -C tools/perf NO_LIBTRACEEVENT=1
  # perf check feature libtraceevent
         libtraceevent: [ OFF ]  # HAVE_LIBTRACEEVENT
  # ldd ~/bin/perf | grep traceevent
  #
  # perf test
    1: vmlinux symtab matches kallsyms                 : Ok
    2: Detect openat syscall event                     : Skip (not linked with libtraceevent)
    3: Detect openat syscall event on all cpus         : Skip (not linked with libtraceevent)
    4: mmap interface tests                            :
    4.1: Read samples using the mmap interface         : Skip (not linked with libtraceevent)
    4.2: User space counter reading of instructions    : Skip (not linked with libtraceevent)
    4.3: User space counter reading of cycles          : Skip (not linked with libtraceevent)
<SNIP>
   14: Parse sched tracepoints fields                  : Skip (not linked with libtraceevent)
   15: syscalls:sys_enter_openat event fields          : Skip (not linked with libtraceevent)
<SNIP>
   32: Track with sched_switch                         : Skip (not linked with libtraceevent)
<SNIP>

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/Build                      | 12 +++++-----
 tools/perf/tests/builtin-test.c             |  6 -----
 tools/perf/tests/evsel-tp-sched.c           | 16 +++++++++++--
 tools/perf/tests/mmap-basic.c               | 26 +++++++++++++++++++--
 tools/perf/tests/openat-syscall-all-cpus.c  | 11 ++++++++-
 tools/perf/tests/openat-syscall-tp-fields.c | 11 ++++++++-
 tools/perf/tests/openat-syscall.c           | 11 ++++++++-
 tools/perf/tests/switch-tracking.c          | 23 +++++++++++++++++-
 8 files changed, 96 insertions(+), 20 deletions(-)

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 01ed9335db4dba4e..c57ac14e7114e291 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -5,13 +5,13 @@ perf-test-y += tests-scripts.o
 perf-test-y += parse-events.o
 perf-test-y += dso-data.o
 perf-test-y += vmlinux-kallsyms.o
-perf-test-$(CONFIG_LIBTRACEEVENT) += openat-syscall.o
-perf-test-$(CONFIG_LIBTRACEEVENT) += openat-syscall-all-cpus.o
-perf-test-$(CONFIG_LIBTRACEEVENT) += openat-syscall-tp-fields.o
-perf-test-$(CONFIG_LIBTRACEEVENT) += mmap-basic.o
+perf-test-y += openat-syscall.o
+perf-test-y += openat-syscall-all-cpus.o
+perf-test-y += openat-syscall-tp-fields.o
+perf-test-y += mmap-basic.o
 perf-test-y += perf-record.o
 perf-test-y += evsel-roundtrip-name.o
-perf-test-$(CONFIG_LIBTRACEEVENT) += evsel-tp-sched.o
+perf-test-y += evsel-tp-sched.o
 perf-test-y += fdarray.o
 perf-test-y += pmu.o
 perf-test-y += pmu-events.o
@@ -29,7 +29,7 @@ perf-test-y += task-exit.o
 perf-test-y += sw-clock.o
 perf-test-y += mmap-thread-lookup.o
 perf-test-y += thread-maps-share.o
-perf-test-$(CONFIG_LIBTRACEEVENT) += switch-tracking.o
+perf-test-y += switch-tracking.o
 perf-test-y += keep-tracking.o
 perf-test-y += code-reading.o
 perf-test-y += sample-parsing.o
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index d2cabaa8ad922d68..5ebeaf3d7b69a8d0 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -60,11 +60,9 @@ static struct test_suite *arch_tests[] = {
 
 static struct test_suite *generic_tests[] = {
 	&suite__vmlinux_matches_kallsyms,
-#ifdef HAVE_LIBTRACEEVENT
 	&suite__openat_syscall_event,
 	&suite__openat_syscall_event_on_all_cpus,
 	&suite__basic_mmap,
-#endif
 	&suite__mem,
 	&suite__parse_events,
 	&suite__expr,
@@ -74,10 +72,8 @@ static struct test_suite *generic_tests[] = {
 	&suite__tool_pmu,
 	&suite__dso_data,
 	&suite__perf_evsel__roundtrip_name_test,
-#ifdef HAVE_LIBTRACEEVENT
 	&suite__perf_evsel__tp_sched_test,
 	&suite__syscall_openat_tp_fields,
-#endif
 	&suite__hists_link,
 	&suite__python_use,
 	&suite__bp_signal,
@@ -95,9 +91,7 @@ static struct test_suite *generic_tests[] = {
 	&suite__thread_maps_share,
 	&suite__hists_output,
 	&suite__hists_cumulate,
-#ifdef HAVE_LIBTRACEEVENT
 	&suite__switch_tracking,
-#endif
 	&suite__fdarray__filter,
 	&suite__fdarray__add,
 	&suite__kmod_path__parse,
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
index 3da6a76eac3856d1..a7d3a59f01217280 100644
--- a/tools/perf/tests/evsel-tp-sched.c
+++ b/tools/perf/tests/evsel-tp-sched.c
@@ -1,10 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/err.h>
-#include <traceevent/event-parse.h>
 #include "evsel.h"
 #include "tests.h"
 #include "debug.h"
 
+#ifdef HAVE_LIBTRACEEVENT
+#include <traceevent/event-parse.h>
+
 static int evsel__test_field(struct evsel *evsel, const char *name, int size, bool should_be_signed)
 {
 	struct tep_format_field *field = evsel__field(evsel, name);
@@ -31,10 +33,12 @@ static int evsel__test_field(struct evsel *evsel, const char *name, int size, bo
 
 	return ret;
 }
+#endif // HAVE_LIBTRACEEVENT
 
 static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unused,
 					   int subtest __maybe_unused)
 {
+#ifdef HAVE_LIBTRACEEVENT
 	struct evsel *evsel = evsel__newtp("sched", "sched_switch");
 	int ret = TEST_OK;
 
@@ -87,12 +91,20 @@ static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unuse
 
 	evsel__delete(evsel);
 	return ret;
+#else
+	return TEST_SKIP;
+#endif // HAVE_LIBTRACEEVENT
 }
 
 static struct test_case tests__perf_evsel__tp_sched_test[] = {
 	TEST_CASE_REASON("Parse sched tracepoints fields",
 			 perf_evsel__tp_sched_test,
-			 "permissions"),
+#ifdef HAVE_LIBTRACEEVENT
+			 "permissions"
+#else
+			 "not linked with libtraceevent"
+#endif
+			),
 	{	.name = NULL, }
 };
 
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index 012c8ae439fdcf56..f87ec3c40e091d5d 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -10,6 +10,7 @@
 #include "evsel.h"
 #include "thread_map.h"
 #include "tests.h"
+#include "tests/tests.h"
 #include "util/mmap.h"
 #include "util/sample.h"
 #include <linux/err.h>
@@ -31,6 +32,7 @@
  */
 static int test__basic_mmap(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
 {
+#ifdef HAVE_LIBTRACEEVENT
 	int err = TEST_FAIL;
 	union perf_event *event;
 	struct perf_thread_map *threads;
@@ -167,10 +169,14 @@ static int test__basic_mmap(struct test_suite *test __maybe_unused, int subtest
 out_free_threads:
 	perf_thread_map__put(threads);
 	return err;
+#else
+	return TEST_SKIP;
+#endif // HAVE_LIBTRACEEVENT
 }
 
-static int test_stat_user_read(int event)
+static int test_stat_user_read(int event __maybe_unused)
 {
+#ifdef HAVE_LIBTRACEEVENT
 	struct perf_counts_values counts = { .val = 0 };
 	struct perf_thread_map *threads;
 	struct perf_evsel *evsel;
@@ -264,6 +270,9 @@ static int test_stat_user_read(int event)
 
 	perf_thread_map__put(threads);
 	return ret;
+#else
+	return TEST_SKIP;
+#endif // HAVE_LIBTRACEEVENT
 }
 
 static int test__mmap_user_read_instr(struct test_suite *test __maybe_unused,
@@ -281,23 +290,36 @@ static int test__mmap_user_read_cycles(struct test_suite *test __maybe_unused,
 static struct test_case tests__basic_mmap[] = {
 	TEST_CASE_REASON("Read samples using the mmap interface",
 			 basic_mmap,
-			 "permissions"),
+#ifdef HAVE_LIBTRACEEVENT
+			 "permissions"
+#else
+			 "not linked with libtraceevent"
+#endif
+			),
 	TEST_CASE_REASON("User space counter reading of instructions",
 			 mmap_user_read_instr,
+#ifdef HAVE_LIBTRACEEVENT
 #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
 			 (defined(__riscv) && __riscv_xlen == 64)
 			 "permissions"
 #else
 			 "unsupported"
+#endif
+#else
+			 "not linked with libtraceevent"
 #endif
 		),
 	TEST_CASE_REASON("User space counter reading of cycles",
 			 mmap_user_read_cycles,
+#ifdef HAVE_LIBTRACEEVENT
 #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
 			 (defined(__riscv) && __riscv_xlen == 64)
 			 "permissions"
 #else
 			 "unsupported"
+#endif
+#else
+			 "not linked with libtraceevent"
 #endif
 		),
 	{	.name = NULL, }
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
index fb114118c87640b8..72dc22bef917f17d 100644
--- a/tools/perf/tests/openat-syscall-all-cpus.c
+++ b/tools/perf/tests/openat-syscall-all-cpus.c
@@ -22,6 +22,7 @@
 static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __maybe_unused,
 						  int subtest __maybe_unused)
 {
+#ifdef HAVE_LIBTRACEEVENT
 	int err = TEST_FAIL, fd, idx;
 	struct perf_cpu cpu;
 	struct perf_cpu_map *cpus;
@@ -122,13 +123,21 @@ static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __mayb
 out_thread_map_delete:
 	perf_thread_map__put(threads);
 	return err;
+#else
+	return TEST_SKIP;
+#endif // HAVE_LIBTRACEEVENT
 }
 
 
 static struct test_case tests__openat_syscall_event_on_all_cpus[] = {
 	TEST_CASE_REASON("Detect openat syscall event on all cpus",
 			 openat_syscall_event_on_all_cpus,
-			 "permissions"),
+#ifdef HAVE_LIBTRACEEVENT
+			 "permissions"
+#else
+			 "not linked with libtraceevent"
+#endif
+			),
 	{	.name = NULL, }
 };
 
diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
index 3943da441979c0fc..cc0e31958646e88c 100644
--- a/tools/perf/tests/openat-syscall-tp-fields.c
+++ b/tools/perf/tests/openat-syscall-tp-fields.c
@@ -26,6 +26,7 @@
 static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused,
 					  int subtest __maybe_unused)
 {
+#ifdef HAVE_LIBTRACEEVENT
 	struct record_opts opts = {
 		.target = {
 			.uid = UINT_MAX,
@@ -144,12 +145,20 @@ static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused
 	evlist__delete(evlist);
 out:
 	return ret;
+#else
+	return TEST_SKIP;
+#endif // HAVE_LIBTRACEEVENT
 }
 
 static struct test_case tests__syscall_openat_tp_fields[] = {
 	TEST_CASE_REASON("syscalls:sys_enter_openat event fields",
 			 syscall_openat_tp_fields,
-			 "permissions"),
+#ifdef HAVE_LIBTRACEEVENT
+			 "permissions"
+#else
+			 "not linked with libtraceevent"
+#endif
+			),
 	{	.name = NULL, }
 };
 
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
index 131b62271bfa270b..2ca0b7d2cca7672e 100644
--- a/tools/perf/tests/openat-syscall.c
+++ b/tools/perf/tests/openat-syscall.c
@@ -17,6 +17,7 @@
 static int test__openat_syscall_event(struct test_suite *test __maybe_unused,
 				      int subtest __maybe_unused)
 {
+#ifdef HAVE_LIBTRACEEVENT
 	int err = TEST_FAIL, fd;
 	struct evsel *evsel;
 	unsigned int nr_openat_calls = 111, i;
@@ -69,12 +70,20 @@ static int test__openat_syscall_event(struct test_suite *test __maybe_unused,
 out_thread_map_delete:
 	perf_thread_map__put(threads);
 	return err;
+#else
+	return TEST_SKIP;
+#endif // HAVE_LIBTRACEEVENT
 }
 
 static struct test_case tests__openat_syscall_event[] = {
 	TEST_CASE_REASON("Detect openat syscall event",
 			 openat_syscall_event,
-			 "permissions"),
+#ifdef HAVE_LIBTRACEEVENT
+			 "permissions"
+#else
+			 "not linked with libtraceevent"
+#endif
+			),
 	{	.name = NULL, }
 };
 
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index 5cab17a1942e67d7..591ae74b663af3c1 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -22,6 +22,7 @@
 #include "util/sample.h"
 #include "pmus.h"
 
+#ifdef HAVE_LIBTRACEEVENT
 static int spin_sleep(void)
 {
 	struct timeval start, now, diff, maxtime;
@@ -314,6 +315,7 @@ static int process_events(struct evlist *evlist,
 	free_event_nodes(&events);
 	return ret;
 }
+#endif // HAVE_LIBTRACEEVENT
 
 /**
  * test__switch_tracking - test using sched_switch and tracking events.
@@ -325,6 +327,7 @@ static int process_events(struct evlist *evlist,
  */
 static int test__switch_tracking(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
 {
+#ifdef HAVE_LIBTRACEEVENT
 	const char *sched_switch = "sched:sched_switch";
 	const char *cycles = "cycles:u";
 	struct switch_tracking switch_tracking = { .tids = NULL, };
@@ -581,6 +584,24 @@ static int test__switch_tracking(struct test_suite *test __maybe_unused, int sub
 out_err:
 	err = -1;
 	goto out;
+#else
+	return TEST_SKIP;
+#endif // HAVE_LIBTRACEEVENT
 }
 
-DEFINE_SUITE("Track with sched_switch", switch_tracking);
+static struct test_case tests__switch_tracking[] = {
+	{
+		.name = "switch_tracking",
+		.desc = "Track with sched_switch",
+		.run_case = test__switch_tracking,
+#ifndef HAVE_LIBTRACEEVENT
+		.skip_reason = "not linked with libtraceevent",
+#endif
+	},
+	{	.name = NULL, }
+};
+
+struct test_suite suite__switch_tracking = {
+	.desc = "Track with sched_switch",
+	.test_cases = tests__switch_tracking,
+};
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 4/4] perf build: Emit a warning when libtraceevent is explicitely disabled
  2024-11-05 14:26 [PATCH v2 perf-tools-next 0/4] 'perf test' fixes/improvements Arnaldo Carvalho de Melo
                   ` (2 preceding siblings ...)
  2024-11-05 14:26 ` [PATCH v2 3/4] perf test: Don't suppress the libtraceevent tests, skip them Arnaldo Carvalho de Melo
@ 2024-11-05 14:26 ` Arnaldo Carvalho de Melo
  3 siblings, 0 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-11-05 14:26 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
	linux-perf-users, Arnaldo Carvalho de Melo, Athira Rajeev,
	Howard Chu, James Clark, Leo Yan, Thomas Richter,
	Veronika Molnarova

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Since not having the libtraceevent devel package installed prevents the
build from proceeding unless NO_LIBTRACEEVENT=1 is passed:

  $ make O=/tmp/build/perf-tools-next/ -C tools/perf install-bin
  Makefile.config:1195: *** ERROR: libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel and/or set LIBTRACEEVENT_DIR or build with NO_LIBTRACEEVENT=1.  Stop.
  make[1]: *** [Makefile.perf:292: sub-make] Error 2
  make: *** [Makefile:119: install-bin] Error 2
  make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
  $

Behave just like with the NO_LIBPYTHON case:

  $ make NO_LIBPYTHON=1 NO_LIBTRACEEVENT=1 O=/tmp/build/perf-tools-next/ -C tools/perf install-bin
  Makefile.config:874: Python support disabled by user
  Makefile.config:1180: libtraceevent support disabled by user

  Auto-detecting system features:
<SNIP>

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile.config | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 80bf06e828f0ebc8..3ae3449ccf684b42 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -1180,7 +1180,9 @@ ifndef NO_LIBPFM4
 endif
 
 # libtraceevent is a recommended dependency picked up from the system.
-ifneq ($(NO_LIBTRACEEVENT),1)
+ifeq ($(NO_LIBTRACEEVENT),1)
+  msg := $(warning libtraceevent support disabled by user);
+else
   $(call feature_check,libtraceevent)
   ifeq ($(feature-libtraceevent), 1)
     CFLAGS += -DHAVE_LIBTRACEEVENT $(shell $(PKG_CONFIG) --cflags libtraceevent)
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/4] perf test: Don't suppress the libtraceevent tests, skip them
  2024-11-05 14:26 ` [PATCH v2 3/4] perf test: Don't suppress the libtraceevent tests, skip them Arnaldo Carvalho de Melo
@ 2024-11-05 15:50   ` Ian Rogers
  2024-11-08 17:50     ` Namhyung Kim
  2024-11-09  0:14   ` Namhyung Kim
  1 sibling, 1 reply; 8+ messages in thread
From: Ian Rogers @ 2024-11-05 15:50 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Ingo Molnar, Thomas Gleixner, Jiri Olsa,
	Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
	linux-perf-users, Arnaldo Carvalho de Melo, Athira Rajeev,
	Howard Chu, James Clark, Leo Yan, Thomas Richter,
	Veronika Molnarova

On Tue, Nov 5, 2024 at 6:26 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> As suggested by Namhyung for the "import perf" python binding test, skip
> the tests that require perf being linked with libtraceevent, telling the
> reason:
>
>   $ make -C tools/perf NO_LIBTRACEEVENT=1
>   # perf check feature libtraceevent
>          libtraceevent: [ OFF ]  # HAVE_LIBTRACEEVENT
>   # ldd ~/bin/perf | grep traceevent
>   #
>   # perf test
>     1: vmlinux symtab matches kallsyms                 : Ok
>     2: Detect openat syscall event                     : Skip (not linked with libtraceevent)
>     3: Detect openat syscall event on all cpus         : Skip (not linked with libtraceevent)
>     4: mmap interface tests                            :
>     4.1: Read samples using the mmap interface         : Skip (not linked with libtraceevent)
>     4.2: User space counter reading of instructions    : Skip (not linked with libtraceevent)
>     4.3: User space counter reading of cycles          : Skip (not linked with libtraceevent)
> <SNIP>
>    14: Parse sched tracepoints fields                  : Skip (not linked with libtraceevent)
>    15: syscalls:sys_enter_openat event fields          : Skip (not linked with libtraceevent)
> <SNIP>
>    32: Track with sched_switch                         : Skip (not linked with libtraceevent)
> <SNIP>
>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> Cc: Howard Chu <howardchu95@gmail.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: James Clark <james.clark@linaro.org>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Kan Liang <kan.liang@linux.intel.com>
> Cc: Leo Yan <leo.yan@linux.dev>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Thomas Richter <tmricht@linux.ibm.com>
> Cc: Veronika Molnarova <vmolnaro@redhat.com>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

This will conflict with:
https://lore.kernel.org/lkml/20241102165400.75785-7-irogers@google.com/

Thanks,
Ian

> ---
>  tools/perf/tests/Build                      | 12 +++++-----
>  tools/perf/tests/builtin-test.c             |  6 -----
>  tools/perf/tests/evsel-tp-sched.c           | 16 +++++++++++--
>  tools/perf/tests/mmap-basic.c               | 26 +++++++++++++++++++--
>  tools/perf/tests/openat-syscall-all-cpus.c  | 11 ++++++++-
>  tools/perf/tests/openat-syscall-tp-fields.c | 11 ++++++++-
>  tools/perf/tests/openat-syscall.c           | 11 ++++++++-
>  tools/perf/tests/switch-tracking.c          | 23 +++++++++++++++++-
>  8 files changed, 96 insertions(+), 20 deletions(-)
>
> diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
> index 01ed9335db4dba4e..c57ac14e7114e291 100644
> --- a/tools/perf/tests/Build
> +++ b/tools/perf/tests/Build
> @@ -5,13 +5,13 @@ perf-test-y += tests-scripts.o
>  perf-test-y += parse-events.o
>  perf-test-y += dso-data.o
>  perf-test-y += vmlinux-kallsyms.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += openat-syscall.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += openat-syscall-all-cpus.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += openat-syscall-tp-fields.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += mmap-basic.o
> +perf-test-y += openat-syscall.o
> +perf-test-y += openat-syscall-all-cpus.o
> +perf-test-y += openat-syscall-tp-fields.o
> +perf-test-y += mmap-basic.o
>  perf-test-y += perf-record.o
>  perf-test-y += evsel-roundtrip-name.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += evsel-tp-sched.o
> +perf-test-y += evsel-tp-sched.o
>  perf-test-y += fdarray.o
>  perf-test-y += pmu.o
>  perf-test-y += pmu-events.o
> @@ -29,7 +29,7 @@ perf-test-y += task-exit.o
>  perf-test-y += sw-clock.o
>  perf-test-y += mmap-thread-lookup.o
>  perf-test-y += thread-maps-share.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += switch-tracking.o
> +perf-test-y += switch-tracking.o
>  perf-test-y += keep-tracking.o
>  perf-test-y += code-reading.o
>  perf-test-y += sample-parsing.o
> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index d2cabaa8ad922d68..5ebeaf3d7b69a8d0 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -60,11 +60,9 @@ static struct test_suite *arch_tests[] = {
>
>  static struct test_suite *generic_tests[] = {
>         &suite__vmlinux_matches_kallsyms,
> -#ifdef HAVE_LIBTRACEEVENT
>         &suite__openat_syscall_event,
>         &suite__openat_syscall_event_on_all_cpus,
>         &suite__basic_mmap,
> -#endif
>         &suite__mem,
>         &suite__parse_events,
>         &suite__expr,
> @@ -74,10 +72,8 @@ static struct test_suite *generic_tests[] = {
>         &suite__tool_pmu,
>         &suite__dso_data,
>         &suite__perf_evsel__roundtrip_name_test,
> -#ifdef HAVE_LIBTRACEEVENT
>         &suite__perf_evsel__tp_sched_test,
>         &suite__syscall_openat_tp_fields,
> -#endif
>         &suite__hists_link,
>         &suite__python_use,
>         &suite__bp_signal,
> @@ -95,9 +91,7 @@ static struct test_suite *generic_tests[] = {
>         &suite__thread_maps_share,
>         &suite__hists_output,
>         &suite__hists_cumulate,
> -#ifdef HAVE_LIBTRACEEVENT
>         &suite__switch_tracking,
> -#endif
>         &suite__fdarray__filter,
>         &suite__fdarray__add,
>         &suite__kmod_path__parse,
> diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
> index 3da6a76eac3856d1..a7d3a59f01217280 100644
> --- a/tools/perf/tests/evsel-tp-sched.c
> +++ b/tools/perf/tests/evsel-tp-sched.c
> @@ -1,10 +1,12 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include <linux/err.h>
> -#include <traceevent/event-parse.h>
>  #include "evsel.h"
>  #include "tests.h"
>  #include "debug.h"
>
> +#ifdef HAVE_LIBTRACEEVENT
> +#include <traceevent/event-parse.h>
> +
>  static int evsel__test_field(struct evsel *evsel, const char *name, int size, bool should_be_signed)
>  {
>         struct tep_format_field *field = evsel__field(evsel, name);
> @@ -31,10 +33,12 @@ static int evsel__test_field(struct evsel *evsel, const char *name, int size, bo
>
>         return ret;
>  }
> +#endif // HAVE_LIBTRACEEVENT
>
>  static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unused,
>                                            int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>         struct evsel *evsel = evsel__newtp("sched", "sched_switch");
>         int ret = TEST_OK;
>
> @@ -87,12 +91,20 @@ static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unuse
>
>         evsel__delete(evsel);
>         return ret;
> +#else
> +       return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>
>  static struct test_case tests__perf_evsel__tp_sched_test[] = {
>         TEST_CASE_REASON("Parse sched tracepoints fields",
>                          perf_evsel__tp_sched_test,
> -                        "permissions"),
> +#ifdef HAVE_LIBTRACEEVENT
> +                        "permissions"
> +#else
> +                        "not linked with libtraceevent"
> +#endif
> +                       ),
>         {       .name = NULL, }
>  };
>
> diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
> index 012c8ae439fdcf56..f87ec3c40e091d5d 100644
> --- a/tools/perf/tests/mmap-basic.c
> +++ b/tools/perf/tests/mmap-basic.c
> @@ -10,6 +10,7 @@
>  #include "evsel.h"
>  #include "thread_map.h"
>  #include "tests.h"
> +#include "tests/tests.h"
>  #include "util/mmap.h"
>  #include "util/sample.h"
>  #include <linux/err.h>
> @@ -31,6 +32,7 @@
>   */
>  static int test__basic_mmap(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>         int err = TEST_FAIL;
>         union perf_event *event;
>         struct perf_thread_map *threads;
> @@ -167,10 +169,14 @@ static int test__basic_mmap(struct test_suite *test __maybe_unused, int subtest
>  out_free_threads:
>         perf_thread_map__put(threads);
>         return err;
> +#else
> +       return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>
> -static int test_stat_user_read(int event)
> +static int test_stat_user_read(int event __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>         struct perf_counts_values counts = { .val = 0 };
>         struct perf_thread_map *threads;
>         struct perf_evsel *evsel;
> @@ -264,6 +270,9 @@ static int test_stat_user_read(int event)
>
>         perf_thread_map__put(threads);
>         return ret;
> +#else
> +       return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>
>  static int test__mmap_user_read_instr(struct test_suite *test __maybe_unused,
> @@ -281,23 +290,36 @@ static int test__mmap_user_read_cycles(struct test_suite *test __maybe_unused,
>  static struct test_case tests__basic_mmap[] = {
>         TEST_CASE_REASON("Read samples using the mmap interface",
>                          basic_mmap,
> -                        "permissions"),
> +#ifdef HAVE_LIBTRACEEVENT
> +                        "permissions"
> +#else
> +                        "not linked with libtraceevent"
> +#endif
> +                       ),
>         TEST_CASE_REASON("User space counter reading of instructions",
>                          mmap_user_read_instr,
> +#ifdef HAVE_LIBTRACEEVENT
>  #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
>                          (defined(__riscv) && __riscv_xlen == 64)
>                          "permissions"
>  #else
>                          "unsupported"
> +#endif
> +#else
> +                        "not linked with libtraceevent"
>  #endif
>                 ),
>         TEST_CASE_REASON("User space counter reading of cycles",
>                          mmap_user_read_cycles,
> +#ifdef HAVE_LIBTRACEEVENT
>  #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
>                          (defined(__riscv) && __riscv_xlen == 64)
>                          "permissions"
>  #else
>                          "unsupported"
> +#endif
> +#else
> +                        "not linked with libtraceevent"
>  #endif
>                 ),
>         {       .name = NULL, }
> diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
> index fb114118c87640b8..72dc22bef917f17d 100644
> --- a/tools/perf/tests/openat-syscall-all-cpus.c
> +++ b/tools/perf/tests/openat-syscall-all-cpus.c
> @@ -22,6 +22,7 @@
>  static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __maybe_unused,
>                                                   int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>         int err = TEST_FAIL, fd, idx;
>         struct perf_cpu cpu;
>         struct perf_cpu_map *cpus;
> @@ -122,13 +123,21 @@ static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __mayb
>  out_thread_map_delete:
>         perf_thread_map__put(threads);
>         return err;
> +#else
> +       return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>
>
>  static struct test_case tests__openat_syscall_event_on_all_cpus[] = {
>         TEST_CASE_REASON("Detect openat syscall event on all cpus",
>                          openat_syscall_event_on_all_cpus,
> -                        "permissions"),
> +#ifdef HAVE_LIBTRACEEVENT
> +                        "permissions"
> +#else
> +                        "not linked with libtraceevent"
> +#endif
> +                       ),
>         {       .name = NULL, }
>  };
>
> diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
> index 3943da441979c0fc..cc0e31958646e88c 100644
> --- a/tools/perf/tests/openat-syscall-tp-fields.c
> +++ b/tools/perf/tests/openat-syscall-tp-fields.c
> @@ -26,6 +26,7 @@
>  static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused,
>                                           int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>         struct record_opts opts = {
>                 .target = {
>                         .uid = UINT_MAX,
> @@ -144,12 +145,20 @@ static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused
>         evlist__delete(evlist);
>  out:
>         return ret;
> +#else
> +       return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>
>  static struct test_case tests__syscall_openat_tp_fields[] = {
>         TEST_CASE_REASON("syscalls:sys_enter_openat event fields",
>                          syscall_openat_tp_fields,
> -                        "permissions"),
> +#ifdef HAVE_LIBTRACEEVENT
> +                        "permissions"
> +#else
> +                        "not linked with libtraceevent"
> +#endif
> +                       ),
>         {       .name = NULL, }
>  };
>
> diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
> index 131b62271bfa270b..2ca0b7d2cca7672e 100644
> --- a/tools/perf/tests/openat-syscall.c
> +++ b/tools/perf/tests/openat-syscall.c
> @@ -17,6 +17,7 @@
>  static int test__openat_syscall_event(struct test_suite *test __maybe_unused,
>                                       int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>         int err = TEST_FAIL, fd;
>         struct evsel *evsel;
>         unsigned int nr_openat_calls = 111, i;
> @@ -69,12 +70,20 @@ static int test__openat_syscall_event(struct test_suite *test __maybe_unused,
>  out_thread_map_delete:
>         perf_thread_map__put(threads);
>         return err;
> +#else
> +       return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>
>  static struct test_case tests__openat_syscall_event[] = {
>         TEST_CASE_REASON("Detect openat syscall event",
>                          openat_syscall_event,
> -                        "permissions"),
> +#ifdef HAVE_LIBTRACEEVENT
> +                        "permissions"
> +#else
> +                        "not linked with libtraceevent"
> +#endif
> +                       ),
>         {       .name = NULL, }
>  };
>
> diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
> index 5cab17a1942e67d7..591ae74b663af3c1 100644
> --- a/tools/perf/tests/switch-tracking.c
> +++ b/tools/perf/tests/switch-tracking.c
> @@ -22,6 +22,7 @@
>  #include "util/sample.h"
>  #include "pmus.h"
>
> +#ifdef HAVE_LIBTRACEEVENT
>  static int spin_sleep(void)
>  {
>         struct timeval start, now, diff, maxtime;
> @@ -314,6 +315,7 @@ static int process_events(struct evlist *evlist,
>         free_event_nodes(&events);
>         return ret;
>  }
> +#endif // HAVE_LIBTRACEEVENT
>
>  /**
>   * test__switch_tracking - test using sched_switch and tracking events.
> @@ -325,6 +327,7 @@ static int process_events(struct evlist *evlist,
>   */
>  static int test__switch_tracking(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>         const char *sched_switch = "sched:sched_switch";
>         const char *cycles = "cycles:u";
>         struct switch_tracking switch_tracking = { .tids = NULL, };
> @@ -581,6 +584,24 @@ static int test__switch_tracking(struct test_suite *test __maybe_unused, int sub
>  out_err:
>         err = -1;
>         goto out;
> +#else
> +       return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>
> -DEFINE_SUITE("Track with sched_switch", switch_tracking);
> +static struct test_case tests__switch_tracking[] = {
> +       {
> +               .name = "switch_tracking",
> +               .desc = "Track with sched_switch",
> +               .run_case = test__switch_tracking,
> +#ifndef HAVE_LIBTRACEEVENT
> +               .skip_reason = "not linked with libtraceevent",
> +#endif
> +       },
> +       {       .name = NULL, }
> +};
> +
> +struct test_suite suite__switch_tracking = {
> +       .desc = "Track with sched_switch",
> +       .test_cases = tests__switch_tracking,
> +};
> --
> 2.47.0
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/4] perf test: Don't suppress the libtraceevent tests, skip them
  2024-11-05 15:50   ` Ian Rogers
@ 2024-11-08 17:50     ` Namhyung Kim
  0 siblings, 0 replies; 8+ messages in thread
From: Namhyung Kim @ 2024-11-08 17:50 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Thomas Gleixner, Jiri Olsa,
	Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
	linux-perf-users, Arnaldo Carvalho de Melo, Athira Rajeev,
	Howard Chu, James Clark, Leo Yan, Thomas Richter,
	Veronika Molnarova

On Tue, Nov 05, 2024 at 07:50:25AM -0800, Ian Rogers wrote:
> On Tue, Nov 5, 2024 at 6:26 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> >
> > From: Arnaldo Carvalho de Melo <acme@redhat.com>
> >
> > As suggested by Namhyung for the "import perf" python binding test, skip
> > the tests that require perf being linked with libtraceevent, telling the
> > reason:
> >
> >   $ make -C tools/perf NO_LIBTRACEEVENT=1
> >   # perf check feature libtraceevent
> >          libtraceevent: [ OFF ]  # HAVE_LIBTRACEEVENT
> >   # ldd ~/bin/perf | grep traceevent
> >   #
> >   # perf test
> >     1: vmlinux symtab matches kallsyms                 : Ok
> >     2: Detect openat syscall event                     : Skip (not linked with libtraceevent)
> >     3: Detect openat syscall event on all cpus         : Skip (not linked with libtraceevent)
> >     4: mmap interface tests                            :
> >     4.1: Read samples using the mmap interface         : Skip (not linked with libtraceevent)
> >     4.2: User space counter reading of instructions    : Skip (not linked with libtraceevent)
> >     4.3: User space counter reading of cycles          : Skip (not linked with libtraceevent)
> > <SNIP>
> >    14: Parse sched tracepoints fields                  : Skip (not linked with libtraceevent)
> >    15: syscalls:sys_enter_openat event fields          : Skip (not linked with libtraceevent)
> > <SNIP>
> >    32: Track with sched_switch                         : Skip (not linked with libtraceevent)
> > <SNIP>
> >
> > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> > Cc: Howard Chu <howardchu95@gmail.com>
> > Cc: Ian Rogers <irogers@google.com>
> > Cc: James Clark <james.clark@linaro.org>
> > Cc: Jiri Olsa <jolsa@kernel.org>
> > Cc: Kan Liang <kan.liang@linux.intel.com>
> > Cc: Leo Yan <leo.yan@linux.dev>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Thomas Richter <tmricht@linux.ibm.com>
> > Cc: Veronika Molnarova <vmolnaro@redhat.com>
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> This will conflict with:
> https://lore.kernel.org/lkml/20241102165400.75785-7-irogers@google.com/

Let me process that first.

Thanks,
Namhyung


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/4] perf test: Don't suppress the libtraceevent tests, skip them
  2024-11-05 14:26 ` [PATCH v2 3/4] perf test: Don't suppress the libtraceevent tests, skip them Arnaldo Carvalho de Melo
  2024-11-05 15:50   ` Ian Rogers
@ 2024-11-09  0:14   ` Namhyung Kim
  1 sibling, 0 replies; 8+ messages in thread
From: Namhyung Kim @ 2024-11-09  0:14 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Thomas Gleixner, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Kan Liang, Clark Williams, linux-kernel,
	linux-perf-users, Arnaldo Carvalho de Melo, Athira Rajeev,
	Howard Chu, James Clark, Leo Yan, Thomas Richter,
	Veronika Molnarova

Hi Arnaldo,

On Tue, Nov 05, 2024 at 11:26:15AM -0300, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> As suggested by Namhyung for the "import perf" python binding test, skip
> the tests that require perf being linked with libtraceevent, telling the
> reason:
> 
>   $ make -C tools/perf NO_LIBTRACEEVENT=1
>   # perf check feature libtraceevent
>          libtraceevent: [ OFF ]  # HAVE_LIBTRACEEVENT
>   # ldd ~/bin/perf | grep traceevent
>   #
>   # perf test
>     1: vmlinux symtab matches kallsyms                 : Ok
>     2: Detect openat syscall event                     : Skip (not linked with libtraceevent)
>     3: Detect openat syscall event on all cpus         : Skip (not linked with libtraceevent)
>     4: mmap interface tests                            :
>     4.1: Read samples using the mmap interface         : Skip (not linked with libtraceevent)
>     4.2: User space counter reading of instructions    : Skip (not linked with libtraceevent)
>     4.3: User space counter reading of cycles          : Skip (not linked with libtraceevent)
> <SNIP>
>    14: Parse sched tracepoints fields                  : Skip (not linked with libtraceevent)
>    15: syscalls:sys_enter_openat event fields          : Skip (not linked with libtraceevent)
> <SNIP>
>    32: Track with sched_switch                         : Skip (not linked with libtraceevent)
> <SNIP>
> 
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> Cc: Howard Chu <howardchu95@gmail.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: James Clark <james.clark@linaro.org>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Kan Liang <kan.liang@linux.intel.com>
> Cc: Leo Yan <leo.yan@linux.dev>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Thomas Richter <tmricht@linux.ibm.com>
> Cc: Veronika Molnarova <vmolnaro@redhat.com>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>  tools/perf/tests/Build                      | 12 +++++-----
>  tools/perf/tests/builtin-test.c             |  6 -----
>  tools/perf/tests/evsel-tp-sched.c           | 16 +++++++++++--
>  tools/perf/tests/mmap-basic.c               | 26 +++++++++++++++++++--
>  tools/perf/tests/openat-syscall-all-cpus.c  | 11 ++++++++-
>  tools/perf/tests/openat-syscall-tp-fields.c | 11 ++++++++-
>  tools/perf/tests/openat-syscall.c           | 11 ++++++++-
>  tools/perf/tests/switch-tracking.c          | 23 +++++++++++++++++-
>  8 files changed, 96 insertions(+), 20 deletions(-)
> 
> diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
> index 01ed9335db4dba4e..c57ac14e7114e291 100644
> --- a/tools/perf/tests/Build
> +++ b/tools/perf/tests/Build
> @@ -5,13 +5,13 @@ perf-test-y += tests-scripts.o
>  perf-test-y += parse-events.o
>  perf-test-y += dso-data.o
>  perf-test-y += vmlinux-kallsyms.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += openat-syscall.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += openat-syscall-all-cpus.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += openat-syscall-tp-fields.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += mmap-basic.o
> +perf-test-y += openat-syscall.o
> +perf-test-y += openat-syscall-all-cpus.o
> +perf-test-y += openat-syscall-tp-fields.o
> +perf-test-y += mmap-basic.o
>  perf-test-y += perf-record.o
>  perf-test-y += evsel-roundtrip-name.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += evsel-tp-sched.o
> +perf-test-y += evsel-tp-sched.o
>  perf-test-y += fdarray.o
>  perf-test-y += pmu.o
>  perf-test-y += pmu-events.o
> @@ -29,7 +29,7 @@ perf-test-y += task-exit.o
>  perf-test-y += sw-clock.o
>  perf-test-y += mmap-thread-lookup.o
>  perf-test-y += thread-maps-share.o
> -perf-test-$(CONFIG_LIBTRACEEVENT) += switch-tracking.o
> +perf-test-y += switch-tracking.o
>  perf-test-y += keep-tracking.o
>  perf-test-y += code-reading.o
>  perf-test-y += sample-parsing.o
> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index d2cabaa8ad922d68..5ebeaf3d7b69a8d0 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -60,11 +60,9 @@ static struct test_suite *arch_tests[] = {
>  
>  static struct test_suite *generic_tests[] = {
>  	&suite__vmlinux_matches_kallsyms,
> -#ifdef HAVE_LIBTRACEEVENT
>  	&suite__openat_syscall_event,
>  	&suite__openat_syscall_event_on_all_cpus,
>  	&suite__basic_mmap,
> -#endif
>  	&suite__mem,
>  	&suite__parse_events,
>  	&suite__expr,
> @@ -74,10 +72,8 @@ static struct test_suite *generic_tests[] = {
>  	&suite__tool_pmu,
>  	&suite__dso_data,
>  	&suite__perf_evsel__roundtrip_name_test,
> -#ifdef HAVE_LIBTRACEEVENT
>  	&suite__perf_evsel__tp_sched_test,
>  	&suite__syscall_openat_tp_fields,
> -#endif
>  	&suite__hists_link,
>  	&suite__python_use,
>  	&suite__bp_signal,
> @@ -95,9 +91,7 @@ static struct test_suite *generic_tests[] = {
>  	&suite__thread_maps_share,
>  	&suite__hists_output,
>  	&suite__hists_cumulate,
> -#ifdef HAVE_LIBTRACEEVENT
>  	&suite__switch_tracking,
> -#endif
>  	&suite__fdarray__filter,
>  	&suite__fdarray__add,
>  	&suite__kmod_path__parse,
> diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
> index 3da6a76eac3856d1..a7d3a59f01217280 100644
> --- a/tools/perf/tests/evsel-tp-sched.c
> +++ b/tools/perf/tests/evsel-tp-sched.c
> @@ -1,10 +1,12 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include <linux/err.h>
> -#include <traceevent/event-parse.h>
>  #include "evsel.h"
>  #include "tests.h"
>  #include "debug.h"
>  
> +#ifdef HAVE_LIBTRACEEVENT
> +#include <traceevent/event-parse.h>

I'm about to process this for the header path.

https://lore.kernel.org/linux-perf-users/20241105105649.45399-1-yangyicong@huawei.com/

> +
>  static int evsel__test_field(struct evsel *evsel, const char *name, int size, bool should_be_signed)
>  {
>  	struct tep_format_field *field = evsel__field(evsel, name);
> @@ -31,10 +33,12 @@ static int evsel__test_field(struct evsel *evsel, const char *name, int size, bo
>  
>  	return ret;
>  }
> +#endif // HAVE_LIBTRACEEVENT
>  
>  static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unused,
>  					   int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT

It doesn't look good we need #ifdef every places.  Is it possible to
check it as an integer value and return early if it's not available?

	if (!HAVE_LIBTRACEEVENT)
		return TEST_SKIP;

I guess it'd break where it just checks if it's defined.  Probably we
need a separate global variable to be set using the value.

Obviously it cannot be applied if it needs to see the definition of
data type in the libtraceevent.  But I think encapsulated things
already.


>  	struct evsel *evsel = evsel__newtp("sched", "sched_switch");
>  	int ret = TEST_OK;
>  
> @@ -87,12 +91,20 @@ static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unuse
>  
>  	evsel__delete(evsel);
>  	return ret;
> +#else
> +	return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>  
>  static struct test_case tests__perf_evsel__tp_sched_test[] = {
>  	TEST_CASE_REASON("Parse sched tracepoints fields",
>  			 perf_evsel__tp_sched_test,
> -			 "permissions"),
> +#ifdef HAVE_LIBTRACEEVENT
> +			 "permissions"
> +#else
> +			 "not linked with libtraceevent"
> +#endif

Hmm.. maybe it needs to update the reason of the skip.  Something like
this?

	if (!IS_ENABLED(CONFIG_LIBTRACEEVENT)) {
		test->skip_reason = "not linked with libtraceevent";
		return TEST_SKIP;
	}

Thanks,
Namhyung


> +			),
>  	{	.name = NULL, }
>  };
>  
> diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
> index 012c8ae439fdcf56..f87ec3c40e091d5d 100644
> --- a/tools/perf/tests/mmap-basic.c
> +++ b/tools/perf/tests/mmap-basic.c
> @@ -10,6 +10,7 @@
>  #include "evsel.h"
>  #include "thread_map.h"
>  #include "tests.h"
> +#include "tests/tests.h"
>  #include "util/mmap.h"
>  #include "util/sample.h"
>  #include <linux/err.h>
> @@ -31,6 +32,7 @@
>   */
>  static int test__basic_mmap(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>  	int err = TEST_FAIL;
>  	union perf_event *event;
>  	struct perf_thread_map *threads;
> @@ -167,10 +169,14 @@ static int test__basic_mmap(struct test_suite *test __maybe_unused, int subtest
>  out_free_threads:
>  	perf_thread_map__put(threads);
>  	return err;
> +#else
> +	return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>  
> -static int test_stat_user_read(int event)
> +static int test_stat_user_read(int event __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>  	struct perf_counts_values counts = { .val = 0 };
>  	struct perf_thread_map *threads;
>  	struct perf_evsel *evsel;
> @@ -264,6 +270,9 @@ static int test_stat_user_read(int event)
>  
>  	perf_thread_map__put(threads);
>  	return ret;
> +#else
> +	return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>  
>  static int test__mmap_user_read_instr(struct test_suite *test __maybe_unused,
> @@ -281,23 +290,36 @@ static int test__mmap_user_read_cycles(struct test_suite *test __maybe_unused,
>  static struct test_case tests__basic_mmap[] = {
>  	TEST_CASE_REASON("Read samples using the mmap interface",
>  			 basic_mmap,
> -			 "permissions"),
> +#ifdef HAVE_LIBTRACEEVENT
> +			 "permissions"
> +#else
> +			 "not linked with libtraceevent"
> +#endif
> +			),
>  	TEST_CASE_REASON("User space counter reading of instructions",
>  			 mmap_user_read_instr,
> +#ifdef HAVE_LIBTRACEEVENT
>  #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
>  			 (defined(__riscv) && __riscv_xlen == 64)
>  			 "permissions"
>  #else
>  			 "unsupported"
> +#endif
> +#else
> +			 "not linked with libtraceevent"
>  #endif
>  		),
>  	TEST_CASE_REASON("User space counter reading of cycles",
>  			 mmap_user_read_cycles,
> +#ifdef HAVE_LIBTRACEEVENT
>  #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
>  			 (defined(__riscv) && __riscv_xlen == 64)
>  			 "permissions"
>  #else
>  			 "unsupported"
> +#endif
> +#else
> +			 "not linked with libtraceevent"
>  #endif
>  		),
>  	{	.name = NULL, }
> diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
> index fb114118c87640b8..72dc22bef917f17d 100644
> --- a/tools/perf/tests/openat-syscall-all-cpus.c
> +++ b/tools/perf/tests/openat-syscall-all-cpus.c
> @@ -22,6 +22,7 @@
>  static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __maybe_unused,
>  						  int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>  	int err = TEST_FAIL, fd, idx;
>  	struct perf_cpu cpu;
>  	struct perf_cpu_map *cpus;
> @@ -122,13 +123,21 @@ static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __mayb
>  out_thread_map_delete:
>  	perf_thread_map__put(threads);
>  	return err;
> +#else
> +	return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>  
>  
>  static struct test_case tests__openat_syscall_event_on_all_cpus[] = {
>  	TEST_CASE_REASON("Detect openat syscall event on all cpus",
>  			 openat_syscall_event_on_all_cpus,
> -			 "permissions"),
> +#ifdef HAVE_LIBTRACEEVENT
> +			 "permissions"
> +#else
> +			 "not linked with libtraceevent"
> +#endif
> +			),
>  	{	.name = NULL, }
>  };
>  
> diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
> index 3943da441979c0fc..cc0e31958646e88c 100644
> --- a/tools/perf/tests/openat-syscall-tp-fields.c
> +++ b/tools/perf/tests/openat-syscall-tp-fields.c
> @@ -26,6 +26,7 @@
>  static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused,
>  					  int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>  	struct record_opts opts = {
>  		.target = {
>  			.uid = UINT_MAX,
> @@ -144,12 +145,20 @@ static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused
>  	evlist__delete(evlist);
>  out:
>  	return ret;
> +#else
> +	return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>  
>  static struct test_case tests__syscall_openat_tp_fields[] = {
>  	TEST_CASE_REASON("syscalls:sys_enter_openat event fields",
>  			 syscall_openat_tp_fields,
> -			 "permissions"),
> +#ifdef HAVE_LIBTRACEEVENT
> +			 "permissions"
> +#else
> +			 "not linked with libtraceevent"
> +#endif
> +			),
>  	{	.name = NULL, }
>  };
>  
> diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
> index 131b62271bfa270b..2ca0b7d2cca7672e 100644
> --- a/tools/perf/tests/openat-syscall.c
> +++ b/tools/perf/tests/openat-syscall.c
> @@ -17,6 +17,7 @@
>  static int test__openat_syscall_event(struct test_suite *test __maybe_unused,
>  				      int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>  	int err = TEST_FAIL, fd;
>  	struct evsel *evsel;
>  	unsigned int nr_openat_calls = 111, i;
> @@ -69,12 +70,20 @@ static int test__openat_syscall_event(struct test_suite *test __maybe_unused,
>  out_thread_map_delete:
>  	perf_thread_map__put(threads);
>  	return err;
> +#else
> +	return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>  
>  static struct test_case tests__openat_syscall_event[] = {
>  	TEST_CASE_REASON("Detect openat syscall event",
>  			 openat_syscall_event,
> -			 "permissions"),
> +#ifdef HAVE_LIBTRACEEVENT
> +			 "permissions"
> +#else
> +			 "not linked with libtraceevent"
> +#endif
> +			),
>  	{	.name = NULL, }
>  };
>  
> diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
> index 5cab17a1942e67d7..591ae74b663af3c1 100644
> --- a/tools/perf/tests/switch-tracking.c
> +++ b/tools/perf/tests/switch-tracking.c
> @@ -22,6 +22,7 @@
>  #include "util/sample.h"
>  #include "pmus.h"
>  
> +#ifdef HAVE_LIBTRACEEVENT
>  static int spin_sleep(void)
>  {
>  	struct timeval start, now, diff, maxtime;
> @@ -314,6 +315,7 @@ static int process_events(struct evlist *evlist,
>  	free_event_nodes(&events);
>  	return ret;
>  }
> +#endif // HAVE_LIBTRACEEVENT
>  
>  /**
>   * test__switch_tracking - test using sched_switch and tracking events.
> @@ -325,6 +327,7 @@ static int process_events(struct evlist *evlist,
>   */
>  static int test__switch_tracking(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
>  {
> +#ifdef HAVE_LIBTRACEEVENT
>  	const char *sched_switch = "sched:sched_switch";
>  	const char *cycles = "cycles:u";
>  	struct switch_tracking switch_tracking = { .tids = NULL, };
> @@ -581,6 +584,24 @@ static int test__switch_tracking(struct test_suite *test __maybe_unused, int sub
>  out_err:
>  	err = -1;
>  	goto out;
> +#else
> +	return TEST_SKIP;
> +#endif // HAVE_LIBTRACEEVENT
>  }
>  
> -DEFINE_SUITE("Track with sched_switch", switch_tracking);
> +static struct test_case tests__switch_tracking[] = {
> +	{
> +		.name = "switch_tracking",
> +		.desc = "Track with sched_switch",
> +		.run_case = test__switch_tracking,
> +#ifndef HAVE_LIBTRACEEVENT
> +		.skip_reason = "not linked with libtraceevent",
> +#endif
> +	},
> +	{	.name = NULL, }
> +};
> +
> +struct test_suite suite__switch_tracking = {
> +	.desc = "Track with sched_switch",
> +	.test_cases = tests__switch_tracking,
> +};
> -- 
> 2.47.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-09  0:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-05 14:26 [PATCH v2 perf-tools-next 0/4] 'perf test' fixes/improvements Arnaldo Carvalho de Melo
2024-11-05 14:26 ` [PATCH v2 1/4] perf test python: Robustify the 'perf test python' test case Arnaldo Carvalho de Melo
2024-11-05 14:26 ` [PATCH v2 2/4] perf test: Skip the python binding builtin test case with NO_LIBPYTHON=1 Arnaldo Carvalho de Melo
2024-11-05 14:26 ` [PATCH v2 3/4] perf test: Don't suppress the libtraceevent tests, skip them Arnaldo Carvalho de Melo
2024-11-05 15:50   ` Ian Rogers
2024-11-08 17:50     ` Namhyung Kim
2024-11-09  0:14   ` Namhyung Kim
2024-11-05 14:26 ` [PATCH v2 4/4] perf build: Emit a warning when libtraceevent is explicitely disabled Arnaldo Carvalho de Melo

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).