]> git.proxmox.com Git - mirror_lxcfs.git/blob - tests/main.sh
bindings: better logging for write_string()
[mirror_lxcfs.git] / tests / main.sh
1 #!/bin/bash
2
3 set -ex
4
5 [ $(id -u) -eq 0 ]
6
7 # Run lxcfs testsuite
8 export LXCFSDIR=$(mktemp -d)
9 pidfile=$(mktemp)
10
11 cmdline=$(realpath $0)
12 dirname=$(dirname ${cmdline})
13 topdir=$(dirname ${dirname})
14
15 p=-1
16 FAILED=1
17 cleanup() {
18 set +e
19 if [ $p -ne -1 ]; then
20 kill -9 $p
21 fi
22 if [ ${LXCFSDIR} != "/var/lib/lxcfs" ]; then
23 umount -l ${LXCFSDIR}
24 rmdir ${LXCFSDIR}
25 fi
26 rm -f ${pidfile}
27 if [ ${FAILED} -eq 1 ]; then
28 echo "FAILED at $TESTCASE"
29 exit 1
30 fi
31 echo PASSED
32 exit 0
33 }
34
35 TESTCASE="setup"
36 lxcfs=${topdir}/lxcfs
37
38 if [ -x ${lxcfs} ]; then
39 echo "Running ${lxcfs} ${LXCFSDIR}"
40 ${lxcfs} -p ${pidfile} ${LXCFSDIR} &
41 p=$!
42 else
43 pidof lxcfs
44 echo "Using host lxcfs"
45 rmdir $LXCFSDIR
46 export LXCFSDIR=/var/lib/lxcfs
47 fi
48
49 trap cleanup EXIT SIGHUP SIGINT SIGTERM
50
51 count=1
52 while ! mountpoint -q $LXCFSDIR; do
53 sleep 1s
54 if [ $count -gt 5 ]; then
55 echo "lxcfs failed to start"
56 false
57 fi
58 count=$((count+1))
59 done
60
61 RUNTEST() {
62 unshare -fmp --mount-proc $*
63 }
64
65 TESTCASE="test_proc"
66 RUNTEST ${dirname}/test_proc
67 TESTCASE="test_cgroup"
68 RUNTEST ${dirname}/test_cgroup
69 TESTCASE="test_read_proc.sh"
70 RUNTEST ${dirname}/test_read_proc.sh
71 TESTCASE="cpusetrange"
72 RUNTEST ${dirname}/cpusetrange
73 TESTCASE="meminfo hierarchy"
74 RUNTEST ${dirname}/test_meminfo_hierarchy.sh
75 TESTCASE="liblxcfs reloading"
76 ${dirname}/test_reload.sh
77
78 # Check for any defunct processes - children we didn't reap
79 n=`ps -ef | grep lxcfs | grep defunct | wc -l`
80 [ $n = 0 ]
81
82 FAILED=0