test.sh revision 898720b7e9cf3bdf7a93e435cbed5dd6942ecf9b
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou# ex: ts=8 sw=4 sts=4 et filetype=sh
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou# Uncomment this to debug failures
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou -append "root=/dev/sda1 systemd.log_level=debug raid=noautodetect loglevel=2 init=/usr/lib/systemd/systemd rw console=ttyS0,115200n81 selinux=0 $DEBUGFAIL"
0ac98dbed6b896ad6bb5adf2c70038112268966bJnRouvignac # Create the blank file to use as a root filesystem
53247d28ba99538f841a13ea2cde01c3faa3ef36kenneth_suter dd if=/dev/null of=$TESTDIR/rootdisk.img bs=1M seek=100
0ac98dbed6b896ad6bb5adf2c70038112268966bJnRouvignac LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
0ac98dbed6b896ad6bb5adf2c70038112268966bJnRouvignac [ -b $LOOPDEV ] || return 1
0ac98dbed6b896ad6bb5adf2c70038112268966bJnRouvignac sfdisk -C 3200 -H 2 -S 32 -L $LOOPDEV <<EOF
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou # Create what will eventually be our root filesystem onto an overlay
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou echo 'ImportKernel=yes' >> $initdir/etc/systemd/journald.conf
0ac98dbed6b896ad6bb5adf2c70038112268966bJnRouvignac cat >$initdir/etc/systemd/system/testsuite.target <<EOF
0ac98dbed6b896ad6bb5adf2c70038112268966bJnRouvignacDescription=Testsuite target
02dfa37c68e25bff17fa958b0773b88262bb1380jarnouRequires=multi-user.target
02dfa37c68e25bff17fa958b0773b88262bb1380jarnouAfter=multi-user.target
0ac98dbed6b896ad6bb5adf2c70038112268966bJnRouvignacConflicts=rescue.target
02dfa37c68e25bff17fa958b0773b88262bb1380jarnouAllowIsolate=yes
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou cat >$initdir/etc/systemd/system/testsuite.service <<EOF
02dfa37c68e25bff17fa958b0773b88262bb1380jarnouDescription=Testsuite service
02dfa37c68e25bff17fa958b0773b88262bb1380jarnouAfter=multi-user.target
02dfa37c68e25bff17fa958b0773b88262bb1380jarnouExecStart=/bin/sh -c 'echo OK > /testok; /bin/sleep 5'
0ac98dbed6b896ad6bb5adf2c70038112268966bJnRouvignacExecStartPost=/usr/sbin/poweroff
ffbc69223f0d1b5043554576d0ee3f1035043982sinType=oneshot
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou ln -fs testsuite.target $initdir/etc/systemd/system/default.target
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou | while read file; do
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou [[ -f $i ]] || continue
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou [ -f ${_terminfodir}/l/linux ] && break
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou | while read i; do
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou # install plymouth, if found... else remove plymouth service files
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
02dfa37c68e25bff17fa958b0773b88262bb1380jarnou /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir