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