]> git.proxmox.com Git - mirror_lxcfs.git/blob - tests/test_meminfo_hierarchy.sh
enable debug option
[mirror_lxcfs.git] / tests / test_meminfo_hierarchy.sh
1 #!/bin/bash
2
3 set -eux
4
5 LXCFSDIR=${LXCFSDIR:-/var/lib/lxcfs}
6
7 cg1=$(uuidgen).$$
8 cg2=$(uuidgen).$$
9
10 cleanup() {
11 if [ $FAILED -eq 1 ]; then
12 echo "Failed"
13 exit 1
14 fi
15 echo "Passed"
16 exit 0
17 }
18
19 FAILED=1
20 trap cleanup EXIT HUP INT TERM
21
22 [ ! -d /sys/fs/cgroup/memory ] && exit 0
23 initmemory=`awk -F: '/memory/ { print $3 }' /proc/1/cgroup`
24 mempath=/sys/fs/cgroup/memory/${initmemory}
25 rmdir ${mempath}/${cg1} || true
26 rmdir ${mempath}/${cg2} || true
27 mkdir ${mempath}/${cg1}
28
29 echo 500000000 > ${mempath}/${cg1}/memory.limit_in_bytes
30 echo 1 > ${mempath}/${cg1}/tasks
31
32 m1=`awk '/^MemTotal:/ { print $2 }' ${LXCFSDIR}/proc/meminfo`
33 mkdir ${mempath}/${cg1}/${cg2}
34 echo 1 > ${mempath}/${cg1}/${cg2}/tasks
35 m2=`awk '/^MemTotal:/ { print $2 }' ${LXCFSDIR}/proc/meminfo`
36 [ $m1 -eq $m2 ]
37
38 FAILED=0