test.sh revision 71dc3ed1d95dfe246004018c2ca85156fc73c146
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
TEST_DESCRIPTION="Basic systemd setup"
KERNEL_VER=$(uname -r)
# Uncomment this to debug failures
#DEBUGFAIL="systemd.unit=multi-user.target"
DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort"
# TODO: qemu wrapper script: http://www.spinics.net/lists/kvm/msg72389.html
-m 512M -nographic \
-append "root=/dev/sda1 systemd.log_level=debug raid=noautodetect loglevel=2 init=/usr/lib/systemd/systemd ro console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" || return 1
ret=1
return $ret
}
systemd-nspawn -b -D $TESTDIR/nspawn-root --capability=CAP_AUDIT_CONTROL,CAP_AUDIT_WRITE /usr/lib/systemd/systemd
ret=1
[[ -e $TESTDIR/nspawn-root/testok ]] && ret=0
return $ret
}
if check_qemu ; then
run_qemu || return 1
else
dwarn "can't run qemu-kvm, skipping"
fi
if check_nspawn; then
run_nspawn || return 1
else
dwarn "can't run systemd-nspawn, skipping"
fi
return 0
}
# Create the blank file to use as a root filesystem
LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
[ -b $LOOPDEV ] || return 1
,3200
,
EOF
# Create what will eventually be our root filesystem onto an overlay
(
# create the basic filesystem layout
# install compiled files
# remove unneeded documentation
# install possible missing libraries
inst_libs $i
done
# make a journal directory
# install some basic config files
# we want an empty environment
# set the hostname
LABEL=systemd / ext3 rw 0 1
EOF
# setup the testsuite target
[Unit]
Description=Testsuite target
Requires=multi-user.target
After=multi-user.target
Conflicts=rescue.target
AllowIsolate=yes
EOF
# setup the testsuite service
[Unit]
Description=Testsuite service
After=multi-user.target
[Service]
ExecStart=/bin/bash -c 'set -x; systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok; while : ;do echo "testsuite service waiting for journal to move to /var/log/journal" > /dev/console ; for i in /var/log/journal/*;do [ -d "\$i" ] && echo "\$i" && break 2; done; sleep 1; done; sleep 1; exit 0;'
ExecStopPost=/usr/bin/systemctl poweroff
Type=oneshot
EOF
# make the testsuite the default target
#!/bin/bash
exit 0
EOF
# install basic tools needed
# install libnss_files for login
inst_libdir_file "libnss_files*"
# install dbus and pam
find \
| while read file; do
done
# install dbus socket and service file
# install basic keyboard maps and fonts
for i in \
[[ -f $i ]] || continue
inst $i
done
# some basic terminfo files
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
# softlink mtab
# install any Exec's from the service files
| while read i; do
i=${i##Exec*=}; i=${i##-}
inst $i
done
# install plymouth, if found... else remove plymouth service files
# if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
# PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
# /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
# dracut_install plymouth plymouthd
# else
rm -f $initdir/{usr/lib,etc}/systemd/system/plymouth* $initdir/{usr/lib,etc}/systemd/system/*/plymouth*
# fi
# some helper tools for debugging
[[ $DEBUGTOOLS ]] && dracut_install $DEBUGTOOLS
# install ld.so.conf* and run ldconfig
cp -a /etc/ld.so.conf* $initdir/etc
ddebug "Strip binaeries"
# copy depmod files
# generate module dependencies
if [[ -d $initdir/lib/modules/$KERNEL_VER ]] && \
dfatal "\"depmod -a $KERNEL_VER\" failed."
exit 1
fi
)
# we don't mount in the nspawn root
}
return 0
}
. $TEST_BASE_DIR/test-functions
do_test "$@"