]> git.proxmox.com Git - mirror_lxcfs.git/blame - tests/test_proc
support running tests from travis
[mirror_lxcfs.git] / tests / test_proc
CommitLineData
1c511f26 1#!/bin/sh -eux
a6c5a845
SG
2
3PASS=0
4
5cleanup() {
794ed8d5 6 [ "$PASS" = "1" ] || (echo FAIL && exit 1)
a6c5a845
SG
7}
8
9trap cleanup EXIT HUP INT TERM
10
1c511f26
SH
11LXCFSDIR=${LXCFSDIR:-/var/lib/lxcfs}
12
13if ! mountpoint -q ${LXCFSDIR}; then
14 echo "lxcfs isn't mounted on ${LXCFSDIR}"
a6c5a845
SG
15 exit 1
16fi
17
18cgm remove all lxcfs_test_proc || true
19cgm create all lxcfs_test_proc
20cgm removeonempty all lxcfs_test_proc
21cgm movepid all lxcfs_test_proc $$
22
23cgm setvalue memory $(cgm getpidcgroupabs memory $$) \
24 memory.limit_in_bytes $((1024*1024))
25cgm setvalue cpuset $(cgm getpidcgroupabs cpuset $$) \
26 cpuset.cpus 0
27
28# Test cpuinfo
1c511f26
SH
29[ "$(grep "^processor" ${LXCFSDIR}/proc/cpuinfo | wc -l)" = "1" ]
30grep -q "^processor.*0$" ${LXCFSDIR}/proc/cpuinfo
a6c5a845
SG
31
32# Test stat
1c511f26 33[ "$(grep "^cpu" ${LXCFSDIR}/proc/stat | wc -l)" = "2" ]
a6c5a845
SG
34
35# Test meminfo
1c511f26 36grep -q "^MemTotal.*1024 kB$" ${LXCFSDIR}/proc/meminfo
a6c5a845
SG
37
38# Test uptime
39if [ -e /proc/self/ns/user ]; then
1c511f26 40 [ "$(lxc-unshare -s 'USER|PID' cat ${LXCFSDIR}/proc/uptime)" = "0.0 0.0" ]
a6c5a845
SG
41fi
42
43PASS=1
44echo PASS