1e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng/*
2e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng * Just test if we can load the python binding.
3e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng */
4e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng
5e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng#include <stdio.h>
6e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng#include <stdlib.h>
7e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng#include "tests.h"
8e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng
9e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengextern int verbose;
10e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng
11e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Chengint test__python_use(void)
12e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng{
13e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng	char *cmd;
14e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng	int ret;
15e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng
16e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng	if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s",
17e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng		     PYTHONPATH, PYTHON, verbose ? "" : "2> /dev/null") < 0)
18e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng		return -1;
19e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng
20e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng	ret = system(cmd) ? -1 : 0;
21e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng	free(cmd);
22e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng	return ret;
23e6e8a0bd7cffcc9ae2e0e75546fb12a19213d4aeBen Cheng}
24