test.sh revision 6b197f2a03fa03a2a853cf726d47be2ea4c623b6
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen# ex: ts=8 sw=4 sts=4 et filetype=sh
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen# Uncomment this to debug failures
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen -append "root=/dev/sda1 systemd.log_level=debug raid=noautodetect loglevel=2 init=/usr/lib/systemd/systemd rw console=ttyS0,115200n81 selinux=0 $DEBUGFAIL"
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen # Create the blank file to use as a root filesystem
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen dd if=/dev/null of=$TESTDIR/rootdisk.img bs=1M seek=100
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen [ -b $LOOPDEV ] || return 1
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen sfdisk -C 3200 -H 2 -S 32 -L $LOOPDEV <<EOF
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen # Create what will eventually be our root filesystem onto an overlay
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen echo 'ImportKernel=yes' >> $initdir/etc/systemd/journald.conf
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen echo systemd-testsuite > $initdir/etc/hostname
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen cat >$initdir/etc/systemd/system/testsuite.target <<EOF
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom GundersenDescription=Testsuite target
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom GundersenRequires=multi-user.target
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom GundersenAfter=multi-user.target
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom GundersenConflicts=rescue.target
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom GundersenAllowIsolate=yes
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen cat >$initdir/etc/systemd/system/testsuite.service <<EOF
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom GundersenDescription=Testsuite service
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom GundersenAfter=multi-user.target
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom GundersenExecStart=/bin/sh -c 'systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok'
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom GundersenExecStartPost=/usr/sbin/poweroff
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen ln -fs testsuite.target $initdir/etc/systemd/system/default.target
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen dracut_install sh bash setsid loadkeys setfont \
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen | while read file; do
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen /usr/lib/kbd/consolefonts/latarcyrheb-sun16* \
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen [[ -f $i ]] || continue
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen [ -f ${_terminfodir}/l/linux ] && break
08232a020bd2571088d3ee06dda07732c5e963d1Tom Gundersen egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
08232a020bd2571088d3ee06dda07732c5e963d1Tom Gundersen | while read i; do
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen # install plymouth, if found... else remove plymouth service files
08232a020bd2571088d3ee06dda07732c5e963d1Tom Gundersen if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
08232a020bd2571088d3ee06dda07732c5e963d1Tom Gundersen PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
08232a020bd2571088d3ee06dda07732c5e963d1Tom Gundersen /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
57fa1d094cd2c5ac68970526ad0a0754c548e75dTom Gundersen rm -f $initdir/usr/lib/systemd/system/plymouth* $initdir/usr/lib/systemd/system/*/plymouth*