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