test.sh revision 7c1856aacd4f5d41dc320860490afda18c4a7495
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering# ex: ts=8 sw=4 sts=4 et filetype=sh
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering# Uncomment this to debug failures
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering#DEBUGFAIL="systemd.unit=multi-user.target"
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering -net none -kernel /boot/vmlinuz-$KVERSION \
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart 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"
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering cp -a $TESTDIR/root/var/log/journal $TESTDIR
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering test -s $TESTDIR/failed && ret=$(($ret+1))
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering # Create the blank file to use as a root filesystem
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering dd if=/dev/null of=$TESTDIR/rootdisk.img bs=1M seek=100
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
40b71e89bae4e51768db4dc50ec64c1e9c96eec4Sebastian Thorarensen [ -b $LOOPDEV ] || return 1
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering sfdisk -C 3200 -H 2 -S 32 -L $LOOPDEV <<EOF
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering # Create what will eventually be our root filesystem onto an overlay
d18d46ecea80a7f07415edb9264af6a254fd70bbZbigniew Jędrzejewski-Szmek (cd ../..; make DESTDIR=$initdir install)
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering echo 'ImportKernel=yes' >> $initdir/etc/systemd/journald.conf
d18d46ecea80a7f07415edb9264af6a254fd70bbZbigniew Jędrzejewski-Szmek mkdir -p $initdir/var/log/journal
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering echo systemd-testsuite > $initdir/etc/hostname
874bc134ac6504c45e94174e37af13ff21a6bfe2Zbigniew Jędrzejewski-Szmek cat >$initdir/etc/systemd/system/testsuite.target <<EOF
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart PoetteringDescription=Testsuite target
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-SzmekRequires=multi-user.target
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart PoetteringAfter=multi-user.target
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart PoetteringConflicts=rescue.target
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart PoetteringAllowIsolate=yes
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering cat >$initdir/etc/systemd/system/testsuite.service <<EOF
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart PoetteringDescription=Testsuite service
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart PoetteringAfter=multi-user.target
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart PoetteringExecStart=/bin/sh -c 'systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok'
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart PoetteringExecStartPost=/usr/sbin/poweroff
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
874bc134ac6504c45e94174e37af13ff21a6bfe2Zbigniew Jędrzejewski-Szmek # make the testsuite the default target
874bc134ac6504c45e94174e37af13ff21a6bfe2Zbigniew Jędrzejewski-Szmek ln -fs testsuite.target $initdir/etc/systemd/system/default.target
874bc134ac6504c45e94174e37af13ff21a6bfe2Zbigniew Jędrzejewski-Szmek dracut_install sh bash setsid loadkeys setfont \
874bc134ac6504c45e94174e37af13ff21a6bfe2Zbigniew Jędrzejewski-Szmek login sushell sulogin gzip sleep echo
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering | while read file; do
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering inst /usr/lib/systemd/system/dbus.service
92ee6447b1deef7c79962a8121fdf8e58acb3a83Zbigniew Jędrzejewski-Szmek /usr/lib/kbd/consolefonts/latarcyrheb-sun16* \
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek /usr/lib/kbd/keymaps/include/* \
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek /usr/lib/kbd/keymaps/i386/include/* \
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering /usr/lib/kbd/keymaps/i386/qwerty/us.*; do
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering [[ -f $i ]] || continue
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering [ -f ${_terminfodir}/l/linux ] && break
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering dracut_install -o ${_terminfodir}/l/linux
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering ln -fs /proc/self/mounts $initdir/etc/mtab
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering # install any Exec's from the service files
874bc134ac6504c45e94174e37af13ff21a6bfe2Zbigniew Jędrzejewski-Szmek egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
a174f94d529c7ae9be589867308b669ec9b4dcc0Lennart Poettering | while read i; do
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering # install plymouth, if found... else remove plymouth service files
2a0e0692565f0435657c93498e09cbb2d3517152Shawn Landden if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
2a0e0692565f0435657c93498e09cbb2d3517152Shawn Landden rm -f $initdir/usr/lib/systemd/system/plymouth* $initdir/usr/lib/systemd/system/*/plymouth*
0153028ae379eb7c9a463c548ef73ea392c6cdb0Lennart Poettering dracut_install sh df free ls shutdown poweroff \