]> git.proxmox.com Git - mirror_lxcfs.git/blob - tests/test_proc
tests: Fix run on ppc64el
[mirror_lxcfs.git] / tests / test_proc
1 #!/bin/sh -eux
2
3 PASS=0
4
5 cleanup() {
6 [ "$PASS" = "1" ] || (echo FAIL && exit 1)
7 }
8
9 trap cleanup EXIT HUP INT TERM
10
11 LXCFSDIR=${LXCFSDIR:-/var/lib/lxcfs}
12
13 if ! mountpoint -q ${LXCFSDIR}; then
14 echo "lxcfs isn't mounted on ${LXCFSDIR}"
15 exit 1
16 fi
17
18 [ ! -d /sys/fs/cgroup/memory ] && exit 0
19 [ ! -d /sys/fs/cgroup/cpuset ] && exit 0
20
21 initcpuset=`awk -F: '/cpuset/ { print $3 }' /proc/1/cgroup`
22 initmemory=`awk -F: '/memory/ { print $3 }' /proc/1/cgroup`
23
24 cpupath=/sys/fs/cgroup/cpuset/${initcpuset}
25 mempath=/sys/fs/cgroup/memory/${initmemory}
26
27 rmdir ${cpupath}/lxcfs_test_proc || true
28 rmdir ${mempath}/lxcfs_test_proc || true
29 mkdir ${cpupath}/lxcfs_test_proc
30 mkdir ${mempath}/lxcfs_test_proc
31
32 echo 1 > ${cpupath}/lxcfs_test_proc/tasks
33 echo 1 > ${mempath}/lxcfs_test_proc/tasks
34
35 echo $((64*1024*1024)) > ${mempath}/lxcfs_test_proc/memory.limit_in_bytes
36 echo 0 > ${cpupath}/lxcfs_test_proc/cpuset.cpus
37
38 # Test uptime
39 [ "$(cat ${LXCFSDIR}/proc/uptime)" = "0.0 0.0" ]
40
41 # Test cpuinfo
42 [ "$(grep "^processor" ${LXCFSDIR}/proc/cpuinfo | wc -l)" = "1" ]
43 grep -q "^processor.*0$" ${LXCFSDIR}/proc/cpuinfo
44
45 # Test stat
46 [ "$(grep "^cpu" ${LXCFSDIR}/proc/stat | wc -l)" = "2" ]
47
48 # Test meminfo
49 grep -q "^MemTotal.*65536 kB$" ${LXCFSDIR}/proc/meminfo
50
51 PASS=1
52 echo PASS