summaryrefslogtreecommitdiffstats
path: root/tests/pathtest.c
blob: 076c38ae0fbdb73f50d29aa165f358c2dee6c636 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <libcgroup.h>

int main(int argc, char *argv[])
{
	char *path;
	char *expected_path, *controller;
	int ret;

	if (argc < 2) {
		fprintf(stderr, "Usage %s: <controller name> <path>\n",
			argv[0]);
		exit(EXIT_FAILURE);
	}

	controller = argv[1];
	expected_path = argv[2];

	cgroup_init();

	ret = cgroup_get_current_controller_path(getpid(), controller, &path);
	if (ret)
		printf("Test FAIL, get path failed for controller %s\n",
			controller);
	else {
		if (strcmp(path, expected_path))
			printf("Test FAIL, expected_path %s, got path %s\n",
				expected_path, path);
		else
			printf("Test PASS, controller %s path %s\n",
				controller, path);
		free(path);
	}

	return EXIT_SUCCESS;
}