blob: 6b990ee385756b76198a7aa7e235c3cc5bcedda4 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Arnaldo Carvalho de Melo54359d32012-12-14 13:06:13 -03002/*
3 * Just test if we can load the python binding.
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
Arnaldo Carvalho de Melo721a1f52015-11-19 12:01:48 -03008#include <linux/compiler.h>
Arnaldo Carvalho de Melo54359d32012-12-14 13:06:13 -03009#include "tests.h"
Thomas Richtere9ee0dc2018-05-28 15:48:17 +020010#include "util/debug.h"
Arnaldo Carvalho de Melo54359d32012-12-14 13:06:13 -030011
Ian Rogers33f44bf2021-11-03 23:41:51 -070012static int test__python_use(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
Arnaldo Carvalho de Melo54359d32012-12-14 13:06:13 -030013{
14 char *cmd;
15 int ret;
16
Namhyung Kim000ae332012-12-17 16:25:01 +090017 if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s",
Namhyung Kimbb963e12017-02-17 17:17:38 +090018 PYTHONPATH, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0)
Arnaldo Carvalho de Melo54359d32012-12-14 13:06:13 -030019 return -1;
20
Arnaldo Carvalho de Melo0fd0f002020-10-13 16:22:03 -030021 pr_debug("python usage test: \"%s\"\n", cmd);
Arnaldo Carvalho de Melo54359d32012-12-14 13:06:13 -030022 ret = system(cmd) ? -1 : 0;
23 free(cmd);
24 return ret;
25}
Ian Rogersd68f0362021-11-03 23:41:50 -070026
27DEFINE_SUITE("'import perf' in python", python_use);