test-functions revision c7eda0133b6bf13a182337cbe8a61bf2faf9b32e
5a4b3207b395b426c5a9066f4afea8d3fa8c6660stoddard# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
780a4529501556bf31f57e98b6a8ba389fcf735estoddard# ex: ts=8 sw=4 sts=4 et filetype=sh
780a4529501556bf31f57e98b6a8ba389fcf735estoddardif ! ROOTLIBDIR=$(pkg-config --variable=systemdutildir systemd); then
780a4529501556bf31f57e98b6a8ba389fcf735estoddard echo "WARNING! Cannot determine rootlibdir from pkg-config, assuming /usr/lib/systemd" >&2
780a4529501556bf31f57e98b6a8ba389fcf735estoddardBASICTOOLS="sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe"
780a4529501556bf31f57e98b6a8ba389fcf735estoddardDEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname"
780a4529501556bf31f57e98b6a8ba389fcf735estoddard [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a kvm qemu-kvm 2>/dev/null | grep '^/' -m1)
780a4529501556bf31f57e98b6a8ba389fcf735estoddard # QEMU's own build system calls it qemu-system-x86_64
780a4529501556bf31f57e98b6a8ba389fcf735estoddard [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu-system-x86_64 2>/dev/null | grep '^/' -m1)
780a4529501556bf31f57e98b6a8ba389fcf735estoddard [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu-system-i386 2>/dev/null | grep '^/' -m1)
780a4529501556bf31f57e98b6a8ba389fcf735estoddard [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu 2>/dev/null | grep '^/' -m1)
db848a70422b56cf0f15a47c37e17ebe05e2ce04stoddard if [ -f /etc/machine-id ]; then
780a4529501556bf31f57e98b6a8ba389fcf735estoddard [ -z "$INITRD" ] && [ -e "/boot/$MACHINE_ID/$KERNEL_VER/initrd" ] \
780a4529501556bf31f57e98b6a8ba389fcf735estoddard [ -z "$KERNEL_BIN" ] && [ -e "/boot/$MACHINE_ID/$KERNEL_VER/linux" ] \
780a4529501556bf31f57e98b6a8ba389fcf735estoddard && KERNEL_BIN="/boot/$MACHINE_ID/$KERNEL_VER/linux"
780a4529501556bf31f57e98b6a8ba389fcf735estoddard [ "$KERNEL_BIN" ] || KERNEL_BIN=/boot/vmlinuz-$KERNEL_VER
1f2f357528d122de2c7886a073b4eee8766d5c95wrowe [ "$INITRD" ] || INITRD=/boot/initramfs-${KERNEL_VER}.img
780a4529501556bf31f57e98b6a8ba389fcf735estoddardraid=noautodetect \
780a4529501556bf31f57e98b6a8ba389fcf735estoddardloglevel=2 \
780a4529501556bf31f57e98b6a8ba389fcf735estoddardinit=$ROOTLIBDIR/systemd \
780a4529501556bf31f57e98b6a8ba389fcf735estoddardconsole=ttyS0 \
780a4529501556bf31f57e98b6a8ba389fcf735estoddard-nographic \
780a4529501556bf31f57e98b6a8ba389fcf735estoddard $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND" $TESTDIR/rootdisk.img ) || return 1
780a4529501556bf31f57e98b6a8ba389fcf735estoddard ../../systemd-nspawn --boot --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND
type -P dmeventd >/dev/null && dracut_install dmeventd
inst_libs $i
ret=1
[[ -e $TESTDIR/nspawn-root/testok ]] && ret=0
[[ -f $TESTDIR/nspawn-root/failed ]] && cp -a $TESTDIR/nspawn-root/failed $TESTDIR
return $ret
find "$initdir" -executable -not -path '*/lib/modules/*.ko' -type f | xargs strip --strip-unneeded | ddebug
export PKG_CONFIG_PATH=$TEST_BASE_DIR/../src/core/
inst $i
if [[ -d $initdir/lib/modules/$KERNEL_VER ]] && \
rm -f $initdir/{usr/lib,etc}/systemd/system/plymouth* $initdir/{usr/lib,etc}/systemd/system/*/plymouth*
cp -a /etc/ld.so.conf* $initdir/etc
[[ $BASICTOOLS ]] && dracut_install $BASICTOOLS
[[ $DEBUGTOOLS ]] && dracut_install $DEBUGTOOLS
NSS_LIBS=$(LD_DEBUG=files getent passwd 2>&1 >/dev/null |sed -n '/calling init: .*libnss_/ {s!^.* /!/!; p}')
find \
| while read file; do
find \
| while read file; do
for i in \
inst $i
for i in \
/usr/lib/kbd/consolefonts/eurlatgr* \
/usr/lib/kbd/consolefonts/latarcyrheb-sun16*; do
inst $i
[ -f ${_terminfodir}/l/linux ] && break
dracut_install -o ${_terminfodir}/l/linux
ln -fs $TEST_BASE_DIR/testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
for d in usr/bin usr/sbin bin etc lib "$libdir" sbin tmp usr var var/log dev proc sys sysroot root run run/lock run/initramfs; do
local _bin=$1
if [[ $_line =~ $_so_regex ]]; then
_file=${BASH_REMATCH[1]}
[[ -e $STATEFILE ]] && . $STATEFILE
export TESTDIR
export initdir
[ $1 -le $LOG_LEVEL ] || return 0
if [ $# -ge 1 ]; then
while read line; do
while [[ ${__absolute[__level]} == ${__current[__level]} ]]
if [[ -n $__newpath ]]
if [[ -L $_file ]]; then
# rev_lib_symlinks libfoo.so.8.1
if [[ -L $_src ]]; then
[[ -L $_bin ]] && inst_symlink $_bin $_target && return 0
if [[ $_line =~ $_so_regex ]]; then
_file=${BASH_REMATCH[1]}
local _bin
local _line _shebang_regex
[[ $_line =~ $_shebang_regex ]] || return 1
if [[ -d $_realsrc ]]; then
if [[ -f $r/$_rule ]]; then
if [[ -f ${r}$_rule ]]; then
local _x
case $# in
[[ $initdir = $2 ]] && set $1;;
for _x in inst_symlink inst_script inst_binary inst_simple; do
local to f
if [[ $_optional = yes ]]; then
if [[ $omit_drivers ]]; then
_found=1
local _modname _filtercmd
if ! [[ $hostonly ]]; then
if ! [[ $hostonly ]]; then
[[ $no_kernel = yes ]] && return
local _fderr=9
| instmods
| instmods
local _moddirname=${KERNEL_MODS%%/lib/modules/*}
--set-version $KERNEL_VER ${_moddirname} $_mpargs
return $_ret
while read _mod; do
set -o pipefail
| while read line; do [[ "$line" =~ $_filter_not_found ]] && echo $line || echo $line >&2 ;done | derror
_ret=$?
set +o pipefail
return $_ret
local _pattern=$1
case $1 in
--run)
ret=$?
exit $ret;;
--setup)
--clean)
--all)
ret=$?
exit $ret
ret=$?
exit $ret;;