]>
Commit | Line | Data |
---|---|---|
1c511f26 SH |
1 | #!/bin/bash |
2 | ||
3 | set -ex | |
4 | ||
5 | [ $(id -u) -eq 0 ] | |
6 | ||
7 | # Run lxcfs testsuite | |
8 | export LXCFSDIR=$(mktemp -d) | |
e190ee91 | 9 | pidfile=$(mktemp) |
1c511f26 SH |
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 | |
bb682ba8 SH |
22 | if [ ${LXCFSDIR} != "/var/lib/lxcfs" ]; then |
23 | umount -l ${LXCFSDIR} | |
24 | rmdir ${LXCFSDIR} | |
25 | fi | |
e190ee91 | 26 | rm -f ${pidfile} |
1c511f26 SH |
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 | ||
bb682ba8 SH |
38 | if [ -x ${lxcfs} ]; then |
39 | echo "Running ${lxcfs} ${LXCFSDIR}" | |
e190ee91 | 40 | ${lxcfs} -p ${pidfile} ${LXCFSDIR} & |
bb682ba8 SH |
41 | p=$! |
42 | else | |
43 | pidof lxcfs | |
44 | echo "Using host lxcfs" | |
45 | rmdir $LXCFSDIR | |
46 | export LXCFSDIR=/var/lib/lxcfs | |
47 | fi | |
1c511f26 SH |
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 | ||
754c2080 SH |
61 | RUNTEST() { |
62 | unshare -fmp --mount-proc $* | |
63 | } | |
64 | ||
1c511f26 | 65 | TESTCASE="test_proc" |
754c2080 | 66 | RUNTEST ${dirname}/test_proc |
1c511f26 | 67 | TESTCASE="test_cgroup" |
754c2080 | 68 | RUNTEST ${dirname}/test_cgroup |
1c511f26 | 69 | TESTCASE="test_read_proc.sh" |
754c2080 | 70 | RUNTEST ${dirname}/test_read_proc.sh |
1c511f26 | 71 | TESTCASE="cpusetrange" |
754c2080 | 72 | RUNTEST ${dirname}/cpusetrange |
7bc95a75 | 73 | TESTCASE="meminfo hierarchy" |
754c2080 | 74 | RUNTEST ${dirname}/test_meminfo_hierarchy.sh |
237e200e SH |
75 | TESTCASE="liblxcfs reloading" |
76 | ${dirname}/test_reload.sh | |
1c511f26 | 77 | |
a6c00375 SH |
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 | ||
1c511f26 | 82 | FAILED=0 |