Commit d3003d9e authored by Rob Herring's avatar Rob Herring Committed by Arnaldo Carvalho de Melo

libperf tests: Add support for verbose printing

Add __T_VERBOSE() so tests can add verbose output. The verbose output is
enabled with the '-v' command line option. Running 'make tests V=1' will
enable the '-v' option when running the tests.

It'll be used in the next patch, for a user space counter access test.
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Itaru Kitayama <itaru.kitayama@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Link: http://lore.kernel.org/lkml/20210414155412.3697605-3-robh@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6cd70754
...@@ -3,11 +3,32 @@ ...@@ -3,11 +3,32 @@
#define __LIBPERF_INTERNAL_TESTS_H #define __LIBPERF_INTERNAL_TESTS_H
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
int tests_failed; int tests_failed;
int tests_verbose;
static inline int get_verbose(char **argv, int argc)
{
int c;
int verbose = 0;
while ((c = getopt(argc, argv, "v")) != -1) {
switch (c)
{
case 'v':
verbose = 1;
break;
default:
break;
}
}
return verbose;
}
#define __T_START \ #define __T_START \
do { \ do { \
tests_verbose = get_verbose(argv, argc); \
fprintf(stdout, "- running %s...", __FILE__); \ fprintf(stdout, "- running %s...", __FILE__); \
fflush(NULL); \ fflush(NULL); \
tests_failed = 0; \ tests_failed = 0; \
...@@ -30,4 +51,15 @@ do { ...@@ -30,4 +51,15 @@ do {
} \ } \
} while (0) } while (0)
#define __T_VERBOSE(...) \
do { \
if (tests_verbose) { \
if (tests_verbose == 1) { \
fputc('\n', stderr); \
tests_verbose++; \
} \
fprintf(stderr, ##__VA_ARGS__); \
} \
} while (0)
#endif /* __LIBPERF_INTERNAL_TESTS_H */ #endif /* __LIBPERF_INTERNAL_TESTS_H */
...@@ -5,6 +5,8 @@ TESTS = test-cpumap test-threadmap test-evlist test-evsel ...@@ -5,6 +5,8 @@ TESTS = test-cpumap test-threadmap test-evlist test-evsel
TESTS_SO := $(addsuffix -so,$(TESTS)) TESTS_SO := $(addsuffix -so,$(TESTS))
TESTS_A := $(addsuffix -a,$(TESTS)) TESTS_A := $(addsuffix -a,$(TESTS))
TEST_ARGS := $(if $(V),-v)
# Set compile option CFLAGS # Set compile option CFLAGS
ifdef EXTRA_CFLAGS ifdef EXTRA_CFLAGS
CFLAGS := $(EXTRA_CFLAGS) CFLAGS := $(EXTRA_CFLAGS)
...@@ -28,9 +30,9 @@ all: $(TESTS_A) $(TESTS_SO) ...@@ -28,9 +30,9 @@ all: $(TESTS_A) $(TESTS_SO)
run: run:
@echo "running static:" @echo "running static:"
@for i in $(TESTS_A); do ./$$i; done @for i in $(TESTS_A); do ./$$i $(TEST_ARGS); done
@echo "running dynamic:" @echo "running dynamic:"
@for i in $(TESTS_SO); do LD_LIBRARY_PATH=../ ./$$i; done @for i in $(TESTS_SO); do LD_LIBRARY_PATH=../ ./$$i $(TEST_ARGS); done
clean: clean:
$(call QUIET_CLEAN, tests)$(RM) $(TESTS_A) $(TESTS_SO) $(call QUIET_CLEAN, tests)$(RM) $(TESTS_A) $(TESTS_SO)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment