3 TEST_DESCRIPTION
="Full systemd serialization/deserialization test with /usr mount"
5 export KVERSION
=${KVERSION-$(uname -r)}
7 # Uncomment this to debug failures
8 #DEBUGFAIL="rd.shell rd.break"
10 #DEBUGOUT="quiet systemd.log_level=debug systemd.log_target=console loglevel=77 rd.info rd.debug"
11 DEBUGOUT
="loglevel=0 "
13 local test_name
="$1"; shift
14 local client_opts
="$*"
16 echo "CLIENT TEST START: $test_name"
18 dd if=/dev
/zero of
=$TESTDIR/result bs
=1M count
=1
20 -drive format
=raw
,index
=0,media
=disk
,file=$TESTDIR/root.btrfs \
21 -drive format
=raw
,index
=1,media
=disk
,file=$TESTDIR/usr.btrfs \
22 -drive format
=raw
,index
=2,media
=disk
,file=$TESTDIR/result \
23 -m 512M
-smp 2 -nographic \
26 -append "panic=1 systemd.crash_reboot root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT rd.shell=0 $DEBUGFAIL" \
27 -initrd $TESTDIR/initramfs.testing
30 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
34 if ! grep -F -m 1 -q dracut-root-block-success
$TESTDIR/result
; then
35 echo "CLIENT TEST END: $test_name [FAILED]"
38 echo "CLIENT TEST END: $test_name [OK]"
43 client_run
"no option specified" ||
return 1
44 client_run
"readonly root" "ro" ||
return 1
45 client_run
"writeable root" "rw" ||
return 1
50 rm -f -- $TESTDIR/root.btrfs
51 rm -f -- $TESTDIR/usr.btrfs
52 # Create the blank file to use as a root filesystem
53 dd if=/dev
/null of
=$TESTDIR/root.btrfs bs
=1M seek
=320
54 dd if=/dev
/null of
=$TESTDIR/usr.btrfs bs
=1M seek
=320
56 export kernel
=$KVERSION
57 # Create what will eventually be our root filesystem onto an overlay
59 export initdir
=$TESTDIR/overlay
/source
61 .
$basedir/dracut-init.sh
63 for d
in usr
/bin usr
/sbin bin etc lib
"$libdir" sbin tmp usr var var
/log dev proc sys sysroot root run
; do
71 ln -sfn /run
"$initdir/var/run"
72 ln -sfn /run
/lock
"$initdir/var/lock"
74 inst_multiple sh df free
ls shutdown poweroff stty
cat ps
ln ip \
75 mount dmesg dhclient mkdir
cp ping dhclient \
76 umount strace
less setsid tree systemctl
reset
78 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
79 [ -f ${_terminfodir}/l
/linux
] && break
81 inst_multiple
-o ${_terminfodir}/l
/linux
82 inst
"$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
83 inst
"$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
85 inst_simple .
/fstab
/etc
/fstab
86 rpm
-ql systemd |
xargs -r $DRACUT_INSTALL ${initdir:+-D "$initdir"} -o -a -l
87 inst
/lib
/systemd
/system
/systemd-remount-fs.service
88 inst
/lib
/systemd
/systemd-remount-fs
89 inst
/lib
/systemd
/system
/systemd-journal-flush.service
90 inst
/etc
/sysconfig
/init
91 inst
/lib
/systemd
/system
/slices.target
92 inst
/lib
/systemd
/system
/system.slice
93 inst_multiple
-o /lib
/systemd
/system
/dracut
*
95 # make a journal directory
96 mkdir
-p $initdir/var
/log
/journal
98 # install some basic config files
102 /etc
/sysconfig
/init \
113 # we want an empty environment
114 > $initdir/etc
/environment
116 # setup the testsuite target
117 cat >$initdir/etc
/systemd
/system
/testsuite.target
<<EOF
119 Description=Testsuite target
120 Requires=basic.target
122 Conflicts=rescue.target
126 inst .
/test-init.sh
/sbin
/test-init
128 # setup the testsuite service
129 cat >$initdir/etc
/systemd
/system
/testsuite.service
<<EOF
131 Description=Testsuite service
135 ExecStart=/sbin/test-init
140 mkdir
-p $initdir/etc
/systemd
/system
/testsuite.target.wants
141 ln -fs ..
/testsuite.service
$initdir/etc
/systemd
/system
/testsuite.target.wants
/testsuite.service
143 # make the testsuite the default target
144 ln -fs testsuite.target
$initdir/etc
/systemd
/system
/default.target
146 # mkdir -p $initdir/etc/rc.d
147 # cat >$initdir/etc/rc.d/rc.local <<EOF
152 # install basic tools needed
153 inst_multiple sh bash setsid loadkeys setfont \
154 login sushell sulogin
gzip sleep echo mount umount
155 inst_multiple modprobe
157 # install libnss_files for login
158 inst_libdir_file
"libnss_files*"
160 # install dbus and pam
166 /lib
/security
-xtype f \
167 |
while read file ||
[ -n "$file" ]; do
168 inst_multiple
-o $file
171 # install dbus socket and service file
172 inst
/usr
/lib
/systemd
/system
/dbus.socket
173 inst
/usr
/lib
/systemd
/system
/dbus.service
178 ) >$initrd/etc
/vconsole.conf
180 # install basic keyboard maps and fonts
182 /usr
/lib
/kbd
/consolefonts
/eurlatgr
* \
183 /usr
/lib
/kbd
/keymaps
/{legacy
/,/}include
/* \
184 /usr
/lib
/kbd
/keymaps
/{legacy
/,/}i386
/include
/* \
185 /usr
/lib
/kbd
/keymaps
/{legacy
/,/}i386
/qwerty
/us.
*; do
186 [[ -f $i ]] ||
continue
190 # some basic terminfo files
191 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
192 [ -f ${_terminfodir}/l
/linux
] && break
194 inst_multiple
-o ${_terminfodir}/l
/linux
197 ln -fs /proc
/self
/mounts
$initdir/etc
/mtab
199 # install any Execs from the service files
200 grep -Eho '^Exec[^ ]*=[^ ]+' $initdir/lib
/systemd
/system
/*.service \
201 |
while read i ||
[ -n "$i" ]; do
202 i
=${i##Exec*=}; i
=${i##-}
206 # some helper tools for debugging
207 [[ $DEBUGTOOLS ]] && inst_multiple
$DEBUGTOOLS
209 # install ld.so.conf* and run ldconfig
210 cp -a /etc
/ld.so.conf
* $initdir/etc
211 ldconfig
-r "$initdir"
212 ddebug
"Strip binaeries"
213 find "$initdir" -perm /0111 -type f |
xargs -r strip
--strip-unneeded | ddebug
216 inst
/lib
/modules
/$kernel/modules.order
217 inst
/lib
/modules
/$kernel/modules.
builtin
218 # generate module dependencies
219 if [[ -d $initdir/lib
/modules
/$kernel ]] && \
220 ! depmod
-a -b "$initdir" $kernel; then
221 dfatal
"\"depmod -a $kernel\" failed."
227 # second, install the files needed to make the root filesystem
229 export initdir
=$TESTDIR/overlay
230 .
$basedir/dracut-init.sh
231 inst_multiple sfdisk mkfs.btrfs btrfs poweroff
cp umount sync
232 inst_hook initqueue
01 .
/create-root.sh
233 inst_hook initqueue
/finished
01 .
/finished-false.sh
234 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
237 # create an initramfs that will create the target root filesystem.
238 # We do it this way so that we do not risk trashing the host mdraid
239 # devices, volume groups, encrypted partitions, etc.
240 $basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
241 -m "dash udev-rules btrfs base rootfs-block fs-lib kernel-modules" \
242 -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
245 --no-hostonly-cmdline -N \
246 -f $TESTDIR/initramfs.makeroot
$KVERSION ||
return 1
248 # Invoke KVM and/or QEMU to actually create the target filesystem.
249 rm -rf -- $TESTDIR/overlay
252 -drive format
=raw
,index
=0,media
=disk
,file=$TESTDIR/root.btrfs \
253 -drive format
=raw
,index
=1,media
=disk
,file=$TESTDIR/usr.btrfs \
254 -m 512M
-smp 2 -nographic -net none \
255 -append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
256 -initrd $TESTDIR/initramfs.makeroot ||
return 1
257 grep -F -m 1 -q dracut-root-block-created
$TESTDIR/root.btrfs ||
return 1
261 export initdir
=$TESTDIR/overlay
262 .
$basedir/dracut-init.sh
263 inst_multiple poweroff shutdown
264 inst_hook shutdown-emergency
000 .
/hard-off.sh
265 inst_hook emergency
000 .
/hard-off.sh
266 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
269 [ -e /etc
/machine-id
] && EXTRA_MACHINE
="/etc/machine-id"
270 [ -e /etc
/machine-info
] && EXTRA_MACHINE
+=" /etc/machine-info"
272 sudo
$basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
273 -a "debug systemd i18n" \
274 ${EXTRA_MACHINE:+-I "$EXTRA_MACHINE"} \
275 -o "dash network plymouth lvm mdraid resume crypt caps dm terminfo usrmount kernel-network-modules" \
276 -d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
277 --no-hostonly-cmdline -N \
278 -f $TESTDIR/initramfs.testing
$KVERSION ||
return 1
280 rm -rf -- $TESTDIR/overlay
287 .
$testdir/test-functions