test-functions revision 889a90422dd47284dffa32b9234a6e58991b000c
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# ex: ts=8 sw=4 sts=4 et filetype=sh
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterBASICTOOLS="sh bash setsid loadkeys setfont login sushell sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe"
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterDEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster -append "root=/dev/sda1 systemd.log_level=debug raid=noautodetect loglevel=2 init=/usr/lib/systemd/systemd ro console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" || return 1
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ../../systemd-nspawn --boot --directory=$TESTDIR/nspawn-root /usr/lib/systemd/systemd
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster type -P dmeventd >/dev/null && dracut_install dmeventd
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (cd $TEST_BASE_DIR/..; make DESTDIR=$initdir install)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # we strip binaries since debug symbols increase binaries size a lot
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # Create the blank file to use as a root filesystem
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster dd if=/dev/null of=$TESTDIR/rootdisk.img bs=1M seek=200
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster [ -b $LOOPDEV ] || return 1
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sfdisk -C 6400 -H 2 -S 32 -L $LOOPDEV <<EOF
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster [[ -f $TESTDIR/nspawn-root/failed ]] && cp -a $TESTDIR/nspawn-root/failed $TESTDIR
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster cp -a $TESTDIR/nspawn-root/var/log/journal $TESTDIR
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster find "$initdir" -executable -not -path '*/lib/modules/*.ko' -type f | xargs strip --strip-unneeded | ddebug
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster | while read i; do
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if [[ -d $initdir/lib/modules/$KERNEL_VER ]] && \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # install plymouth, if found... else remove plymouth service files
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster rm -f $initdir/{usr/lib,etc}/systemd/system/plymouth* $initdir/{usr/lib,etc}/systemd/system/*/plymouth*
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterLABEL=systemd / ext3 rw 0 1
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster [[ $BASICTOOLS ]] && dracut_install $BASICTOOLS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster [[ $DEBUGTOOLS ]] && dracut_install $DEBUGTOOLS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster | while read file; do
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster | while read file; do
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster [[ -f $i ]] || continue
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /usr/lib/kbd/consolefonts/latarcyrheb-sun16*; do
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster [[ -f $i ]] || continue
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster [ -f ${_terminfodir}/l/linux ] && break
ln -fs $TEST_BASE_DIR/testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
for d in usr/bin usr/sbin bin etc lib "$libdir" sbin tmp usr var var/log dev proc sys sysroot root run run/lock run/initramfs; do
local _bin=$1
if [[ $_line =~ $_so_regex ]]; then
_file=${BASH_REMATCH[1]}
[[ -e $STATEFILE ]] && . $STATEFILE
export TESTDIR
export initdir
[ $1 -le $LOG_LEVEL ] || return 0
if [ $# -ge 1 ]; then
while read line; do
while [[ ${__absolute[__level]} == ${__current[__level]} ]]
if [[ -n $__newpath ]]
if [[ -L $_file ]]; then
# rev_lib_symlinks libfoo.so.8.1
if [[ -L $_src ]]; then
[[ -L $_bin ]] && inst_symlink $_bin $_target && return 0
if [[ $_line =~ $_so_regex ]]; then
_file=${BASH_REMATCH[1]}
local _bin
local _line _shebang_regex
[[ $_line =~ $_shebang_regex ]] || return 1
if [[ -d $_realsrc ]]; then
if [[ -f $r/$_rule ]]; then
if [[ -f ${r}$_rule ]]; then
local _x
case $# in
[[ $initdir = $2 ]] && set $1;;
for _x in inst_symlink inst_script inst_binary inst_simple; do
local to f
if [[ $_optional = yes ]]; then
if [[ $omit_drivers ]]; then
_found=1
local _modname _filtercmd
if ! [[ $hostonly ]]; then
if ! [[ $hostonly ]]; then
[[ $no_kernel = yes ]] && return
local _fderr=9
| instmods
| instmods
local _moddirname=${KERNEL_MODS%%/lib/modules/*}
--set-version $KERNEL_VER ${_moddirname} $_mpargs
return $_ret
while read _mod; do
set -o pipefail
| while read line; do [[ "$line" =~ $_filter_not_found ]] && echo $line || echo $line >&2 ;done | derror
_ret=$?
set +o pipefail
return $_ret
local _pattern=$1
case $1 in
--run)
ret=$?
exit $ret;;
--setup)
--clean)
--all)
ret=$?
exit $ret
ret=$?
exit $ret;;