test.sh revision 6b197f2a03fa03a2a853cf726d47be2ea4c623b6
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# ex: ts=8 sw=4 sts=4 et filetype=sh
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering# Uncomment this to debug failures
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering#DEBUGFAIL="systemd.unit=multi-user.target"
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering -net none -kernel /boot/vmlinuz-$KVERSION \
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering -append "root=/dev/sda1 systemd.log_level=debug raid=noautodetect loglevel=2 init=/usr/lib/systemd/systemd rw console=ttyS0,115200n81 selinux=0 $DEBUGFAIL"
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering cp -a $TESTDIR/root/var/log/journal $TESTDIR
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering # Create the blank file to use as a root filesystem
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering dd if=/dev/null of=$TESTDIR/rootdisk.img bs=1M seek=100
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering [ -b $LOOPDEV ] || return 1
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering sfdisk -C 3200 -H 2 -S 32 -L $LOOPDEV <<EOF
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering # Create what will eventually be our root filesystem onto an overlay
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering (cd ../..; make DESTDIR=$initdir install)
46e65dcc3a522b5e992e165b5e61d14254026859Lennart Poettering for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers echo 'ImportKernel=yes' >> $initdir/etc/systemd/journald.conf
599659860c770058f2eb04d578c521c16e0b1853Lennart Poettering echo systemd-testsuite > $initdir/etc/hostname
d95a74ed1191bb09f5be57b0619d3d77708e019dLennart Poettering cat >$initdir/etc/systemd/system/testsuite.target <<EOF
2311eb2ff0c3ff80ec3645b02c97170c9a565454Kay SieversDescription=Testsuite target
d95a74ed1191bb09f5be57b0619d3d77708e019dLennart PoetteringRequires=multi-user.target
d95a74ed1191bb09f5be57b0619d3d77708e019dLennart PoetteringAfter=multi-user.target
d95a74ed1191bb09f5be57b0619d3d77708e019dLennart PoetteringConflicts=rescue.target
d95a74ed1191bb09f5be57b0619d3d77708e019dLennart PoetteringAllowIsolate=yes
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden cat >$initdir/etc/systemd/system/testsuite.service <<EOF
d95a74ed1191bb09f5be57b0619d3d77708e019dLennart PoetteringDescription=Testsuite service
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn LanddenAfter=multi-user.target
d95a74ed1191bb09f5be57b0619d3d77708e019dLennart PoetteringExecStart=/bin/sh -c 'systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok'
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart PoetteringExecStartPost=/usr/sbin/poweroff
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
9ff09bcb86fb125768667aca9bc0b10b1745370aShawn Landden ln -fs testsuite.target $initdir/etc/systemd/system/default.target
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek dracut_install sh bash setsid loadkeys setfont \
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek login sushell sulogin gzip sleep echo
d95a74ed1191bb09f5be57b0619d3d77708e019dLennart Poettering | while read file; do
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek inst /usr/lib/systemd/system/dbus.socket
b90930c73b1c82a3dc4d4f2603799993f042aaffLennart Poettering inst /usr/lib/systemd/system/dbus.service
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering /usr/lib/kbd/keymaps/i386/qwerty/us.*; do
2f6a59070559786428d9eaf199ae3d61772b2225Kay Sievers [[ -f $i ]] || continue
c264aeab4b0e7b69f469e12e78d4a48b3ed7a66eKay Sievers for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
07a062a79374406e8f6b5a1e2f80c80baf031567Jason St. John [ -f ${_terminfodir}/l/linux ] && break
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering dracut_install -o ${_terminfodir}/l/linux
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
9f6eb1cd58f2ddf2eb6ba0e4de056e13d938af75Kay Sievers | while read i; do
ffc06c3513d9a0693c7f810d03b20705127ba55aKay Sievers # install plymouth, if found... else remove plymouth service files
ffc06c3513d9a0693c7f810d03b20705127ba55aKay Sievers if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
6d0274f11547a0f11200bb82bf598a5a253e12cfLennart Poettering PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
a281d9c7851b16c4c9195d042901540ee9ced799Thomas Hindoe Paaboel Andersen /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
ffc06c3513d9a0693c7f810d03b20705127ba55aKay Sievers rm -f $initdir/usr/lib/systemd/system/plymouth* $initdir/usr/lib/systemd/system/*/plymouth*