python-use.c 583 B

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