mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
Make tests to be two binaries 'tests_static' and 'tests_shared', so the maintenance is easier. Adding tests under libperf build system, so we define all the flags just once. Adding make-tests tule to just compile tests without running them. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Shunsuke Nakamura <nakamura.shun@fujitsu.com> Link: http://lore.kernel.org/lkml/20210706151704.73662-2-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
65 lines
1.6 KiB
C
65 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __LIBPERF_INTERNAL_TESTS_H
|
|
#define __LIBPERF_INTERNAL_TESTS_H
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
extern int tests_failed;
|
|
extern 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 \
|
|
do { \
|
|
tests_verbose = get_verbose(argv, argc); \
|
|
fprintf(stdout, "- running %s...", __FILE__); \
|
|
fflush(NULL); \
|
|
tests_failed = 0; \
|
|
} while (0)
|
|
|
|
#define __T_END \
|
|
do { \
|
|
if (tests_failed) \
|
|
fprintf(stdout, " FAILED (%d)\n", tests_failed); \
|
|
else \
|
|
fprintf(stdout, "OK\n"); \
|
|
} while (0)
|
|
|
|
#define __T(text, cond) \
|
|
do { \
|
|
if (!(cond)) { \
|
|
fprintf(stderr, "FAILED %s:%d %s\n", __FILE__, __LINE__, text); \
|
|
tests_failed++; \
|
|
return -1; \
|
|
} \
|
|
} 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 */
|