]> git.proxmox.com Git - mirror_lxcfs.git/blob - tests/test_reload.sh
enable debug option
[mirror_lxcfs.git] / tests / test_reload.sh
1 #!/bin/bash
2
3 set -ex
4
5 [ $(id -u) -eq 0 ]
6
7 cmdline=$(realpath $0)
8 dirname=$(dirname ${cmdline})
9 topdir=$(dirname ${dirname})
10
11 testdir=`mktemp -t -d libs.XXX`
12 installdir=`mktemp -t -d libs.XXX`
13 pidfile=$(mktemp)
14 libdir=${installdir}/usr/lib
15 bindir=${installdir}/usr/bin
16 lxcfspid=-1
17 FAILED=1
18
19 cleanup() {
20 if [ ${lxcfspid} -ne -1 ]; then
21 kill -9 ${lxcfspid}
22 count=1
23 while [ -d ${testdir}/proc -a $count -lt 5 ]; do
24 sleep 1
25 done
26 umount -l ${testdir}
27 fi
28 rm -rf ${testdir} ${installdir}
29 rm -f /tmp/lxcfs-iwashere
30 rm -f ${pidfile}
31 if [ ${FAILED} -eq 1 ]; then
32 echo "liblxcfs.so reload test FAILED"
33 else
34 echo "liblxcfs.so reload test PASSED"
35 fi
36 }
37
38 trap cleanup EXIT SIGHUP SIGINT SIGTERM
39
40 ( cd ${topdir}; DESTDIR=${installdir} make install )
41 export LD_LIBRARY_PATH=${libdir}
42
43 ${bindir}/lxcfs -p ${pidfile} ${testdir} &
44
45 lxcfspid=$!
46 count=1
47 while [ ! -d ${testdir}/proc ]; do
48 [ $count -lt 5 ]
49 sleep 1
50 count=$((count+1))
51 done
52
53 rm -f /tmp/lxcfs-iwashere
54 cat ${testdir}/proc/uptime
55 [ ! -f /tmp/lxcfs-iwashere ]
56 (
57 cd ${topdir};
58 make liblxcfstest.la
59 gcc -shared -fPIC -DPIC .libs/liblxcfstest_la-bindings.o .libs/liblxcfstest_la-cpuset.o -lpthread -pthread -o .libs/liblxcfstest.so
60 cp .libs/liblxcfstest.* "${libdir}"
61 )
62 rm -f ${libdir}/liblxcfs.so* ${libdir}/liblxcfs.la
63 cp ${libdir}/liblxcfstest.so ${libdir}/liblxcfs.so
64
65 kill -USR1 ${lxcfspid}
66
67 cat ${testdir}/proc/uptime
68 [ -f /tmp/lxcfs-iwashere ]
69 FAILED=0