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 -append "panic=1 systemd.crash_reboot root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT rd.shell=0 $DEBUGFAIL" \
24 -initrd $TESTDIR/initramfs.testing
27 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
31 if ! grep -F -m 1 -q dracut-root-block-success
$TESTDIR/result
; then
32 echo "CLIENT TEST END: $test_name [FAILED]"
35 echo "CLIENT TEST END: $test_name [OK]"
40 client_run
"no option specified" ||
return 1
41 client_run
"readonly root" "ro" ||
return 1
42 client_run
"writeable root" "rw" ||
return 1
47 rm -f -- $TESTDIR/root.btrfs
48 rm -f -- $TESTDIR/usr.btrfs
49 # Create the blank file to use as a root filesystem
50 dd if=/dev
/null of
=$TESTDIR/root.btrfs bs
=1M seek
=320
51 dd if=/dev
/null of
=$TESTDIR/usr.btrfs bs
=1M seek
=320
53 export kernel
=$KVERSION
54 # Create what will eventually be our root filesystem onto an overlay
56 export initdir
=$TESTDIR/overlay
/source
58 .
$basedir/dracut-init.sh
60 for d
in usr
/bin usr
/sbin bin etc lib
"$libdir" sbin tmp usr var var
/log dev proc sys sysroot root run
; do
68 ln -sfn /run
"$initdir/var/run"
69 ln -sfn /run
/lock
"$initdir/var/lock"
71 inst_multiple sh df free
ls shutdown poweroff stty
cat ps
ln ip \
72 mount dmesg mkdir
cp ping dd \
73 umount strace
less setsid tree systemctl
reset
75 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
76 [ -f ${_terminfodir}/l
/linux
] && break
78 inst_multiple
-o ${_terminfodir}/l
/linux
80 inst_simple .
/fstab
/etc
/fstab
81 rpm
-ql systemd |
xargs -r $DRACUT_INSTALL ${initdir:+-D "$initdir"} -o -a -l
82 inst
/lib
/systemd
/system
/systemd-remount-fs.service
83 inst
/lib
/systemd
/systemd-remount-fs
84 inst
/lib
/systemd
/system
/systemd-journal-flush.service
85 inst
/etc
/sysconfig
/init
86 inst
/lib
/systemd
/system
/slices.target
87 inst
/lib
/systemd
/system
/system.slice
88 inst_multiple
-o /lib
/systemd
/system
/dracut
*
90 # make a journal directory
91 mkdir
-p $initdir/var
/log
/journal
93 # install some basic config files
107 # we want an empty environment
108 > $initdir/etc
/environment
110 # setup the testsuite target
111 mkdir
-p $initdir/etc
/systemd
/system
112 cat >$initdir/etc
/systemd
/system
/testsuite.target
<<EOF
114 Description=Testsuite target
115 Requires=basic.target
117 Conflicts=rescue.target
121 inst .
/test-init.sh
/sbin
/test-init
123 # setup the testsuite service
124 cat >$initdir/etc
/systemd
/system
/testsuite.service
<<EOF
126 Description=Testsuite service
130 ExecStart=/sbin/test-init
135 mkdir
-p $initdir/etc
/systemd
/system
/testsuite.target.wants
136 ln -fs ..
/testsuite.service
$initdir/etc
/systemd
/system
/testsuite.target.wants
/testsuite.service
138 # make the testsuite the default target
139 ln -fs testsuite.target
$initdir/etc
/systemd
/system
/default.target
141 # mkdir -p $initdir/etc/rc.d
142 # cat >$initdir/etc/rc.d/rc.local <<EOF
147 # install basic tools needed
148 inst_multiple sh bash setsid loadkeys setfont \
149 login sushell sulogin
gzip sleep echo mount umount
150 inst_multiple modprobe
152 # install libnss_files for login
153 inst_libdir_file
"libnss_files*"
155 # install dbus and pam
161 /lib
/security
-xtype f \
162 |
while read file ||
[ -n "$file" ]; do
163 inst_multiple
-o $file
166 # install dbus socket and service file
167 inst
/usr
/lib
/systemd
/system
/dbus.socket
168 inst
/usr
/lib
/systemd
/system
/dbus.service
169 inst
/usr
/lib
/systemd
/system
/dbus-broker.service
170 inst
/usr
/lib
/systemd
/system
/dbus-daemon.service
175 ) >$initrd/etc
/vconsole.conf
177 # install basic keyboard maps and fonts
179 /usr
/lib
/kbd
/consolefonts
/eurlatgr
* \
180 /usr
/lib
/kbd
/keymaps
/{legacy
/,/}include
/* \
181 /usr
/lib
/kbd
/keymaps
/{legacy
/,/}i386
/include
/* \
182 /usr
/lib
/kbd
/keymaps
/{legacy
/,/}i386
/qwerty
/us.
*; do
183 [[ -f $i ]] ||
continue
187 # some basic terminfo files
188 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
189 [ -f ${_terminfodir}/l
/linux
] && break
191 inst_multiple
-o ${_terminfodir}/l
/linux
194 ln -fs /proc
/self
/mounts
$initdir/etc
/mtab
196 # install any Execs from the service files
197 grep -Eho '^Exec[^ ]*=[^ ]+' $initdir/lib
/systemd
/system
/*.service \
198 |
while read i ||
[ -n "$i" ]; do
199 i
=${i##Exec*=}; i
=${i##-}
203 # some helper tools for debugging
204 [[ $DEBUGTOOLS ]] && inst_multiple
$DEBUGTOOLS
206 # install ld.so.conf* and run ldconfig
207 cp -a /etc
/ld.so.conf
* $initdir/etc
208 ldconfig
-r "$initdir"
209 ddebug
"Strip binaeries"
210 find "$initdir" -perm /0111 -type f |
xargs -r strip
--strip-unneeded | ddebug
213 inst
/lib
/modules
/$kernel/modules.order
214 inst
/lib
/modules
/$kernel/modules.
builtin
215 # generate module dependencies
216 if [[ -d $initdir/lib
/modules
/$kernel ]] && \
217 ! depmod
-a -b "$initdir" $kernel; then
218 dfatal
"\"depmod -a $kernel\" failed."
221 # disable some services
222 systemctl
--root "$initdir" mask systemd-update-utmp
223 systemctl
--root "$initdir" mask systemd-tmpfiles-setup
226 # second, install the files needed to make the root filesystem
228 export initdir
=$TESTDIR/overlay
229 .
$basedir/dracut-init.sh
230 inst_multiple sfdisk mkfs.btrfs btrfs poweroff
cp umount sync
dd
231 inst_hook initqueue
01 .
/create-root.sh
232 inst_hook initqueue
/finished
01 .
/finished-false.sh
233 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
236 # create an initramfs that will create the target root filesystem.
237 # We do it this way so that we do not risk trashing the host mdraid
238 # devices, volume groups, encrypted partitions, etc.
239 $basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
240 -m "bash udev-rules btrfs base rootfs-block fs-lib kernel-modules qemu" \
241 -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
244 --no-hostonly-cmdline -N \
245 -f $TESTDIR/initramfs.makeroot
$KVERSION ||
return 1
247 # Invoke KVM and/or QEMU to actually create the target filesystem.
248 rm -rf -- $TESTDIR/overlay
251 -drive format
=raw
,index
=0,media
=disk
,file=$TESTDIR/root.btrfs \
252 -drive format
=raw
,index
=1,media
=disk
,file=$TESTDIR/usr.btrfs \
253 -append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
254 -initrd $TESTDIR/initramfs.makeroot ||
return 1
255 if ! grep -F -m 1 -q dracut-root-block-created
$TESTDIR/root.btrfs
; then
256 echo "Could not create root filesystem"
261 export initdir
=$TESTDIR/overlay
262 .
$basedir/dracut-init.sh
263 inst_multiple poweroff shutdown
dd
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 $basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
273 -a "debug systemd i18n qemu" \
274 ${EXTRA_MACHINE:+-I "$EXTRA_MACHINE"} \
275 -o "dash network plymouth lvm mdraid resume crypt caps dm terminfo usrmount kernel-network-modules rngd" \
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