]> git.proxmox.com Git - mirror_lxcfs.git/blob - tests/test_reload.sh
tests: Silence build output
[mirror_lxcfs.git] / tests / test_reload.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: LGPL-2.1+
3
4 set -eu
5 [ -n "${DEBUG:-}" ] && set -x
6
7 [ $(id -u) -eq 0 ]
8
9 cmdline=$(realpath $0)
10 dirname=$(dirname ${cmdline})
11 topdir=$(dirname ${dirname})
12
13 testdir=`mktemp -t -d libs.XXX`
14 installdir=`mktemp -t -d libs.XXX`
15 pidfile=$(mktemp)
16 libdir=${installdir}/usr/lib/lxcfs
17 bindir=${installdir}/usr/bin
18 lxcfspid=-1
19 FAILED=1
20
21 cleanup() {
22 if [ ${lxcfspid} -ne -1 ]; then
23 kill -9 ${lxcfspid}
24 count=1
25 while [ -d ${testdir}/proc -a $count -lt 5 ]; do
26 sleep 1
27 done
28 umount -l ${testdir}
29 fi
30 rm -rf ${testdir} ${installdir}
31 rm -f /tmp/lxcfs-iwashere
32 rm -f ${pidfile}
33 if [ ${FAILED} -eq 1 ]; then
34 echo "liblxcfs.so reload test FAILED"
35 else
36 echo "liblxcfs.so reload test PASSED"
37 fi
38 }
39
40 trap cleanup EXIT HUP INT TERM
41
42 echo "==> Installing lxcfs to temporary path"
43 ( cd ${topdir}; DESTDIR=${installdir} make -s install >/dev/null 2>&1)
44 if [ -n "${LD_LIBRARY_PATH:-}" ]; then
45 export LD_LIBRARY_PATH="${libdir}:${LD_LIBRARY_PATH}"
46 else
47 export LD_LIBRARY_PATH=${libdir}
48 fi
49
50 echo "==> Spawning lxcfs"
51 ${bindir}/lxcfs -p ${pidfile} ${testdir} &
52
53 lxcfspid=$!
54
55 count=1
56 while [ ! -d ${testdir}/proc ]; do
57 [ $count -lt 5 ]
58 sleep 1
59 count=$((count+1))
60 done
61
62 rm -f /tmp/lxcfs-iwashere
63
64 echo "==> Testing that lxcfs is functional"
65 cat ${testdir}/proc/uptime
66
67 [ ! -f /tmp/lxcfs-iwashere ]
68 (
69 cd ${topdir}/src;
70 make -s liblxcfstest.la
71 gcc -shared -fPIC -DPIC -Wl,-soname,liblxcfs.so .libs/liblxcfstest_la-*.o cgroups/.libs/liblxcfstest_la-*.o -lpthread -pthread -o .libs/liblxcfstest.so
72 cp .libs/liblxcfstest.* "${libdir}"
73 ) > /dev/null
74 rm -f ${libdir}/liblxcfs.so* ${libdir}/liblxcfs.la
75 cp ${libdir}/liblxcfstest.so ${libdir}/liblxcfs.so
76
77 kill -USR1 ${lxcfspid}
78 sleep 1
79 cat ${testdir}/proc/uptime
80 sleep 1
81 [ -f /tmp/lxcfs-iwashere ]
82
83 FAILED=0