2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 TEST_DESCRIPTION="Basic systemd setup"
6 KVERSION=${KVERSION-$(uname -r)}
8 # Uncomment this to debug failures
9 #DEBUGFAIL="systemd.unit=multi-user.target"
13 -hda $TESTDIR/rootdisk.img \
15 -net none -kernel /boot/vmlinuz-$KVERSION \
16 -append "root=/dev/sda1 systemd.log_level=debug raid=noautodetect loglevel=2 init=/usr/lib/systemd/systemd rw console=ttyS0,115200n81 selinux=0 $DEBUGFAIL"
18 mkdir -p $TESTDIR/root
19 mount ${LOOPDEV}p1 $TESTDIR/root
20 [[ -e $TESTDIR/root/testok ]] && ret=0
21 cp -a $TESTDIR/root/var/log/journal $TESTDIR
23 ls -l $TESTDIR/journal/*/*.journal
28 rm -f $TESTDIR/rootdisk.img
29 # Create the blank file to use as a root filesystem
30 dd if=/dev/null of=$TESTDIR/rootdisk.img bs=1M seek=100
31 LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
32 [ -b $LOOPDEV ] || return 1
33 echo "LOOPDEV=$LOOPDEV" >> $STATEFILE
34 sfdisk -C 3200 -H 2 -S 32 -L $LOOPDEV <<EOF
38 mkfs.ext3 -L systemd ${LOOPDEV}p1
39 mkdir -p $TESTDIR/root
40 mount ${LOOPDEV}p1 $TESTDIR/root
41 mkdir -p $TESTDIR/root/run
44 # Create what will eventually be our root filesystem onto an overlay
49 # create the basic filesystem layout
52 # install compiled files
53 (cd ../..; make DESTDIR=$initdir install)
55 # install possible missing libraries
56 for i in $initdir/{sbin,bin}/* $initdir/lib/systemd/*; do
60 # activate kmsg import
61 echo 'ImportKernel=yes' >> $initdir/etc/systemd/journald.conf
63 # make a journal directory
64 mkdir -p $initdir/var/log/journal
66 # install some basic config files
67 inst /etc/sysconfig/init
72 inst /etc/nsswitch.conf
77 # we want an empty environment
78 > $initdir/etc/environment
81 echo systemd-testsuite > $initdir/etc/hostname
83 # setup the testsuite target
84 cat >$initdir/etc/systemd/system/testsuite.target <<EOF
86 Description=Testsuite target
87 Requires=multi-user.target
88 After=multi-user.target
89 Conflicts=rescue.target
93 # setup the testsuite service
94 cat >$initdir/etc/systemd/system/testsuite.service <<EOF
96 Description=Testsuite service
97 After=multi-user.target
100 ExecStart=/bin/sh -c 'echo OK > /testok; /bin/sleep 5'
101 ExecStartPost=/usr/sbin/poweroff
105 mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
106 ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
108 # make the testsuite the default target
109 ln -fs testsuite.target $initdir/etc/systemd/system/default.target
111 # install basic tools needed
112 dracut_install sh bash setsid loadkeys setfont \
113 login sushell sulogin gzip sleep echo
115 # install libnss_files for login
116 inst_libdir_file "libnss_files*"
118 # install dbus and pam
124 /lib/security -xtype f \
125 | while read file; do
129 # install dbus socket and service file
130 inst /usr/lib/systemd/system/dbus.socket
131 inst /usr/lib/systemd/system/dbus.service
133 # install basic keyboard maps and fonts
135 /usr/lib/kbd/consolefonts/latarcyrheb-sun16* \
136 /usr/lib/kbd/keymaps/include/* \
137 /usr/lib/kbd/keymaps/i386/include/* \
138 /usr/lib/kbd/keymaps/i386/qwerty/us.*; do
139 [[ -f $i ]] || continue
143 # some basic terminfo files
144 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
145 [ -f ${_terminfodir}/l/linux ] && break
147 dracut_install -o ${_terminfodir}/l/linux
150 ln -fs /proc/self/mounts $initdir/etc/mtab
152 # install any Exec's from the service files
153 egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
155 i=${i##Exec*=}; i=${i##-}
159 # install plymouth, if found... else remove plymouth service files
160 if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
161 PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
162 /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
163 dracut_install plymouth plymouthd
165 rm -f $initdir/usr/lib/systemd/system/plymouth* $initdir/usr/lib/systemd/system/*/plymouth*
168 # some helper tools for debugging
169 dracut_install sh df free ls shutdown poweroff \
170 stty cat ps ln ip route \
171 mount dmesg dhclient mkdir cp ping dhclient \
172 umount strace less grep
174 # install ld.so.conf* and run ldconfig
175 cp -a /etc/ld.so.conf* $initdir/etc
176 ldconfig -r "$initdir"
184 umount $TESTDIR/root 2>/dev/null
185 [[ $LOOPDEV ]] && losetup -d $LOOPDEV
189 . $TEST_BASE_DIR/test-functions