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 mkdir
cp ping \
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
83 inst_simple .
/fstab
/etc
/fstab
84 rpm
-ql systemd |
xargs -r $DRACUT_INSTALL ${initdir:+-D "$initdir"} -o -a -l
85 inst
/lib
/systemd
/system
/systemd-remount-fs.service
86 inst
/lib
/systemd
/systemd-remount-fs
87 inst
/lib
/systemd
/system
/systemd-journal-flush.service
88 inst
/etc
/sysconfig
/init
89 inst
/lib
/systemd
/system
/slices.target
90 inst
/lib
/systemd
/system
/system.slice
91 inst_multiple
-o /lib
/systemd
/system
/dracut
*
93 # make a journal directory
94 mkdir
-p $initdir/var
/log
/journal
96 # install some basic config files
110 # we want an empty environment
111 > $initdir/etc
/environment
113 # setup the testsuite target
114 mkdir
-p $initdir/etc
/systemd
/system
115 cat >$initdir/etc
/systemd
/system
/testsuite.target
<<EOF
117 Description=Testsuite target
118 Requires=basic.target
120 Conflicts=rescue.target
124 inst .
/test-init.sh
/sbin
/test-init
126 # setup the testsuite service
127 cat >$initdir/etc
/systemd
/system
/testsuite.service
<<EOF
129 Description=Testsuite service
133 ExecStart=/sbin/test-init
138 mkdir
-p $initdir/etc
/systemd
/system
/testsuite.target.wants
139 ln -fs ..
/testsuite.service
$initdir/etc
/systemd
/system
/testsuite.target.wants
/testsuite.service
141 # make the testsuite the default target
142 ln -fs testsuite.target
$initdir/etc
/systemd
/system
/default.target
144 # mkdir -p $initdir/etc/rc.d
145 # cat >$initdir/etc/rc.d/rc.local <<EOF
150 # install basic tools needed
151 inst_multiple sh bash setsid loadkeys setfont \
152 login sushell sulogin
gzip sleep echo mount umount
153 inst_multiple modprobe
155 # install libnss_files for login
156 inst_libdir_file
"libnss_files*"
158 # install dbus and pam
164 /lib
/security
-xtype f \
165 |
while read file ||
[ -n "$file" ]; do
166 inst_multiple
-o $file
169 # install dbus socket and service file
170 inst
/usr
/lib
/systemd
/system
/dbus.socket
171 inst
/usr
/lib
/systemd
/system
/dbus.service
172 inst
/usr
/lib
/systemd
/system
/dbus-broker.service
173 inst
/usr
/lib
/systemd
/system
/dbus-daemon.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."
224 # disable some services
225 systemctl
--root "$initdir" mask systemd-update-utmp
226 systemctl
--root "$initdir" mask systemd-tmpfiles-setup
229 # second, install the files needed to make the root filesystem
231 export initdir
=$TESTDIR/overlay
232 .
$basedir/dracut-init.sh
233 inst_multiple sfdisk mkfs.btrfs btrfs poweroff
cp umount sync
234 inst_hook initqueue
01 .
/create-root.sh
235 inst_hook initqueue
/finished
01 .
/finished-false.sh
236 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
239 # create an initramfs that will create the target root filesystem.
240 # We do it this way so that we do not risk trashing the host mdraid
241 # devices, volume groups, encrypted partitions, etc.
242 $basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
243 -m "bash udev-rules btrfs base rootfs-block fs-lib kernel-modules qemu" \
244 -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
247 --no-hostonly-cmdline -N \
248 -f $TESTDIR/initramfs.makeroot
$KVERSION ||
return 1
250 # Invoke KVM and/or QEMU to actually create the target filesystem.
251 rm -rf -- $TESTDIR/overlay
254 -drive format
=raw
,index
=0,media
=disk
,file=$TESTDIR/root.btrfs \
255 -drive format
=raw
,index
=1,media
=disk
,file=$TESTDIR/usr.btrfs \
256 -m 512M
-smp 2 -nographic -net none \
257 -append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
258 -initrd $TESTDIR/initramfs.makeroot ||
return 1
259 if ! grep -F -m 1 -q dracut-root-block-created
$TESTDIR/root.btrfs
; then
260 echo "Could not create root filesystem"
265 export initdir
=$TESTDIR/overlay
266 .
$basedir/dracut-init.sh
267 inst_multiple poweroff shutdown
268 inst_hook shutdown-emergency
000 .
/hard-off.sh
269 inst_hook emergency
000 .
/hard-off.sh
270 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
273 [ -e /etc
/machine-id
] && EXTRA_MACHINE
="/etc/machine-id"
274 [ -e /etc
/machine-info
] && EXTRA_MACHINE
+=" /etc/machine-info"
276 $basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
277 -a "debug systemd i18n qemu" \
278 ${EXTRA_MACHINE:+-I "$EXTRA_MACHINE"} \
279 -o "dash network plymouth lvm mdraid resume crypt caps dm terminfo usrmount kernel-network-modules rngd" \
280 -d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
281 --no-hostonly-cmdline -N \
282 -f $TESTDIR/initramfs.testing
$KVERSION ||
return 1
284 rm -rf -- $TESTDIR/overlay
291 .
$testdir/test-functions