2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 PATH
=/sbin
:/bin
:/usr
/sbin
:/usr
/bin
7 LOOKS_LIKE_DEBIAN
=$
(source /etc
/os-release
&& [[ "$ID" = "debian" ||
" $ID_LIKE " = *" debian "* ]] && echo yes || true
)
8 LOOKS_LIKE_ARCH
=$
(source /etc
/os-release
&& [[ "$ID" = "arch" ||
" $ID_LIKE " = *" arch "* ]] && echo yes || true
)
9 LOOKS_LIKE_SUSE
=$
(source /etc
/os-release
&& [[ " $ID_LIKE " = *" suse "* ]] && echo yes || true
)
10 KERNEL_VER
=${KERNEL_VER-$(uname -r)}
11 KERNEL_MODS
="/lib/modules/$KERNEL_VER/"
12 QEMU_TIMEOUT
="${QEMU_TIMEOUT:-infinity}"
13 NSPAWN_TIMEOUT
="${NSPAWN_TIMEOUT:-infinity}"
14 TIMED_OUT
= # will be 1 after run_* if *_TIMEOUT is set and test timed out
15 [[ "$LOOKS_LIKE_SUSE" ]] && FSTYPE
="${FSTYPE:-btrfs}" || FSTYPE
="${FSTYPE:-ext4}"
16 UNIFIED_CGROUP_HIERARCHY
="${UNIFIED_CGROUP_HIERARCHY:-default}"
17 EFI_MOUNT
="$(bootctl -p 2>/dev/null || echo /boot)"
19 if ! ROOTLIBDIR
=$
(pkg-config
--variable=systemdutildir systemd
); then
20 echo "WARNING! Cannot determine rootlibdir from pkg-config, assuming /usr/lib/systemd" >&2
21 ROOTLIBDIR
=/usr
/lib
/systemd
24 BASICTOOLS
="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln"
25 DEBUGTOOLS
="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find"
27 STATEDIR
="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"
28 STATEFILE
="$STATEDIR/.testdir"
29 TESTLOG
="$STATEDIR/test.log"
31 function find_qemu_bin
() {
32 # SUSE and Red Hat call the binary qemu-kvm. Debian and Gentoo call it kvm.
33 # Either way, only use this version if we aren't running in KVM, because
34 # nested KVM is flaky still.
35 if [ `systemd-detect-virt -v` != kvm
] ; then
36 [ "$QEMU_BIN" ] || QEMU_BIN
=$
(which -a kvm qemu-kvm
2>/dev
/null |
grep '^/' -m1)
39 [ "$ARCH" ] || ARCH
=$
(uname
-m)
42 # QEMU's own build system calls it qemu-system-x86_64
43 [ "$QEMU_BIN" ] || QEMU_BIN
=$
(which -a qemu-system-x86_64
2>/dev
/null |
grep '^/' -m1)
46 # new i386 version of QEMU
47 [ "$QEMU_BIN" ] || QEMU_BIN
=$
(which -a qemu-system-i386
2>/dev
/null |
grep '^/' -m1)
49 # i386 version of QEMU
50 [ "$QEMU_BIN" ] || QEMU_BIN
=$
(which -a qemu
2>/dev
/null |
grep '^/' -m1)
53 [ "$QEMU_BIN" ] || QEMU_BIN
=$
(which -a qemu-system-
$ARCH 2>/dev
/null |
grep '^/' -m1)
57 if [ ! -e "$QEMU_BIN" ]; then
58 echo "Could not find a suitable QEMU binary" >&2
63 # Return 0 if QEMU did run (then you must check the result state/logs for actual
64 # success), or 1 if QEMU is not available.
66 if [ -f /etc
/machine-id
]; then
67 read MACHINE_ID
< /etc
/machine-id
68 [ -z "$INITRD" ] && [ -e "$EFI_MOUNT/$MACHINE_ID/$KERNEL_VER/initrd" ] \
69 && INITRD
="$EFI_MOUNT/$MACHINE_ID/$KERNEL_VER/initrd"
70 [ -z "$KERNEL_BIN" ] && [ -e "$EFI_MOUNT/$MACHINE_ID/$KERNEL_VER/linux" ] \
71 && KERNEL_BIN
="$EFI_MOUNT/$MACHINE_ID/$KERNEL_VER/linux"
74 if [[ ! "$KERNEL_BIN" ]]; then
75 if [[ "$LOOKS_LIKE_ARCH" ]]; then
76 KERNEL_BIN
=/boot
/vmlinuz-linux
78 KERNEL_BIN
=/boot
/vmlinuz-
$KERNEL_VER
82 default_fedora_initrd
=/boot
/initramfs-
${KERNEL_VER}.img
83 default_debian_initrd
=/boot
/initrd.img-
${KERNEL_VER}
84 default_arch_initrd
=/boot
/initramfs-linux.img
85 default_suse_initrd
=/boot
/initrd-
${KERNEL_VER}
86 if [[ ! "$INITRD" ]]; then
87 if [[ -e "$default_fedora_initrd" ]]; then
88 INITRD
="$default_fedora_initrd"
89 elif [[ "$LOOKS_LIKE_DEBIAN" && -e "$default_debian_initrd" ]]; then
90 INITRD
="$default_debian_initrd"
91 elif [[ "$LOOKS_LIKE_ARCH" && -e "$default_arch_initrd" ]]; then
92 INITRD
="$default_arch_initrd"
93 elif [[ "$LOOKS_LIKE_SUSE" && -e "$default_suse_initrd" ]]; then
94 INITRD
="$default_suse_initrd"
98 [ "$QEMU_SMP" ] || QEMU_SMP
=1
100 find_qemu_bin ||
return 1
103 if [[ "$UNIFIED_CGROUP_HIERARCHY" = "yes" ]]; then
104 _cgroup_args
="systemd.unified_cgroup_hierarchy=yes"
105 elif [[ "$UNIFIED_CGROUP_HIERARCHY" = "no" ]]; then
106 _cgroup_args
="systemd.unified_cgroup_hierarchy=no systemd.legacy_systemd_cgroup_controller=yes"
107 elif [[ "$UNIFIED_CGROUP_HIERARCHY" = "hybrid" ]]; then
108 _cgroup_args
="systemd.unified_cgroup_hierarchy=no systemd.legacy_systemd_cgroup_controller=no"
109 elif [[ "$UNIFIED_CGROUP_HIERARCHY" != "default" ]]; then
110 dfatal
"Unknown UNIFIED_CGROUP_HIERARCHY. Got $UNIFIED_CGROUP_HIERARCHY, expected [yes|no|hybrid|default]"
114 if [[ "$LOOKS_LIKE_SUSE" ]]; then
115 PARAMS
+="rd.hostonly=0"
120 KERNEL_APPEND
="$PARAMS \
124 init=$ROOTLIBDIR/systemd \
132 QEMU_OPTIONS
="-smp $QEMU_SMP \
136 -kernel $KERNEL_BIN \
137 -drive format=raw,cache=unsafe,file=${TESTDIR}/rootdisk.img \
140 if [[ "$INITRD" && "$SKIP_INITRD" != "yes" ]]; then
141 QEMU_OPTIONS
="$QEMU_OPTIONS -initrd $INITRD"
144 # Let's use KVM if it is available, but let's avoid using nested KVM as that is still flaky
145 if [ -c /dev
/kvm
-a `systemd-detect-virt -v` != kvm
]; then
146 QEMU_OPTIONS
="$QEMU_OPTIONS -machine accel=kvm -enable-kvm -cpu host"
149 if [[ "$QEMU_TIMEOUT" != "infinity" ]]; then
150 QEMU_BIN
="timeout --foreground $QEMU_TIMEOUT $QEMU_BIN"
152 (set -x; $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND")
154 if [ "$rc" = 124 ] && [ "$QEMU_TIMEOUT" != "infinity" ]; then
155 derror
"test timed out after $QEMU_TIMEOUT s"
158 [ "$rc" != 0 ] && derror
"QEMU failed with exit code $rc"
163 # Return 0 if nspawn did run (then you must check the result state/logs for actual
164 # success), or 1 if nspawn is not available.
166 [[ -d /run
/systemd
/system
]] ||
return 1
168 local _nspawn_cmd
="$BUILD_DIR/systemd-nspawn --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND"
169 if [[ "$NSPAWN_TIMEOUT" != "infinity" ]]; then
170 _nspawn_cmd
="timeout --foreground $NSPAWN_TIMEOUT $_nspawn_cmd"
173 if [[ "$UNIFIED_CGROUP_HIERARCHY" = "hybrid" ]]; then
174 dwarn
"nspawn doesn't support UNIFIED_CGROUP_HIERARCHY=hybrid, skipping"
176 elif [[ "$UNIFIED_CGROUP_HIERARCHY" = "yes" ||
"$UNIFIED_CGROUP_HIERARCHY" = "no" ]]; then
177 _nspawn_cmd
="env UNIFIED_CGROUP_HIERARCHY=$UNIFIED_CGROUP_HIERARCHY $_nspawn_cmd"
178 elif [[ "$UNIFIED_CGROUP_HIERARCHY" = "default" ]]; then
179 _nspawn_cmd
="env --unset=UNIFIED_CGROUP_HIERARCHY $_nspawn_cmd"
181 dfatal
"Unknown UNIFIED_CGROUP_HIERARCHY. Got $UNIFIED_CGROUP_HIERARCHY, expected [yes|no|hybrid|default]"
185 (set -x; $_nspawn_cmd)
187 if [ "$rc" = 124 ] && [ "$NSPAWN_TIMEOUT" != "infinity" ]; then
188 derror
"test timed out after $NSPAWN_TIMEOUT s"
191 [ "$rc" != 0 ] && derror
"nspawn failed with exit code $rc"
196 setup_basic_environment
() {
197 # create the basic filesystem layout
201 install_missing_libraries
219 generate_module_dependencies
223 # don't forget KERNEL_APPEND='... selinux=1 ...'
224 if [[ "$SETUP_SELINUX" != "yes" ]]; then
225 ddebug
"Don't setup SELinux"
228 ddebug
"Setup SELinux"
229 local _conf_dir
=/etc
/selinux
230 local _fixfiles_tools
="bash uname cat sort uniq awk grep egrep head expr find rm secon setfiles"
232 rm -rf $initdir/$_conf_dir
233 if ! cp -ar $_conf_dir $initdir/$_conf_dir; then
234 dfatal
"Failed to copy $_conf_dir"
238 cat <<EOF >$initdir/etc/systemd/system/autorelabel.service
240 Description=Relabel all filesystems
241 DefaultDependencies=no
242 Requires=local-fs.target
243 Conflicts=shutdown.target
244 After=local-fs.target
245 Before=sysinit.target shutdown.target
246 ConditionSecurity=selinux
247 ConditionPathExists=|/.autorelabel
250 ExecStart=/bin/sh -x -c 'echo 0 >/sys/fs/selinux/enforce && fixfiles -f -F relabel && rm /.autorelabel && systemctl --force reboot'
256 touch $initdir/.autorelabel
257 mkdir
-p $initdir/etc
/systemd
/system
/basic.target.wants
258 ln -fs autorelabel.service
$initdir/etc
/systemd
/system
/basic.target.wants
/autorelabel.service
260 dracut_install
$_fixfiles_tools
261 dracut_install fixfiles
262 dracut_install sestatus
266 if ! type -p valgrind
; then
267 dfatal
"Failed to install valgrind"
271 local _valgrind_bins
=$
(strace
-e execve valgrind
/bin
/true
2>&1 >/dev
/null | perl
-lne 'print $1 if /^execve\("([^"]+)"/')
272 dracut_install
$_valgrind_bins
274 local _valgrind_libs
=$
(LD_DEBUG
=files valgrind
/bin
/true
2>&1 >/dev
/null | perl
-lne 'print $1 if m{calling init: (/.*vgpreload_.*)}')
275 dracut_install
$_valgrind_libs
277 local _valgrind_dbg_and_supp
=$
(
278 strace
-e open valgrind
/bin
/true
2>&1 >/dev
/null |
279 perl
-lne 'if (my ($fname) = /^open\("([^"]+).*= (?!-)\d+/) { print $fname if $fname =~ /debug|\.supp$/ }'
281 dracut_install
$_valgrind_dbg_and_supp
284 create_valgrind_wrapper
() {
285 local _valgrind_wrapper
=$initdir/$ROOTLIBDIR/systemd-under-valgrind
286 ddebug
"Create $_valgrind_wrapper"
287 cat >$_valgrind_wrapper <<EOF
290 mount -t proc proc /proc
291 exec valgrind --leak-check=full --log-file=/valgrind.out $ROOTLIBDIR/systemd "\$@"
293 chmod 0755 $_valgrind_wrapper
296 create_strace_wrapper
() {
297 local _strace_wrapper
=$initdir/$ROOTLIBDIR/systemd-under-strace
298 ddebug
"Create $_strace_wrapper"
299 cat >$_strace_wrapper <<EOF
302 exec strace -D -o /strace.out $ROOTLIBDIR/systemd "\$@"
304 chmod 0755 $_strace_wrapper
308 dracut_install
/sbin
/fsck
*
309 dracut_install
-o /bin
/fsck
*
311 # fskc.reiserfs calls reiserfsck. so, install it
312 dracut_install
-o reiserfsck
316 instmods dm_crypt
=crypto
317 type -P dmeventd
>/dev
/null
&& dracut_install dmeventd
318 inst_libdir_file
"libdevmapper-event.so*"
319 if [[ "$LOOKS_LIKE_DEBIAN" ]]; then
320 # dmsetup installs 55-dm and 60-persistent-storage-dm on Debian/Ubuntu
321 # and since buster/bionic 95-dm-notify.rules
322 # see https://gitlab.com/debian-lvm/lvm2/blob/master/debian/patches/udev.patch
323 inst_rules
55-dm.rules
60-persistent-storage-dm.rules
95-dm-notify.rules
325 inst_rules
10-dm.rules
13-dm-disk.rules
95-dm-notify.rules
330 # install compiled files
331 local _ninja_bin
=$
(type -P ninja ||
type -P ninja-build
)
332 if [[ -z "$_ninja_bin" ]]; then
333 dfatal
"ninja was not found"
336 (set -x; DESTDIR
=$initdir "$_ninja_bin" -C $BUILD_DIR install)
337 # remove unneeded documentation
338 rm -fr $initdir/usr
/share
/{man
,doc
}
339 # we strip binaries since debug symbols increase binaries size a lot
340 # and it could fill the available space
343 [[ "$LOOKS_LIKE_SUSE" ]] && setup_suse
345 # enable debug logging in PID1
346 echo LogLevel
=debug
>> $initdir/etc
/systemd
/system.conf
351 objdump
-p "$_bin" 2>/dev
/null |
awk "/R(UN)?PATH/ { print \"$initdir\" \$2 }" |
paste -sd :
354 install_missing_libraries
() {
355 # install possible missing libraries
356 for i
in $initdir{,/usr
}/{sbin
,bin
}/* $initdir{,/usr
}/lib
/systemd
/*; do
357 LD_LIBRARY_PATH
=$
(get_ldpath
$i) inst_libs
$i
361 create_empty_image
() {
362 rm -f "$TESTDIR/rootdisk.img"
363 # Create the blank file to use as a root filesystem
364 dd if=/dev
/null of
="$TESTDIR/rootdisk.img" bs
=1M seek
=400
365 LOOPDEV
=$
(losetup
--show -P -f $TESTDIR/rootdisk.img
)
366 [ -b "$LOOPDEV" ] ||
return 1
367 echo "LOOPDEV=$LOOPDEV" >> $STATEFILE
368 sfdisk
"$LOOPDEV" <<EOF
375 local _label
="-L systemd"
376 # mkfs.reiserfs doesn't know -L. so, use --label instead
377 [[ "$FSTYPE" == "reiserfs" ]] && _label
="--label systemd"
378 if ! mkfs
-t "${FSTYPE}" ${_label} "${LOOPDEV}p1" -q; then
379 dfatal
"Failed to mkfs -t ${FSTYPE}"
384 check_result_nspawn
() {
386 [[ -e $TESTDIR/nspawn-root
/testok
]] && ret
=0
387 [[ -f $TESTDIR/nspawn-root
/failed
]] && cp -a $TESTDIR/nspawn-root
/failed
$TESTDIR
388 cp -a $TESTDIR/nspawn-root
/var
/log
/journal
$TESTDIR
389 [[ -f $TESTDIR/failed
]] && cat $TESTDIR/failed
390 ls -l $TESTDIR/journal
/*/*.journal
391 test -s $TESTDIR/failed
&& ret
=$
(($ret+1))
392 [ -n "$TIMED_OUT" ] && ret
=$
(($ret+1))
396 # can be overridden in specific test
397 check_result_qemu
() {
399 mkdir
-p $TESTDIR/root
400 mount
${LOOPDEV}p1
$TESTDIR/root
401 [[ -e $TESTDIR/root
/testok
]] && ret
=0
402 [[ -f $TESTDIR/root
/failed
]] && cp -a $TESTDIR/root
/failed
$TESTDIR
403 cp -a $TESTDIR/root
/var
/log
/journal
$TESTDIR
405 [[ -f $TESTDIR/failed
]] && cat $TESTDIR/failed
406 ls -l $TESTDIR/journal
/*/*.journal
407 test -s $TESTDIR/failed
&& ret
=$
(($ret+1))
408 [ -n "$TIMED_OUT" ] && ret
=$
(($ret+1))
413 if [[ "$STRIP_BINARIES" = "no" ]]; then
414 ddebug
"Don't strip binaries"
417 ddebug
"Strip binaries"
418 find "$initdir" -executable -not -path '*/lib/modules/*.ko' -type f |
xargs strip
--strip-unneeded | ddebug
422 mkdir
-p $initdir/etc
/rc.d
423 cat >$initdir/etc
/rc.d
/rc.
local <<EOF
427 chmod 0755 $initdir/etc
/rc.d
/rc.
local
431 ddebug
"install any Execs from the service files"
433 export PKG_CONFIG_PATH
=$BUILD_DIR/src
/core
/
434 systemdsystemunitdir
=$
(pkg-config
--variable=systemdsystemunitdir systemd
)
435 systemduserunitdir
=$
(pkg-config
--variable=systemduserunitdir systemd
)
436 egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/{$systemdsystemunitdir,$systemduserunitdir}/*.service \
438 i
=${i##Exec*=}; i=${i##[@+\!-]}; i=${i##\!}
439 # some {rc,halt}.local scripts and programs are okay to not exist, the rest should
440 inst
$i ||
[ "${i%.local}" != "$i" ] ||
[ "${i%systemd-update-done}" != "$i" ]
445 generate_module_dependencies
() {
446 if [[ -d $initdir/lib
/modules
/$KERNEL_VER ]] && \
447 ! depmod
-a -b "$initdir" $KERNEL_VER; then
448 dfatal
"\"depmod -a $KERNEL_VER\" failed."
453 install_depmod_files
() {
454 inst
/lib
/modules
/$KERNEL_VER/modules.order
455 inst
/lib
/modules
/$KERNEL_VER/modules.
builtin
459 # install plymouth, if found... else remove plymouth service files
460 # if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
461 # PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
462 # /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
463 # dracut_install plymouth plymouthd
465 rm -f $initdir/{usr
/lib
,etc
}/systemd
/system
/plymouth
* $initdir/{usr
/lib
,etc
}/systemd
/system
/*/plymouth
*
469 install_ld_so_conf
() {
470 cp -a /etc
/ld.so.conf
* $initdir/etc
471 ldconfig
-r "$initdir"
474 install_config_files
() {
475 inst
/etc
/sysconfig
/init || true
481 inst
/etc
/nsswitch.conf
482 inst
/etc
/pam.conf || true
483 inst
/etc
/securetty || true
486 # we want an empty environment
487 > $initdir/etc
/environment
488 > $initdir/etc
/machine-id
490 echo systemd-testsuite
> $initdir/etc
/hostname
492 if [[ "$LOOKS_LIKE_SUSE" ]]; then
493 ROOTMOUNT
="/dev/sda1 / ${FSTYPE} rw 0 1"
495 ROOTMOUNT
="LABEL=systemd / ${FSTYPE} rw 0 1"
498 cat >$initdir/etc
/fstab
<<EOF
503 install_basic_tools
() {
504 [[ $BASICTOOLS ]] && dracut_install
$BASICTOOLS
505 dracut_install
-o sushell
506 # in Debian ldconfig is just a shell script wrapper around ldconfig.real
507 dracut_install
-o ldconfig.real
510 install_debug_tools
() {
511 [[ $DEBUGTOOLS ]] && dracut_install
$DEBUGTOOLS
515 # install libnss_files for login
516 NSS_LIBS
=$
(LD_DEBUG
=files getent passwd
2>&1 >/dev
/null |
sed -n '/calling init: .*libnss_/ {s!^.* /!/!; p}')
517 dracut_install
$NSS_LIBS
521 inst
$ROOTLIBDIR/system
/dbus.socket
522 inst
$ROOTLIBDIR/system
/dbus.service
525 /etc
/dbus-1
/usr
/share
/dbus-1
-xtype f \
526 |
while read file; do
533 if [[ "$LOOKS_LIKE_DEBIAN" ]] && type -p dpkg-architecture
&>/dev
/null
; then
534 find "/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/security" -xtype f
536 find /lib
*/security
-xtype f
538 find /etc
/pam.d
/etc
/security
-xtype f
539 ) |
while read file; do
543 # pam_unix depends on unix_chkpwd.
544 # see http://www.linux-pam.org/Linux-PAM-html/sag-pam_unix.html
545 dracut_install
-o unix_chkpwd
547 [[ "$LOOKS_LIKE_DEBIAN" ]] &&
548 cp /etc
/pam.d
/systemd-user
$initdir/etc
/pam.d
/
550 # set empty root password for easy debugging
551 sed -i 's/^root:x:/root::/' $initdir/etc
/passwd
556 /usr
/lib
/kbd
/keymaps
/include
/* \
557 /usr
/lib
/kbd
/keymaps
/i386
/include
/* \
558 /usr
/lib
/kbd
/keymaps
/i386
/qwerty
/us.
*; do
559 [[ -f $i ]] ||
continue
566 /usr
/lib
/kbd
/consolefonts
/eurlatgr
* \
567 /usr
/lib
/kbd
/consolefonts
/latarcyrheb-sun16
*; do
568 [[ -f $i ]] ||
continue
574 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
575 [ -f ${_terminfodir}/l
/linux
] && break
577 dracut_install
-o ${_terminfodir}/l
/linux
581 cp $TEST_BASE_DIR/testsuite.target
$initdir/etc
/systemd
/system
/
582 cp $TEST_BASE_DIR/end.service
$initdir/etc
/systemd
/system
/
584 mkdir
-p $initdir/etc
/systemd
/system
/testsuite.target.wants
585 ln -fs $TEST_BASE_DIR/testsuite.service
$initdir/etc
/systemd
/system
/testsuite.target.wants
/testsuite.service
586 ln -fs $TEST_BASE_DIR/end.service
$initdir/etc
/systemd
/system
/testsuite.target.wants
/end.service
588 # make the testsuite the default target
589 ln -fs testsuite.target
$initdir/etc
/systemd
/system
/default.target
592 setup_nspawn_root
() {
593 rm -fr $TESTDIR/nspawn-root
594 ddebug
"cp -ar $initdir $TESTDIR/nspawn-root"
595 cp -ar $initdir $TESTDIR/nspawn-root
596 # we don't mount in the nspawn root
597 rm -f $TESTDIR/nspawn-root
/etc
/fstab
601 mkdir
-p $initdir/run
602 mkdir
-p $initdir/etc
/systemd
/system
603 mkdir
-p $initdir/var
/log
/journal
605 for d
in usr
/bin usr
/sbin bin etc lib
"$libdir" sbin tmp usr var var
/log dev proc sys sysroot root run run
/lock run
/initramfs
; do
606 if [ -L "/$d" ]; then
613 ln -sfn /run
"$initdir/var/run"
614 ln -sfn /run
/lock
"$initdir/var/lock"
619 local _so_regex
='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
622 LC_ALL
=C ldd
"$_bin" 2>/dev
/null |
while read _line
; do
623 [[ $_line = 'not a dynamic executable' ]] && break
625 if [[ $_line =~
$_so_regex ]]; then
626 _file
=${BASH_REMATCH[1]}
627 [[ -e ${initdir}/$_file ]] && continue
628 inst_library
"$_file"
632 if [[ $_line =~ not\ found
]]; then
633 dfatal
"Missing a shared library required by $_bin."
634 dfatal
"Run \"ldd $_bin\" to find out what it is."
636 dfatal
"dracut cannot create an initrd."
643 [[ -e $STATEFILE ]] && .
$STATEFILE
644 if [[ -z "$TESTDIR" ]] ||
[[ ! -d "$TESTDIR" ]]; then
645 TESTDIR
=$
(mktemp
--tmpdir=/var
/tmp
-d -t systemd-test.XXXXXX
)
646 echo "TESTDIR=\"$TESTDIR\"" > $STATEFILE
652 initdir
=$TESTDIR/root
656 ## @brief Converts numeric logging level to the first letter of level name.
658 # @param lvl Numeric logging level in range from 1 to 6.
659 # @retval 1 if @a lvl is out of range.
660 # @retval 0 if @a lvl is correct.
661 # @result Echoes first letter of level name.
674 ## @brief Internal helper function for _do_dlog()
676 # @param lvl Numeric logging level.
677 # @param msg Message.
678 # @retval 0 It's always returned, even if logging failed.
680 # @note This function is not supposed to be called manually. Please use
681 # dtrace(), ddebug(), or others instead which wrap this one.
683 # This function calls _do_dlog() either with parameter msg, or if
684 # none is given, it will read standard input and will use every line as
688 # dwarn "This is a warning"
689 # echo "This is a warning" | dwarn
693 [ -z "$LOG_LEVEL" ] && return 0
694 [ $1 -le $LOG_LEVEL ] ||
return 0
695 local lvl
="$1"; shift
696 local lvlc
=$
(_lvl2char
"$lvl") ||
return 0
698 if [ $# -ge 1 ]; then
702 echo "$lvlc: " "$line"
707 ## @brief Logs message at TRACE level (6)
709 # @param msg Message.
710 # @retval 0 It's always returned, even if logging failed.
714 [ -n "$debug" ] && set -x ||
:
717 ## @brief Logs message at DEBUG level (5)
719 # @param msg Message.
720 # @retval 0 It's always returned, even if logging failed.
724 # [ -n "$debug" ] && set -x || :
727 ## @brief Logs message at INFO level (4)
729 # @param msg Message.
730 # @retval 0 It's always returned, even if logging failed.
734 [ -n "$debug" ] && set -x ||
:
737 ## @brief Logs message at WARN level (3)
739 # @param msg Message.
740 # @retval 0 It's always returned, even if logging failed.
744 [ -n "$debug" ] && set -x ||
:
747 ## @brief Logs message at ERROR level (2)
749 # @param msg Message.
750 # @retval 0 It's always returned, even if logging failed.
754 # [ -n "$debug" ] && set -x || :
757 ## @brief Logs message at FATAL level (1)
759 # @param msg Message.
760 # @retval 0 It's always returned, even if logging failed.
764 [ -n "$debug" ] && set -x ||
:
768 # Generic substring function. If $2 is in $1, return 0.
769 strstr
() { [ "${1#*$2*}" != "$1" ]; }
771 # normalize_path <path>
772 # Prints the normalized path, where it removes any duplicated
773 # and trailing slashes.
775 # $ normalize_path ///test/test//
779 set -- "${1//+(\/)//}"
784 # convert_abs_rel <from> <to>
785 # Prints the relative path, when creating a symlink to <to> from <from>.
787 # $ convert_abs_rel /usr/bin/test /bin/test-2
789 # $ ln -s $(convert_abs_rel /usr/bin/test /bin/test-2) /usr/bin/test
791 local __current __absolute __abssize __cursize __newpath
794 set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
796 # corner case #1 - self looping link
797 [[ "$1" == "$2" ]] && { echo "${1##*/}"; return; }
799 # corner case #2 - own dir link
800 [[ "${1%/*}" == "$2" ]] && { echo "."; return; }
802 IFS
="/" __current
=($1)
803 IFS
="/" __absolute
=($2)
805 __abssize
=${#__absolute[@]}
806 __cursize
=${#__current[@]}
808 while [[ ${__absolute[__level]} == ${__current[__level]} ]]
811 if (( __level
> __abssize || __level
> __cursize
))
817 for ((__i
= __level
; __i
< __cursize-1
; __i
++))
821 __newpath
=$__newpath"/"
823 __newpath
=$__newpath".."
826 for ((__i
= __level
; __i
< __abssize
; __i
++))
828 if [[ -n $__newpath ]]
830 __newpath
=$__newpath"/"
832 __newpath
=$__newpath${__absolute[__i]}
839 # Install a directory, keeping symlinks as on the original system.
840 # Example: if /lib points to /lib64 on the host, "inst_dir /lib/file"
841 # will create ${initdir}/lib64, ${initdir}/lib64/file,
842 # and a symlink ${initdir}/lib -> lib64.
844 [[ -e ${initdir}/"$1" ]] && return 0 # already there
846 local _dir
="$1" _part
="${1%/*}" _file
847 while [[ "$_part" != "${_part%/*}" ]] && ! [[ -e "${initdir}/${_part}" ]]; do
852 # iterate over parent directories
853 for _file
in $_dir; do
854 [[ -e "${initdir}/$_file" ]] && continue
855 if [[ -L $_file ]]; then
856 inst_symlink
"$_file"
859 mkdir
-m 0755 -p "${initdir}/$_file" ||
return 1
860 [[ -e "$_file" ]] && chmod --reference="$_file" "${initdir}/$_file"
861 chmod u
+w
"${initdir}/$_file"
866 # $1 = file to copy to ramdisk
867 # $2 (optional) Name for the file on the ramdisk
868 # Location of the image dir is assumed to be $initdir
869 # We never overwrite the target if it exists.
871 [[ -f "$1" ]] ||
return 1
872 strstr
"$1" "/" ||
return 1
874 local _src
=$1 target
="${2:-$1}"
875 if ! [[ -d ${initdir}/$target ]]; then
876 [[ -e ${initdir}/$target ]] && return 0
877 [[ -L ${initdir}/$target ]] && return 0
878 [[ -d "${initdir}/${target%/*}" ]] || inst_dir "${target%/*}"
880 # install checksum files also
881 if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then
882 inst
"${_src%/*}/.${_src##*/}.hmac" "${target%/*}/.${target##*/}.hmac"
884 ddebug
"Installing $_src"
885 cp --sparse=always
-pfL "$_src" "${initdir}/$target"
888 # find symlinks linked to given library file
890 # Function searches for symlinks by stripping version numbers appended to
891 # library filename, checks if it points to the same target and finally
892 # prints the list of symlinks to stdout.
895 # rev_lib_symlinks libfoo.so.8.1
896 # output: libfoo.so.8 libfoo.so
897 # (Only if libfoo.so.8 and libfoo.so exists on host system.)
899 [[ ! $1 ]] && return 0
901 local fn
="$1" orig
="$(readlink -f "$1")" links
=''
903 [[ ${fn} =~ .
*\.so\..
* ]] ||
return 1
905 until [[ ${fn##*.} == so
]]; do
907 [[ -L ${fn} && $(readlink -f "${fn}") == ${orig} ]] && links+=" ${fn}"
913 # Same as above, but specialized to handle dynamic libraries.
914 # It handles making symlinks according to how the original library
917 local _src="$1" _dest=${2:-$1} _lib _reallib _symlink
918 strstr "$1" "/" || return 1
919 [[ -e $initdir/$_dest ]] && return 0
920 if [[ -L $_src ]]; then
921 # install checksum files also
922 if [[ -e "${_src%/*}/.
${_src##*/}.hmac
" ]]; then
923 inst "${_src%/*}/.${_src##*/}.hmac" "${_dest%/*}/.${_dest##*/}.hmac
"
925 _reallib=$(readlink -f "$_src")
926 inst_simple "$_reallib" "$_reallib"
927 inst_dir "${_dest%/*}"
928 [[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/}
929 ln -sfn $
(convert_abs_rel
"${_dest}" "${_reallib}") "${initdir}/${_dest}"
931 inst_simple
"$_src" "$_dest"
934 # Create additional symlinks. See rev_symlinks description.
935 for _symlink
in $
(rev_lib_symlinks
$_src) $
(rev_lib_symlinks
$_reallib); do
936 [[ -e $initdir/$_symlink ]] ||
{
937 ddebug
"Creating extra symlink: $_symlink"
938 inst_symlink
$_symlink
943 # find a binary. If we were not passed the full path directly,
944 # search in the usual places to find the binary.
946 if [[ -z ${1##/*} ]]; then
947 if [[ -x $1 ]] ||
{ strstr
"$1" ".so" && ldd
$1 &>/dev
/null
; }; then
956 # Same as above, but specialized to install binary executables.
957 # Install binary executable, and all shared library dependencies, if any.
960 _bin
=$
(find_binary
"$1") ||
return 1
962 [[ -e $initdir/$_target ]] && return 0
963 [[ -L $_bin ]] && inst_symlink
$_bin $_target && return 0
965 local _so_regex
='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
967 LC_ALL
=C ldd
"$_bin" 2>/dev
/null |
while read _line
; do
968 [[ $_line = 'not a dynamic executable' ]] && break
970 if [[ $_line =~
$_so_regex ]]; then
971 _file
=${BASH_REMATCH[1]}
972 [[ -e ${initdir}/$_file ]] && continue
973 inst_library
"$_file"
977 if [[ $_line =~ not\ found
]]; then
978 dfatal
"Missing a shared library required by $_bin."
979 dfatal
"Run \"ldd $_bin\" to find out what it is."
981 dfatal
"dracut cannot create an initrd."
985 inst_simple
"$_bin" "$_target"
988 # same as above, except for shell scripts.
989 # If your shell script does not start with shebang, it is not a shell script.
992 _bin
=$
(find_binary
"$1") ||
return 1
994 local _line _shebang_regex
995 read -r -n 80 _line
<"$_bin"
996 # If debug is set, clean unprintable chars to prevent messing up the term
997 [[ $debug ]] && _line
=$
(echo -n "$_line" |
tr -c -d '[:print:][:space:]')
998 _shebang_regex
='(#! *)(/[^ ]+).*'
999 [[ $_line =~
$_shebang_regex ]] ||
return 1
1000 inst
"${BASH_REMATCH[2]}" && inst_simple
"$_bin" "$@"
1003 # same as above, but specialized for symlinks
1005 local _src
=$1 _target
=${2:-$1} _realsrc
1006 strstr
"$1" "/" ||
return 1
1007 [[ -L $1 ]] ||
return 1
1008 [[ -L $initdir/$_target ]] && return 0
1009 _realsrc
=$
(readlink
-f "$_src")
1010 if ! [[ -e $initdir/$_realsrc ]]; then
1011 if [[ -d $_realsrc ]]; then
1012 inst_dir
"$_realsrc"
1017 [[ ! -e $initdir/${_target%/*} ]] && inst_dir
"${_target%/*}"
1018 [[ -d ${_target%/*} ]] && _target=$(readlink -f ${_target%/*})/${_target##*/}
1019 ln -sfn $
(convert_abs_rel
"${_target}" "${_realsrc}") "$initdir/$_target"
1022 # attempt to install any programs specified in a udev rule
1023 inst_rule_programs
() {
1026 if grep -qE 'PROGRAM==?"[^ "]+' "$1"; then
1027 for _prog
in $
(grep -E 'PROGRAM==?"[^ "]+' "$1" |
sed -r 's/.*PROGRAM==?"([^ "]+).*/\1/'); do
1028 if [ -x /lib
/udev
/$_prog ]; then
1029 _bin
=/lib
/udev
/$_prog
1031 _bin
=$
(find_binary
"$_prog") ||
{
1032 dinfo
"Skipping program $_prog using in udev rule $(basename $1) as it cannot be found"
1037 #dinfo "Installing $_bin due to it's use in the udev rule $(basename $1)"
1038 dracut_install
"$_bin"
1043 # udev rules always get installed in the same place, so
1044 # create a function to install them to make life simpler.
1046 local _target
=/etc
/udev
/rules.d _rule _found
1048 inst_dir
"/lib/udev/rules.d"
1050 for _rule
in "$@"; do
1051 if [ "${rule#/}" = "$rule" ]; then
1052 for r
in /lib
/udev
/rules.d
/etc
/udev
/rules.d
; do
1053 if [[ -f $r/$_rule ]]; then
1055 inst_simple
"$_found"
1056 inst_rule_programs
"$_found"
1060 for r
in '' .
/ $dracutbasedir/rules.d
/; do
1061 if [[ -f ${r}$_rule ]]; then
1063 inst_simple
"$_found" "$_target/${_found##*/}"
1064 inst_rule_programs
"$_found"
1067 [[ $_found ]] || dinfo
"Skipping udev rule: $_rule"
1072 # general purpose installation function
1073 # Same args as above.
1079 2) [[ ! $initdir && -d $2 ]] && export initdir
=$2
1080 [[ $initdir = $2 ]] && set $1;;
1081 3) [[ -z $initdir ]] && export initdir
=$2
1083 *) dfatal
"inst only takes 1 or 2 or 3 arguments"
1086 for _x
in inst_symlink inst_script inst_binary inst_simple
; do
1087 $_x "$@" && return 0
1092 # install any of listed files
1094 # If first argument is '-d' and second some destination path, first accessible
1095 # source is installed into this path, otherwise it will installed in the same
1096 # path as source. If none of listed files was installed, function return 1.
1097 # On first successful installation it returns with 0 status.
1101 # inst_any -d /bin/foo /bin/bar /bin/baz
1103 # Lets assume that /bin/baz exists, so it will be installed as /bin/foo in
1108 [[ $1 = '-d' ]] && to
="$2" && shift 2
1111 if [[ -e $f ]]; then
1112 [[ $to ]] && inst
"$f" "$to" && return 0
1113 inst
"$f" && return 0
1120 # dracut_install [-o ] <file> [<file> ... ]
1121 # Install <file> to the initramfs image
1122 # -o optionally install the <file> and don't fail, if it is not there
1125 if [[ $1 = '-o' ]]; then
1129 while (($# > 0)); do
1130 if ! inst
"$1" ; then
1131 if [[ $_optional = yes ]]; then
1132 dinfo
"Skipping program $1 as it cannot be found and is" \
1133 "flagged to be optional"
1135 dfatal
"Failed to install $1"
1143 # Install a single kernel module along with any firmware it may require.
1144 # $1 = full path to kernel module to install
1145 install_kmod_with_fw
() {
1146 # no need to go further if the module is already installed
1148 [[ -e "${initdir}/lib/modules/$KERNEL_VER/${1##*/lib/modules/$KERNEL_VER/}" ]] \
1151 [[ -e "$initdir/.kernelmodseen/${1##*/}" ]] && return 0
1153 if [[ $omit_drivers ]]; then
1154 local _kmod
=${1##*/}
1157 if [[ "$_kmod" =~
$omit_drivers ]]; then
1158 dinfo
"Omitting driver $_kmod"
1161 if [[ "${1##*/lib/modules/$KERNEL_VER/}" =~
$omit_drivers ]]; then
1162 dinfo
"Omitting driver $_kmod"
1167 [ -d "$initdir/.kernelmodseen" ] && \
1168 > "$initdir/.kernelmodseen/${1##*/}"
1170 inst_simple
"$1" "/lib/modules/$KERNEL_VER/${1##*/lib/modules/$KERNEL_VER/}" \
1173 local _modname
=${1##*/} _fwdir _found _fw
1174 _modname
=${_modname%.ko*}
1175 for _fw
in $
(modinfo
-k $KERNEL_VER -F firmware
$1 2>/dev
/null
); do
1177 for _fwdir
in $fw_dir; do
1178 if [[ -d $_fwdir && -f $_fwdir/$_fw ]]; then
1179 inst_simple
"$_fwdir/$_fw" "/lib/firmware/$_fw"
1183 if [[ $_found != yes ]]; then
1184 if ! grep -qe "\<${_modname//-/_}\>" /proc
/modules
; then
1185 dinfo
"Possible missing firmware \"${_fw}\" for kernel module" \
1186 "\"${_modname}.ko\""
1188 dwarn
"Possible missing firmware \"${_fw}\" for kernel module" \
1189 "\"${_modname}.ko\""
1196 # Do something with all the dependencies of a kernel module.
1197 # Note that kernel modules depend on themselves using the technique we use
1198 # $1 = function to call for each dependency we find
1199 # It will be passed the full path to the found kernel module
1200 # $2 = module to get dependencies for
1201 # rest of args = arguments to modprobe
1202 # _fderr specifies FD passed from surrounding scope
1203 for_each_kmod_dep
() {
1204 local _func
=$1 _kmod
=$2 _cmd _modpath _options _found
=0
1206 modprobe
"$@" --ignore-install --show-depends $_kmod 2>&${_fderr} |
(
1207 while read _cmd _modpath _options
; do
1208 [[ $_cmd = insmod
]] ||
continue
1209 $_func ${_modpath} ||
exit $?
1212 [[ $_found -eq 0 ]] && exit 1
1217 # filter kernel modules to install certain modules that meet specific
1219 # $1 = search only in subdirectory of /kernel/$1
1220 # $2 = function to call with module name to filter.
1221 # This function will be passed the full path to the module to test.
1222 # The behavior of this function can vary depending on whether $hostonly is set.
1223 # If it is, we will only look at modules that are already in memory.
1224 # If it is not, we will look at all kernel modules
1225 # This function returns the full filenames of modules that match $1
1226 filter_kernel_modules_by_path
() (
1227 local _modname _filtercmd
1228 if ! [[ $hostonly ]]; then
1229 _filtercmd
='find "$KERNEL_MODS/kernel/$1" "$KERNEL_MODS/extra"'
1230 _filtercmd
+=' "$KERNEL_MODS/weak-updates" -name "*.ko" -o -name "*.ko.gz"'
1231 _filtercmd
+=' -o -name "*.ko.xz"'
1232 _filtercmd
+=' 2>/dev/null'
1234 _filtercmd
='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename '
1235 _filtercmd
+='-k $KERNEL_VER 2>/dev/null'
1237 for _modname
in $
(eval $_filtercmd); do
1239 *.ko
) "$2" "$_modname" && echo "$_modname";;
1240 *.ko.gz
) gzip -dc "$_modname" > $initdir/$$.ko
1241 $2 $initdir/$$.ko
&& echo "$_modname"
1242 rm -f $initdir/$$.ko
1244 *.ko.xz
) xz
-dc "$_modname" > $initdir/$$.ko
1245 $2 $initdir/$$.ko
&& echo "$_modname"
1246 rm -f $initdir/$$.ko
1251 find_kernel_modules_by_path
() (
1252 if ! [[ $hostonly ]]; then
1253 find "$KERNEL_MODS/kernel/$1" "$KERNEL_MODS/extra" "$KERNEL_MODS/weak-updates" \
1254 -name "*.ko" -o -name "*.ko.gz" -o -name "*.ko.xz" 2>/dev
/null
1256 cut
-d " " -f 1 </proc
/modules \
1257 |
xargs modinfo
-F filename
-k $KERNEL_VER 2>/dev
/null
1261 filter_kernel_modules
() {
1262 filter_kernel_modules_by_path drivers
"$1"
1265 find_kernel_modules
() {
1266 find_kernel_modules_by_path drivers
1269 # instmods [-c] <kernel module> [<kernel module> ... ]
1270 # instmods [-c] <kernel subsystem>
1271 # install kernel modules along with all their dependencies.
1272 # <kernel subsystem> can be e.g. "=block" or "=drivers/usb/storage"
1274 [[ $no_kernel = yes ]] && return
1275 # called [sub]functions inherit _fderr
1278 if [[ $1 = '-c' ]]; then
1283 function inst1mod
() {
1284 local _ret
=0 _mod
="$1"
1287 if [ -f $KERNEL_MODS/modules.
${_mod#=} ]; then
1288 ( [[ "$_mpargs" ]] && echo $_mpargs
1289 cat "${KERNEL_MODS}/modules.${_mod#=}" ) \
1292 ( [[ "$_mpargs" ]] && echo $_mpargs
1293 find "$KERNEL_MODS" -path "*/${_mod#=}/*" -printf '%f\n' ) \
1297 --*) _mpargs
+=" $_mod" ;;
1298 i2o_scsi
) return ;; # Do not load this diagnostic-only module
1301 # if we are already installed, skip this module and go on
1303 [[ -f "$initdir/.kernelmodseen/${_mod%.ko}.ko" ]] && return
1305 if [[ $omit_drivers ]] && [[ "$1" =~
$omit_drivers ]]; then
1306 dinfo
"Omitting driver ${_mod##$KERNEL_MODS}"
1309 # If we are building a host-specific initramfs and this
1310 # module is not already loaded, move on to the next one.
1311 [[ $hostonly ]] && ! grep -qe "\<${_mod//-/_}\>" /proc
/modules \
1312 && ! echo $add_drivers |
grep -qe "\<${_mod}\>" \
1315 # We use '-d' option in modprobe only if modules prefix path
1316 # differs from default '/'. This allows us to use Dracut with
1317 # old version of modprobe which doesn't have '-d' option.
1318 local _moddirname
=${KERNEL_MODS%%/lib/modules/*}
1319 [[ -n ${_moddirname} ]] && _moddirname
="-d ${_moddirname}/"
1321 # ok, load the module, all its dependencies, and any firmware
1323 for_each_kmod_dep install_kmod_with_fw
$_mod \
1324 --set-version $KERNEL_VER ${_moddirname} $_mpargs
1331 function instmods_1
() {
1333 if (($# == 0)); then # filenames from stdin
1335 inst1mod
"${_mod%.ko*}" ||
{
1336 if [ "$_check" = "yes" ]; then
1337 dfatal
"Failed to install $_mod"
1343 while (($# > 0)); do # filenames as arguments
1344 inst1mod
${1%.ko*} ||
{
1345 if [ "$_check" = "yes" ]; then
1346 dfatal
"Failed to install $1"
1355 local _ret _filter_not_found
='FATAL: Module .* not found.'
1357 # Capture all stderr from modprobe to _fderr. We could use {var}>...
1358 # redirections, but that would make dracut require bash4 at least.
1359 eval "( instmods_1 \"\$@\" ) ${_fderr}>&1" \
1360 |
while read line
; do [[ "$line" =~
$_filter_not_found ]] && echo $line ||
echo $line >&2 ;done | derror
1366 # inst_libdir_file [-n <pattern>] <file> [<file>...]
1367 # Install a <file> located on a lib directory to the initramfs image
1368 # -n <pattern> install non-matching files
1369 inst_libdir_file
() {
1370 if [[ "$1" == "-n" ]]; then
1373 for _dir
in $libdirs; do
1375 for _f
in "$_dir"/$_i; do
1376 [[ "$_i" =~
$_pattern ]] ||
continue
1377 [[ -e "$_i" ]] && dracut_install
"$_i"
1382 for _dir
in $libdirs; do
1384 for _f
in "$_dir"/$_i; do
1385 [[ -e "$_f" ]] && dracut_install
"$_f"
1393 ln -fs ..
/usr
/bin
/systemctl
$initdir/bin
/
1394 ln -fs ..
/usr
/lib
/systemd
$initdir/lib
/
1395 inst_simple
"/usr/lib/systemd/system/haveged.service"
1398 # can be overridden in specific test
1400 umount
$TESTDIR/root
2>/dev
/null || true
1401 [[ $LOOPDEV ]] && losetup
-d $LOOPDEV || true
1406 if [ -z "$TEST_NO_QEMU" ]; then
1408 check_result_qemu ||
return 1
1410 dwarn
"can't run QEMU, skipping"
1413 if [ -z "$TEST_NO_NSPAWN" ]; then
1415 check_result_nspawn ||
return 1
1417 dwarn
"can't run systemd-nspawn, skipping"
1424 if [[ $UID != "0" ]]; then
1425 echo "TEST: $TEST_DESCRIPTION [SKIPPED]: not root" >&2
1430 [[ $libdir ]] ||
for libdir
in /lib64
/lib
; do
1431 [[ -d $libdir ]] && libdirs
+=" $libdir" && break
1434 [[ $usrlibdir ]] ||
for usrlibdir
in /usr
/lib64
/usr
/lib
; do
1435 [[ -d $usrlibdir ]] && libdirs
+=" $usrlibdir" && break
1438 mkdir
-p "$STATEDIR"
1443 while (($# > 0)); do
1446 echo "TEST RUN: $TEST_DESCRIPTION"
1448 echo "TEST RUN: $TEST_DESCRIPTION [OK]"
1450 echo "TEST RUN: $TEST_DESCRIPTION [FAILED]"
1454 echo "TEST SETUP: $TEST_DESCRIPTION"
1458 echo "TEST CLEANUP: $TEST_DESCRIPTION"
1465 echo -n "TEST: $TEST_DESCRIPTION ";
1467 test_setup
&& test_run
1473 ) </dev
/null
>"$TESTLOG" 2>&1 || ret
=$?
1474 if [ $ret -eq 0 ]; then