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 -hda $TESTDIR/root.btrfs \
21 -hdb $TESTDIR/usr.btrfs \
22 -hdc $TESTDIR/result \
23 -m 256M
-smp 2 -nographic \
25 -append "root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT $DEBUGFAIL" \
26 -initrd $TESTDIR/initramfs.testing
29 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
33 if ! grep -F -m 1 -q dracut-root-block-success
$TESTDIR/result
; then
34 echo "CLIENT TEST END: $test_name [FAILED]"
37 echo "CLIENT TEST END: $test_name [OK]"
42 client_run
"no option specified" ||
return 1
43 client_run
"readonly root" "ro" ||
return 1
44 client_run
"writeable root" "rw" ||
return 1
49 rm -f -- $TESTDIR/root.btrfs
50 rm -f -- $TESTDIR/usr.btrfs
51 # Create the blank file to use as a root filesystem
52 dd if=/dev
/null of
=$TESTDIR/root.btrfs bs
=1M seek
=320
53 dd if=/dev
/null of
=$TESTDIR/usr.btrfs bs
=1M seek
=320
55 export kernel
=$KVERSION
56 # Create what will eventually be our root filesystem onto an overlay
58 export initdir
=$TESTDIR/overlay
/source
60 .
$basedir/dracut-functions.sh
62 for d
in usr
/bin usr
/sbin bin etc lib
"$libdir" sbin tmp usr var var
/log dev proc sys sysroot root run
; do
70 ln -sfn /run
"$initdir/var/run"
71 ln -sfn /run
/lock
"$initdir/var/lock"
73 inst_multiple sh df free
ls shutdown poweroff stty
cat ps
ln ip route \
74 mount dmesg ifconfig dhclient mkdir
cp ping dhclient \
75 umount strace
less setsid tree systemctl
reset
77 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
78 [ -f ${_terminfodir}/l
/linux
] && break
80 inst_multiple
-o ${_terminfodir}/l
/linux
81 inst
"$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
82 inst
"$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
84 inst_simple .
/fstab
/etc
/fstab
85 rpm
-ql systemd |
xargs -r $DRACUT_INSTALL ${initdir:+-D "$initdir"} -o -a -l
86 inst
/lib
/systemd
/system
/systemd-remount-fs.service
87 inst
/lib
/systemd
/systemd-remount-fs
88 inst
/lib
/systemd
/system
/systemd-journal-flush.service
89 inst
/etc
/sysconfig
/init
90 inst
/lib
/systemd
/system
/slices.target
91 inst
/lib
/systemd
/system
/system.slice
92 inst_multiple
-o /lib
/systemd
/system
/dracut
*
94 # make a journal directory
95 mkdir
-p $initdir/var
/log
/journal
97 # install some basic config files
101 /etc
/sysconfig
/init \
112 # we want an empty environment
113 > $initdir/etc
/environment
115 # setup the testsuite target
116 cat >$initdir/etc
/systemd
/system
/testsuite.target
<<EOF
118 Description=Testsuite target
119 Requires=basic.target
121 Conflicts=rescue.target
125 inst .
/test-init.sh
/sbin
/test-init
127 # setup the testsuite service
128 cat >$initdir/etc
/systemd
/system
/testsuite.service
<<EOF
130 Description=Testsuite service
134 ExecStart=/sbin/test-init
139 mkdir
-p $initdir/etc
/systemd
/system
/testsuite.target.wants
140 ln -fs ..
/testsuite.service
$initdir/etc
/systemd
/system
/testsuite.target.wants
/testsuite.service
142 # make the testsuite the default target
143 ln -fs testsuite.target
$initdir/etc
/systemd
/system
/default.target
145 # mkdir -p $initdir/etc/rc.d
146 # cat >$initdir/etc/rc.d/rc.local <<EOF
151 # install basic tools needed
152 inst_multiple sh bash setsid loadkeys setfont \
153 login sushell sulogin
gzip sleep echo mount umount
154 inst_multiple modprobe
156 # install libnss_files for login
157 inst_libdir_file
"libnss_files*"
159 # install dbus and pam
165 /lib
/security
-xtype f \
166 |
while read file; do
167 inst_multiple
-o $file
170 # install dbus socket and service file
171 inst
/usr
/lib
/systemd
/system
/dbus.socket
172 inst
/usr
/lib
/systemd
/system
/dbus.service
174 # install basic keyboard maps and fonts
176 /usr
/lib
/kbd
/consolefonts
/latarcyrheb-sun16
* \
177 /usr
/lib
/kbd
/keymaps
/include
/* \
178 /usr
/lib
/kbd
/keymaps
/i386
/include
/* \
179 /usr
/lib
/kbd
/keymaps
/i386
/qwerty
/us.
*; do
180 [[ -f $i ]] ||
continue
184 # some basic terminfo files
185 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
186 [ -f ${_terminfodir}/l
/linux
] && break
188 inst_multiple
-o ${_terminfodir}/l
/linux
191 ln -fs /proc
/self
/mounts
$initdir/etc
/mtab
193 # install any Exec's from the service files
194 egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib
/systemd
/system
/*.service \
196 i
=${i##Exec*=}; i
=${i##-}
200 # some helper tools for debugging
201 [[ $DEBUGTOOLS ]] && inst_multiple
$DEBUGTOOLS
203 # install ld.so.conf* and run ldconfig
204 cp -a /etc
/ld.so.conf
* $initdir/etc
205 ldconfig
-r "$initdir"
206 ddebug
"Strip binaeries"
207 find "$initdir" -perm +111 -type f |
xargs -r strip
--strip-unneeded | ddebug
210 inst
/lib
/modules
/$kernel/modules.order
211 inst
/lib
/modules
/$kernel/modules.
builtin
212 # generate module dependencies
213 if [[ -d $initdir/lib
/modules
/$kernel ]] && \
214 ! depmod
-a -b "$initdir" $kernel; then
215 dfatal
"\"depmod -a $kernel\" failed."
221 # second, install the files needed to make the root filesystem
223 export initdir
=$TESTDIR/overlay
224 .
$basedir/dracut-functions.sh
225 inst_multiple sfdisk mkfs.btrfs btrfs poweroff
cp umount sync
226 inst_hook initqueue
01 .
/create-root.sh
227 inst_hook initqueue
/finished
01 .
/finished-false.sh
228 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
231 # create an initramfs that will create the target root filesystem.
232 # We do it this way so that we do not risk trashing the host mdraid
233 # devices, volume groups, encrypted partitions, etc.
234 $basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
235 -m "dash udev-rules btrfs base rootfs-block kernel-modules" \
236 -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
239 -f $TESTDIR/initramfs.makeroot
$KVERSION ||
return 1
241 # Invoke KVM and/or QEMU to actually create the target filesystem.
243 # echo $TESTDIR/overlay
244 # echo $TESTDIR/initramfs.makeroot
246 rm -rf -- $TESTDIR/overlay
249 -hda $TESTDIR/root.btrfs \
250 -hdb $TESTDIR/usr.btrfs \
251 -m 256M
-smp 2 -nographic -net none \
252 -append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
253 -initrd $TESTDIR/initramfs.makeroot ||
return 1
254 grep -F -m 1 -q dracut-root-block-created
$TESTDIR/root.btrfs ||
return 1
258 export initdir
=$TESTDIR/overlay
259 .
$basedir/dracut-functions.sh
260 inst_multiple poweroff shutdown
261 inst_hook emergency
000 .
/hard-off.sh
262 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
264 sudo
$basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
266 -I "/etc/machine-id /etc/hostname" \
267 -o "dash network plymouth lvm mdraid resume crypt i18n caps dm terminfo usrmount" \
268 -d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
269 -f $TESTDIR/initramfs.testing
$KVERSION ||
return 1
271 rm -rf -- $TESTDIR/overlay
273 # -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
280 .
$testdir/test-functions