alistair23-linux/tools/perf/tests/python-use.c
Arnaldo Carvalho de Melo 721a1f53df perf tests: Pass the subtest index to each test routine
Some tests have sub-tests we want to run, so allow passing this.

Wang tried to avoid having to touch all tests, but then, having the
test.func in an anonymous union makes the build fail on older compilers,
like the one in RHEL6, where:

  test a = {
	.func = foo,
  };

fails.

To fix it leave the func pointer in the main structure and pass the subtest
index to all tests, end result function is the same, but we have just one
function pointer, not two, with and without the subtest index as an argument.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-5genj0ficwdmelpoqlds0u4y@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-11-19 13:19:15 -03:00

25 lines
459 B
C

/*
* Just test if we can load the python binding.
*/
#include <stdio.h>
#include <stdlib.h>
#include <linux/compiler.h>
#include "tests.h"
extern int verbose;
int test__python_use(int subtest __maybe_unused)
{
char *cmd;
int ret;
if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s",
PYTHONPATH, PYTHON, verbose ? "" : "2> /dev/null") < 0)
return -1;
ret = system(cmd) ? -1 : 0;
free(cmd);
return ret;
}