18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Just test if we can load the python binding. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <stdio.h> 78c2ecf20Sopenharmony_ci#include <stdlib.h> 88c2ecf20Sopenharmony_ci#include <linux/compiler.h> 98c2ecf20Sopenharmony_ci#include "tests.h" 108c2ecf20Sopenharmony_ci#include "util/debug.h" 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciint test__python_use(struct test *test __maybe_unused, int subtest __maybe_unused) 138c2ecf20Sopenharmony_ci{ 148c2ecf20Sopenharmony_ci char *cmd; 158c2ecf20Sopenharmony_ci int ret; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s", 188c2ecf20Sopenharmony_ci PYTHONPATH, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0) 198c2ecf20Sopenharmony_ci return -1; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci pr_debug("python usage test: \"%s\"\n", cmd); 228c2ecf20Sopenharmony_ci ret = system(cmd) ? -1 : 0; 238c2ecf20Sopenharmony_ci free(cmd); 248c2ecf20Sopenharmony_ci return ret; 258c2ecf20Sopenharmony_ci} 26