]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
test: Introduce a basic proc tree test
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 9 Jan 2015 21:29:22 +0000 (16:29 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 9 Jan 2015 21:49:33 +0000 (16:49 -0500)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
tests/test_proc [new file with mode: 0755]

diff --git a/tests/test_proc b/tests/test_proc
new file mode 100755 (executable)
index 0000000..0b114d1
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh -eu
+
+PASS=0
+
+cleanup() {
+    [ "$PASS" = "1" ] || echo FAIL
+    exit 1
+}
+
+trap cleanup EXIT HUP INT TERM
+
+if ! mountpoint -q /var/lib/lxcfs; then
+    echo "lxcfs isn't mounted on /var/lib/lxcfs"
+    exit 1
+fi
+
+cgm remove all lxcfs_test_proc || true
+cgm create all lxcfs_test_proc
+cgm removeonempty all lxcfs_test_proc
+cgm movepid all lxcfs_test_proc $$
+
+cgm setvalue memory $(cgm getpidcgroupabs memory $$) \
+    memory.limit_in_bytes $((1024*1024))
+cgm setvalue cpuset $(cgm getpidcgroupabs cpuset $$) \
+    cpuset.cpus 0
+
+# Test cpuinfo
+[ "$(grep "^processor" /var/lib/lxcfs/proc/cpuinfo | wc -l)" = "1" ]
+grep -q "^processor.*0$" /var/lib/lxcfs/proc/cpuinfo
+
+# Test stat
+[ "$(grep "^cpu" /var/lib/lxcfs/proc/stat | wc -l)" = "1" ]
+
+# Test meminfo
+grep -q "^MemTotal.*1024 kB$" /var/lib/lxcfs/proc/meminfo
+
+# Test uptime
+if [ -e /proc/self/ns/user ]; then
+    [ "$(lxc-unshare -s 'USER|PID' cat /var/lib/lxcfs/proc/uptime)" = "0 0" ]
+fi
+
+PASS=1
+echo PASS