^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Just test if we can load the python binding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "tests.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "util/debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) char *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) PYTHONPATH, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) pr_debug("python usage test: \"%s\"\n", cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) ret = system(cmd) ? -1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) free(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) }