]> git.proxmox.com Git - mirror_lxcfs.git/blob - tests/test_cgroup
support running tests from travis
[mirror_lxcfs.git] / tests / test_cgroup
1 #!/bin/sh -eux
2
3 PASS=0
4
5 cleanup() {
6 [ "$PASS" = "1" ] || (echo FAIL && exit 1)
7 }
8
9 LXCFSDIR=${LXCFSDIR:-/var/lib/lxcfs}
10
11 trap cleanup EXIT HUP INT TERM
12
13 if ! mountpoint -q ${LXCFSDIR}; then
14 echo "lxcfs isn't mounted on ${LXCFSDIR}"
15 exit 1
16 fi
17
18 # Initial cleanup
19 cgm remove freezer lxcfs_test_cgroup/sub >/dev/null 2>&1 || true
20 cgm remove all lxcfs_test_cgroup >/dev/null 2>&1 || true
21
22 # Check that the fs is readable
23 find ${LXCFSDIR}/cgroup/ >/dev/null
24
25 # Do some fs checks
26 cgm create all lxcfs_test_cgroup
27 cgm removeonempty all lxcfs_test_cgroup
28 cgm movepid all lxcfs_test_cgroup $$
29
30 CGPATH=$(cgm getpidcgroupabs freezer $$)
31
32 echo $((1024*1024)) > \
33 ${LXCFSDIR}/cgroup/memory/$CGPATH/memory.limit_in_bytes
34 echo 0 > \
35 ${LXCFSDIR}/cgroup/cpuset/$CGPATH/cpuset.cpus
36
37 [ "$(cgm getvalue memory $CGPATH memory.limit_in_bytes)" = "$((1024*1024))" ]
38 [ "$(cgm getvalue cpuset $CGPATH cpuset.cpus)" = "0" ]
39
40 mkdir ${LXCFSDIR}/cgroup/freezer/$CGPATH/sub
41 echo $$ > ${LXCFSDIR}/cgroup/freezer/$CGPATH/sub/tasks
42
43 [ "$(cgm getpidcgroupabs freezer $$)" = "$CGPATH/sub" ]
44
45 PASS=1
46 echo PASS