]> git.proxmox.com Git - mirror_lxcfs.git/blobdiff - tests/test_cgroup
support running tests from travis
[mirror_lxcfs.git] / tests / test_cgroup
index d5ad7a4124d8ee8206b5c18f33c5d5d81c8f31e5..13bfb8f4aaa5c8d61ef2c0175f5f0d308a348a11 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -eu
+#!/bin/sh -eux
 
 PASS=0
 
@@ -6,10 +6,12 @@ cleanup() {
     [ "$PASS" = "1" ] || (echo FAIL && exit 1)
 }
 
+LXCFSDIR=${LXCFSDIR:-/var/lib/lxcfs}
+
 trap cleanup EXIT HUP INT TERM
 
-if ! mountpoint -q /var/lib/lxcfs; then
-    echo "lxcfs isn't mounted on /var/lib/lxcfs"
+if ! mountpoint -q ${LXCFSDIR}; then
+    echo "lxcfs isn't mounted on ${LXCFSDIR}"
     exit 1
 fi
 
@@ -18,7 +20,7 @@ cgm remove freezer lxcfs_test_cgroup/sub >/dev/null 2>&1 || true
 cgm remove all lxcfs_test_cgroup >/dev/null 2>&1 || true
 
 # Check that the fs is readable
-find /var/lib/lxcfs/cgroup/ >/dev/null
+find ${LXCFSDIR}/cgroup/ >/dev/null
 
 # Do some fs checks
 cgm create all lxcfs_test_cgroup
@@ -28,15 +30,15 @@ cgm movepid all lxcfs_test_cgroup $$
 CGPATH=$(cgm getpidcgroupabs freezer $$)
 
 echo $((1024*1024)) > \
-    /var/lib/lxcfs/cgroup/memory/$CGPATH/memory.limit_in_bytes
+    ${LXCFSDIR}/cgroup/memory/$CGPATH/memory.limit_in_bytes
 echo 0 > \
-    /var/lib/lxcfs/cgroup/cpuset/$CGPATH/cpuset.cpus
+    ${LXCFSDIR}/cgroup/cpuset/$CGPATH/cpuset.cpus
 
 [ "$(cgm getvalue memory $CGPATH memory.limit_in_bytes)" = "$((1024*1024))" ]
 [ "$(cgm getvalue cpuset $CGPATH cpuset.cpus)" = "0" ]
 
-mkdir /var/lib/lxcfs/cgroup/freezer/$CGPATH/sub
-echo $$ > /var/lib/lxcfs/cgroup/freezer/$CGPATH/sub/tasks
+mkdir ${LXCFSDIR}/cgroup/freezer/$CGPATH/sub
+echo $$ > ${LXCFSDIR}/cgroup/freezer/$CGPATH/sub/tasks
 
 [ "$(cgm getpidcgroupabs freezer $$)" = "$CGPATH/sub" ]