1
0
mirror of https://github.com/lxc/lxcfs.git synced 2026-02-05 09:46:18 +01:00
Files
lxcfs/tests/test_reload.sh.in
Christian Brauner e5af758b36 build: use jinja2 templating
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-05 13:49:40 +01:00

78 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1+
set -eu
[ -n "${DEBUG:-}" ] && set -x
[ $(id -u) -eq 0 ]
cmdline=$(realpath $0)
topdir={{LXCFS_BUILD_ROOT}}
testdir=`mktemp -t -d libs.XXX`
installdir=`mktemp -t -d libs.XXX`
pidfile=$(mktemp)
libdir=${installdir}/{{LIBDIR}}
bindir=${installdir}/usr/bin
lxcfspid=-1
FAILED=1
cleanup() {
if [ ${lxcfspid} -ne -1 ]; then
kill -9 ${lxcfspid}
count=1
while [ -d ${testdir}/proc -a $count -lt 5 ]; do
sleep 1
done
umount -l ${testdir}
fi
rm -rf ${testdir} ${installdir}
rm -f /tmp/lxcfs-iwashere
rm -f ${pidfile}
if [ ${FAILED} -eq 1 ]; then
echo "liblxcfs.so reload test FAILED"
else
echo "liblxcfs.so reload test PASSED"
fi
}
trap cleanup EXIT HUP INT TERM
echo "==> Installing lxcfs to temporary path"
cd {{LXCFS_BUILD_ROOT}}
DESTDIR=${installdir} meson install
if [ -n "${LD_LIBRARY_PATH:-}" ]; then
export LD_LIBRARY_PATH="${libdir}:${LD_LIBRARY_PATH}"
else
export LD_LIBRARY_PATH=${libdir}
fi
echo "==> Spawning lxcfs"
${bindir}/lxcfs -p ${pidfile} ${testdir} &
lxcfspid=$!
count=1
while [ ! -d ${testdir}/proc ]; do
[ $count -lt 5 ]
sleep 1
count=$((count+1))
done
rm -f /tmp/lxcfs-iwashere
echo "==> Testing that lxcfs is functional"
cat ${testdir}/proc/uptime
[ ! -f /tmp/lxcfs-iwashere ]
rm -f ${libdir}/liblxcfs.so* ${libdir}/liblxcfs.la
cp {{LXCFS_BUILD_ROOT}}/liblxcfstest.so ${libdir}/liblxcfs.so
kill -USR1 ${lxcfspid}
sleep 1
cat ${testdir}/proc/uptime
sleep 1
[ -f /tmp/lxcfs-iwashere ]
FAILED=0