test.sh revision bd2b15138e1e1da8bc21072cf585179985c902e1
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering# ex: ts=8 sw=4 sts=4 et filetype=sh
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering# Uncomment this to debug failures
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering#DEBUGFAIL="systemd.unit=multi-user.target"
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering -net none -kernel /boot/vmlinuz-$KVERSION \
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart 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"
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering cp -a $TESTDIR/root/var/log/journal $TESTDIR
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering test -s $TESTDIR/failed && ret=$(($ret+1))
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering systemd-nspawn -b -D $TESTDIR/nspawn-root /usr/lib/systemd/systemd
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering [[ -e $TESTDIR/nspawn-root/testok ]] && ret=0
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart Poettering cp -a $TESTDIR/nspawn-root/var/log/journal $TESTDIR
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering cp -a $TESTDIR/nspawn-root/failed $TESTDIR
31885cd5e38ec9807a6a7ab32660cf8c2fcf48f7Zbigniew Jędrzejewski-Szmek ls -l $TESTDIR/journal/*/*.journal
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering if [[ -d /sys/fs/cgroup/systemd ]]; then
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering # Create the blank file to use as a root filesystem
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering dd if=/dev/null of=$TESTDIR/rootdisk.img bs=1M seek=100
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
5841bd803f1b651c0d70c6ae114630723a76d1daZbigniew Jędrzejewski-Szmek [ -b $LOOPDEV ] || return 1
5841bd803f1b651c0d70c6ae114630723a76d1daZbigniew Jędrzejewski-Szmek echo "LOOPDEV=$LOOPDEV" >> $STATEFILE
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering sfdisk -C 3200 -H 2 -S 32 -L $LOOPDEV <<EOF
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering # Create what will eventually be our root filesystem onto an overlay
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart Poettering (cd ../..; make DESTDIR=$initdir install)
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering echo 'ImportKernel=yes' >> $initdir/etc/systemd/journald.conf
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart Poettering echo systemd-testsuite > $initdir/etc/hostname
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering cat >$initdir/etc/systemd/system/testsuite.target <<EOF
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart PoetteringDescription=Testsuite target
fea72cc0336f4d90875cdddc1aa9739dcbb174f5Lennart PoetteringRequires=multi-user.target
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart PoetteringAfter=multi-user.target
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart PoetteringConflicts=rescue.target
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart PoetteringAllowIsolate=yes
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart Poettering cat >$initdir/etc/systemd/system/testsuite.service <<EOF
fea72cc0336f4d90875cdddc1aa9739dcbb174f5Lennart PoetteringDescription=Testsuite service
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart PoetteringAfter=multi-user.target
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart PoetteringExecStart=/bin/sh -c 'systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok'
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart PoetteringExecStartPost=/usr/sbin/poweroff
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart Poettering mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
aaf7eb81be912e7bed939f31e3bc4c631b2552b3Lennart Poettering ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering ln -fs testsuite.target $initdir/etc/systemd/system/default.target
56f64d95763a799ba4475daf44d8e9f72a1bd474Michal Schmidt dracut_install sh bash setsid loadkeys setfont \
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering | while read file; do
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering inst /usr/lib/systemd/system/dbus.service
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering /usr/lib/kbd/consolefonts/latarcyrheb-sun16* \
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering /usr/lib/kbd/keymaps/i386/qwerty/us.*; do
bd3fa1d2434aa28564251ac4da34d01537de8c4bLennart Poettering [[ -f $i ]] || continue
df758e98754016119a9c8d49213a636a80ffab22Kay Sievers for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
3e09eb5c83e56bc0184bd9d9c44f76047464f77cAndreas Henriksson [ -f ${_terminfodir}/l/linux ] && break
60053efbbaabf084e1ecd61474fdc7235fe3da64Thomas Hindoe Paaboel Andersen # install any Exec's from the service files
fea72cc0336f4d90875cdddc1aa9739dcbb174f5Lennart Poettering egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
60053efbbaabf084e1ecd61474fdc7235fe3da64Thomas Hindoe Paaboel Andersen | while read i; do
0bee65f0622c4faa8ac8ae771cc0c8a936dfa284Lennart Poettering # install plymouth, if found... else remove plymouth service files
0bee65f0622c4faa8ac8ae771cc0c8a936dfa284Lennart Poettering if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
0bee65f0622c4faa8ac8ae771cc0c8a936dfa284Lennart Poettering PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
0bee65f0622c4faa8ac8ae771cc0c8a936dfa284Lennart Poettering /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
0bee65f0622c4faa8ac8ae771cc0c8a936dfa284Lennart Poettering rm -f $initdir/usr/lib/systemd/system/plymouth* $initdir/usr/lib/systemd/system/*/plymouth*
0bee65f0622c4faa8ac8ae771cc0c8a936dfa284Lennart Poettering dracut_install sh df free ls shutdown poweroff \
0bee65f0622c4faa8ac8ae771cc0c8a936dfa284Lennart Poettering mount dmesg dhclient mkdir cp ping dhclient \