]> git.proxmox.com Git - mirror_lxcfs.git/blame - tests/test_reload.sh
tests: Fix lxcfs path
[mirror_lxcfs.git] / tests / test_reload.sh
CommitLineData
237e200e 1#!/bin/bash
db0463bf 2# SPDX-License-Identifier: LGPL-2.1+
237e200e
SH
3
4set -ex
5
6[ $(id -u) -eq 0 ]
7
8cmdline=$(realpath $0)
9dirname=$(dirname ${cmdline})
10topdir=$(dirname ${dirname})
11
12testdir=`mktemp -t -d libs.XXX`
13installdir=`mktemp -t -d libs.XXX`
e190ee91 14pidfile=$(mktemp)
237e200e
SH
15libdir=${installdir}/usr/lib
16bindir=${installdir}/usr/bin
17lxcfspid=-1
18FAILED=1
19
20cleanup() {
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
39trap cleanup EXIT SIGHUP SIGINT SIGTERM
40
41( cd ${topdir}; DESTDIR=${installdir} make install )
42export LD_LIBRARY_PATH=${libdir}
43
e190ee91 44${bindir}/lxcfs -p ${pidfile} ${testdir} &
4e62479e 45
237e200e
SH
46lxcfspid=$!
47count=1
48while [ ! -d ${testdir}/proc ]; do
49 [ $count -lt 5 ]
50 sleep 1
689e96b7 51 count=$((count+1))
237e200e
SH
52done
53
ec2b5e7c 54rm -f /tmp/lxcfs-iwashere
237e200e 55cat ${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 63rm -f ${libdir}/liblxcfs.so* ${libdir}/liblxcfs.la
4e62479e 64cp ${libdir}/liblxcfstest.so ${libdir}/liblxcfs.so
237e200e
SH
65
66kill -USR1 ${lxcfspid}
67
68cat ${testdir}/proc/uptime
ec2b5e7c 69[ -f /tmp/lxcfs-iwashere ]
237e200e 70FAILED=0