~ubuntu-branches/ubuntu/maverick/libcgroup/maverick-proposed

« back to all changes in this revision

Viewing changes to tests/get_mount_point.c

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2009-08-26 11:29:17 UTC
  • Revision ID: james.westby@ubuntu.com-20090826112917-402ews2uj6v350d2
Tags: upstream-0.34
ImportĀ upstreamĀ versionĀ 0.34

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <libcgroup.h>
 
2
#include <stdio.h>
 
3
#include <stdlib.h>
 
4
#include <string.h>
 
5
#include <unistd.h>
 
6
 
 
7
int main()
 
8
{
 
9
        int ret;
 
10
        char *mount_point;
 
11
        char string[100];
 
12
 
 
13
        strcpy(string, "cpu");
 
14
 
 
15
        ret = cgroup_init();
 
16
        if (ret) {
 
17
                printf("cgroup_init failed with %s\n", cgroup_strerror(ret));
 
18
                exit(3);
 
19
        }
 
20
 
 
21
        ret = cgroup_get_subsys_mount_point(string, &mount_point);
 
22
        if (ret) {
 
23
                printf("get_mount_point failed with %s\n",
 
24
                                        cgroup_strerror(ret));
 
25
                exit(3);
 
26
        }
 
27
 
 
28
        printf("The mount point is %s\n", mount_point);
 
29
        free(mount_point);
 
30
 
 
31
        strcpy(string, "obviouslynonexistsubsys");
 
32
 
 
33
        ret = cgroup_get_subsys_mount_point(string, &mount_point);
 
34
 
 
35
        if (!ret) {
 
36
                printf("get_mount_point failed as it got a "
 
37
                                        "non existant subsys\n");
 
38
                exit(3);
 
39
        }
 
40
 
 
41
        if (ret == ECGROUPNOTEXIST) {
 
42
                printf("get_mount_point worked as expected\n");
 
43
                return 0;
 
44
        }
 
45
 
 
46
        printf("get_mount_point failed with %s\n", cgroup_strerror(ret));
 
47
 
 
48
        return 3;
 
49
}