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