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" ]] && 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
33 # Debian and Gentoo call it kvm
34 [ "$QEMU_BIN" ] || QEMU_BIN
=$
(which -a kvm qemu-kvm
2>/dev
/null |
grep '^/' -m1)
36 [ "$ARCH" ] || ARCH
=$
(uname
-m)
39 # QEMU's own build system calls it qemu-system-x86_64
40 [ "$QEMU_BIN" ] || QEMU_BIN
=$
(which -a qemu-system-x86_64
2>/dev
/null |
grep '^/' -m1)
43 # new i386 version of QEMU
44 [ "$QEMU_BIN" ] || QEMU_BIN
=$
(which -a qemu-system-i386
2>/dev
/null |
grep '^/' -m1)
46 # i386 version of QEMU
47 [ "$QEMU_BIN" ] || QEMU_BIN
=$
(which -a qemu
2>/dev
/null |
grep '^/' -m1)
50 [ "$QEMU_BIN" ] || QEMU_BIN
=$
(which -a qemu-system-
$ARCH 2>/dev
/null |
grep '^/' -m1)
54 if [ ! -e "$QEMU_BIN" ]; then
55 echo "Could not find a suitable QEMU binary" >&2
60 # Return 0 if QEMU did run (then you must check the result state/logs for actual
61 # success), or 1 if QEMU is not available.
63 if [ -f /etc
/machine-id
]; then
64 read MACHINE_ID
< /etc
/machine-id
65 [ -z "$INITRD" ] && [ -e "$EFI_MOUNT/$MACHINE_ID/$KERNEL_VER/initrd" ] \
66 && INITRD
="$EFI_MOUNT/$MACHINE_ID/$KERNEL_VER/initrd"
67 [ -z "$KERNEL_BIN" ] && [ -e "$EFI_MOUNT/$MACHINE_ID/$KERNEL_VER/linux" ] \
68 && KERNEL_BIN
="$EFI_MOUNT/$MACHINE_ID/$KERNEL_VER/linux"
71 if [[ ! "$KERNEL_BIN" ]]; then
72 if [[ "$LOOKS_LIKE_ARCH" ]]; then
73 KERNEL_BIN
=/boot
/vmlinuz-linux
75 KERNEL_BIN
=/boot
/vmlinuz-
$KERNEL_VER
79 default_fedora_initrd
=/boot
/initramfs-
${KERNEL_VER}.img
80 default_debian_initrd
=/boot
/initrd.img-
${KERNEL_VER}
81 default_arch_initrd
=/boot
/initramfs-linux.img
82 default_suse_initrd
=/boot
/initrd-
${KERNEL_VER}
83 if [[ ! "$INITRD" ]]; then
84 if [[ -e "$default_fedora_initrd" ]]; then
85 INITRD
="$default_fedora_initrd"
86 elif [[ "$LOOKS_LIKE_DEBIAN" && -e "$default_debian_initrd" ]]; then
87 INITRD
="$default_debian_initrd"
88 elif [[ "$LOOKS_LIKE_ARCH" && -e "$default_arch_initrd" ]]; then
89 INITRD
="$default_arch_initrd"
90 elif [[ "$LOOKS_LIKE_SUSE" && -e "$default_suse_initrd" ]]; then
91 INITRD
="$default_suse_initrd"
95 [ "$QEMU_SMP" ] || QEMU_SMP
=1
97 find_qemu_bin ||
return 1
100 if [[ "$UNIFIED_CGROUP_HIERARCHY" = "yes" ]]; then
101 _cgroup_args
="systemd.unified_cgroup_hierarchy=yes"
102 elif [[ "$UNIFIED_CGROUP_HIERARCHY" = "no" ]]; then
103 _cgroup_args
="systemd.unified_cgroup_hierarchy=no systemd.legacy_systemd_cgroup_controller=yes"
104 elif [[ "$UNIFIED_CGROUP_HIERARCHY" = "hybrid" ]]; then
105 _cgroup_args
="systemd.unified_cgroup_hierarchy=no systemd.legacy_systemd_cgroup_controller=no"
106 elif [[ "$UNIFIED_CGROUP_HIERARCHY" != "default" ]]; then
107 dfatal
"Unknown UNIFIED_CGROUP_HIERARCHY. Got $UNIFIED_CGROUP_HIERARCHY, expected [yes|no|hybrid|default]"
111 if [[ "$LOOKS_LIKE_SUSE" ]]; then
112 PARAMS
+="rd.hostonly=0"
117 KERNEL_APPEND
="$PARAMS \
121 init=$ROOTLIBDIR/systemd \
128 QEMU_OPTIONS
="-smp $QEMU_SMP \
132 -kernel $KERNEL_BIN \
133 -drive format=raw,cache=unsafe,file=${TESTDIR}/rootdisk.img \
136 if [[ "$INITRD" && "$SKIP_INITRD" != "yes" ]]; then
137 QEMU_OPTIONS
="$QEMU_OPTIONS -initrd $INITRD"
140 if [ -c /dev
/kvm
]; then
141 QEMU_OPTIONS
="$QEMU_OPTIONS -machine accel=kvm -enable-kvm -cpu host"
144 if [[ "$QEMU_TIMEOUT" != "infinity" ]]; then
145 QEMU_BIN
="timeout --foreground $QEMU_TIMEOUT $QEMU_BIN"
147 (set -x; $QEMU_BIN $QEMU_OPTIONS -append "$KERNEL_APPEND")
149 if [ "$rc" = 124 ] && [ "$QEMU_TIMEOUT" != "infinity" ]; then
150 derror
"test timed out after $QEMU_TIMEOUT s"
153 [ "$rc" != 0 ] && derror
"QEMU failed with exit code $rc"
158 # Return 0 if nspawn did run (then you must check the result state/logs for actual
159 # success), or 1 if nspawn is not available.
161 [[ -d /run
/systemd
/system
]] ||
return 1
163 local _nspawn_cmd
="$BUILD_DIR/systemd-nspawn --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND"
164 if [[ "$NSPAWN_TIMEOUT" != "infinity" ]]; then
165 _nspawn_cmd
="timeout --foreground $NSPAWN_TIMEOUT $_nspawn_cmd"
168 if [[ "$UNIFIED_CGROUP_HIERARCHY" = "hybrid" ]]; then
169 dwarn
"nspawn doesn't support UNIFIED_CGROUP_HIERARCHY=hybrid, skipping"
171 elif [[ "$UNIFIED_CGROUP_HIERARCHY" = "yes" ||
"$UNIFIED_CGROUP_HIERARCHY" = "no" ]]; then
172 _nspawn_cmd
="env UNIFIED_CGROUP_HIERARCHY=$UNIFIED_CGROUP_HIERARCHY $_nspawn_cmd"
173 elif [[ "$UNIFIED_CGROUP_HIERARCHY" = "default" ]]; then
174 _nspawn_cmd
="env --unset=UNIFIED_CGROUP_HIERARCHY $_nspawn_cmd"
176 dfatal
"Unknown UNIFIED_CGROUP_HIERARCHY. Got $UNIFIED_CGROUP_HIERARCHY, expected [yes|no|hybrid|default]"
180 (set -x; $_nspawn_cmd)
182 if [ "$rc" = 124 ] && [ "$NSPAWN_TIMEOUT" != "infinity" ]; then
183 derror
"test timed out after $NSPAWN_TIMEOUT s"
186 [ "$rc" != 0 ] && derror
"nspawn failed with exit code $rc"
191 setup_basic_environment
() {
192 # create the basic filesystem layout
196 install_missing_libraries
214 generate_module_dependencies
218 # don't forget KERNEL_APPEND='... selinux=1 ...'
219 if [[ "$SETUP_SELINUX" != "yes" ]]; then
220 ddebug
"Don't setup SELinux"
223 ddebug
"Setup SELinux"
224 local _conf_dir
=/etc
/selinux
225 local _fixfiles_tools
="bash uname cat sort uniq awk grep egrep head expr find rm secon setfiles"
227 rm -rf $initdir/$_conf_dir
228 if ! cp -ar $_conf_dir $initdir/$_conf_dir; then
229 dfatal
"Failed to copy $_conf_dir"
233 cat <<EOF >$initdir/etc/systemd/system/autorelabel.service
235 Description=Relabel all filesystems
236 DefaultDependencies=no
237 Requires=local-fs.target
238 Conflicts=shutdown.target
239 After=local-fs.target
240 Before=sysinit.target shutdown.target
241 ConditionSecurity=selinux
242 ConditionPathExists=|/.autorelabel
245 ExecStart=/bin/sh -x -c 'echo 0 >/sys/fs/selinux/enforce && fixfiles -f -F relabel && rm /.autorelabel && systemctl --force reboot'
251 touch $initdir/.autorelabel
252 mkdir
-p $initdir/etc
/systemd
/system
/basic.target.wants
253 ln -fs autorelabel.service
$initdir/etc
/systemd
/system
/basic.target.wants
/autorelabel.service
255 dracut_install
$_fixfiles_tools
256 dracut_install fixfiles
257 dracut_install sestatus
261 if ! type -p valgrind
; then
262 dfatal
"Failed to install valgrind"
266 local _valgrind_bins
=$
(strace
-e execve valgrind
/bin
/true
2>&1 >/dev
/null | perl
-lne 'print $1 if /^execve\("([^"]+)"/')
267 dracut_install
$_valgrind_bins
269 local _valgrind_libs
=$
(LD_DEBUG
=files valgrind
/bin
/true
2>&1 >/dev
/null | perl
-lne 'print $1 if m{calling init: (/.*vgpreload_.*)}')
270 dracut_install
$_valgrind_libs
272 local _valgrind_dbg_and_supp
=$
(
273 strace
-e open valgrind
/bin
/true
2>&1 >/dev
/null |
274 perl
-lne 'if (my ($fname) = /^open\("([^"]+).*= (?!-)\d+/) { print $fname if $fname =~ /debug|\.supp$/ }'
276 dracut_install
$_valgrind_dbg_and_supp
279 create_valgrind_wrapper
() {
280 local _valgrind_wrapper
=$initdir/$ROOTLIBDIR/systemd-under-valgrind
281 ddebug
"Create $_valgrind_wrapper"
282 cat >$_valgrind_wrapper <<EOF
285 mount -t proc proc /proc
286 exec valgrind --leak-check=full --log-file=/valgrind.out $ROOTLIBDIR/systemd "\$@"
288 chmod 0755 $_valgrind_wrapper
291 create_strace_wrapper
() {
292 local _strace_wrapper
=$initdir/$ROOTLIBDIR/systemd-under-strace
293 ddebug
"Create $_strace_wrapper"
294 cat >$_strace_wrapper <<EOF
297 exec strace -D -o /strace.out $ROOTLIBDIR/systemd "\$@"
299 chmod 0755 $_strace_wrapper
303 dracut_install
/sbin
/fsck
*
304 dracut_install
-o /bin
/fsck
*
306 # fskc.reiserfs calls reiserfsck. so, install it
307 dracut_install
-o reiserfsck
311 instmods dm_crypt
=crypto
312 type -P dmeventd
>/dev
/null
&& dracut_install dmeventd
313 inst_libdir_file
"libdevmapper-event.so*"
314 if [[ "$LOOKS_LIKE_DEBIAN" ]]; then
315 # dmsetup installs 55-dm and 60-persistent-storage-dm on Debian/Ubuntu
316 # and since buster/bionic 95-dm-notify.rules
317 # see https://gitlab.com/debian-lvm/lvm2/blob/master/debian/patches/udev.patch
318 inst_rules
55-dm.rules
60-persistent-storage-dm.rules
95-dm-notify.rules
320 inst_rules
10-dm.rules
13-dm-disk.rules
95-dm-notify.rules
325 # install compiled files
326 local _ninja_bin
=$
(type -P ninja ||
type -P ninja-build
)
327 if [[ -z "$_ninja_bin" ]]; then
328 dfatal
"ninja was not found"
331 (set -x; DESTDIR
=$initdir "$_ninja_bin" -C $BUILD_DIR install)
332 # remove unneeded documentation
333 rm -fr $initdir/usr
/share
/{man
,doc
}
334 # we strip binaries since debug symbols increase binaries size a lot
335 # and it could fill the available space
338 [[ "$LOOKS_LIKE_SUSE" ]] && setup_suse
340 # enable debug logging in PID1
341 echo LogLevel
=debug
>> $initdir/etc
/systemd
/system.conf
346 objdump
-p "$_bin" 2>/dev
/null |
awk "/R(UN)?PATH/ { print \"$initdir\" \$2 }" |
paste -sd :
349 install_missing_libraries
() {
350 # install possible missing libraries
351 for i
in $initdir{,/usr
}/{sbin
,bin
}/* $initdir{,/usr
}/lib
/systemd
/*; do
352 LD_LIBRARY_PATH
=$
(get_ldpath
$i) inst_libs
$i
356 create_empty_image
() {
357 rm -f "$TESTDIR/rootdisk.img"
358 # Create the blank file to use as a root filesystem
359 dd if=/dev
/null of
="$TESTDIR/rootdisk.img" bs
=1M seek
=400
360 LOOPDEV
=$
(losetup
--show -P -f $TESTDIR/rootdisk.img
)
361 [ -b "$LOOPDEV" ] ||
return 1
362 echo "LOOPDEV=$LOOPDEV" >> $STATEFILE
363 sfdisk
"$LOOPDEV" <<EOF
370 local _label
="-L systemd"
371 # mkfs.reiserfs doesn't know -L. so, use --label instead
372 [[ "$FSTYPE" == "reiserfs" ]] && _label
="--label systemd"
373 if ! mkfs
-t "${FSTYPE}" ${_label} "${LOOPDEV}p1" -q; then
374 dfatal
"Failed to mkfs -t ${FSTYPE}"
379 check_result_nspawn
() {
381 [[ -e $TESTDIR/nspawn-root
/testok
]] && ret
=0
382 [[ -f $TESTDIR/nspawn-root
/failed
]] && cp -a $TESTDIR/nspawn-root
/failed
$TESTDIR
383 cp -a $TESTDIR/nspawn-root
/var
/log
/journal
$TESTDIR
384 [[ -f $TESTDIR/failed
]] && cat $TESTDIR/failed
385 ls -l $TESTDIR/journal
/*/*.journal
386 test -s $TESTDIR/failed
&& ret
=$
(($ret+1))
387 [ -n "$TIMED_OUT" ] && ret
=$
(($ret+1))
391 # can be overridden in specific test
392 check_result_qemu
() {
394 mkdir
-p $TESTDIR/root
395 mount
${LOOPDEV}p1
$TESTDIR/root
396 [[ -e $TESTDIR/root
/testok
]] && ret
=0
397 [[ -f $TESTDIR/root
/failed
]] && cp -a $TESTDIR/root
/failed
$TESTDIR
398 cp -a $TESTDIR/root
/var
/log
/journal
$TESTDIR
400 [[ -f $TESTDIR/failed
]] && cat $TESTDIR/failed
401 ls -l $TESTDIR/journal
/*/*.journal
402 test -s $TESTDIR/failed
&& ret
=$
(($ret+1))
403 [ -n "$TIMED_OUT" ] && ret
=$
(($ret+1))
408 if [[ "$STRIP_BINARIES" = "no" ]]; then
409 ddebug
"Don't strip binaries"
412 ddebug
"Strip binaries"
413 find "$initdir" -executable -not -path '*/lib/modules/*.ko' -type f |
xargs strip
--strip-unneeded | ddebug
417 mkdir
-p $initdir/etc
/rc.d
418 cat >$initdir/etc
/rc.d
/rc.
local <<EOF
422 chmod 0755 $initdir/etc
/rc.d
/rc.
local
426 ddebug
"install any Execs from the service files"
428 export PKG_CONFIG_PATH
=$BUILD_DIR/src
/core
/
429 systemdsystemunitdir
=$
(pkg-config
--variable=systemdsystemunitdir systemd
)
430 systemduserunitdir
=$
(pkg-config
--variable=systemduserunitdir systemd
)
431 egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/{$systemdsystemunitdir,$systemduserunitdir}/*.service \
433 i
=${i##Exec*=}; i=${i##[@+\!-]}; i=${i##\!}
434 # some {rc,halt}.local scripts and programs are okay to not exist, the rest should
435 inst
$i ||
[ "${i%.local}" != "$i" ] ||
[ "${i%systemd-update-done}" != "$i" ]
440 generate_module_dependencies
() {
441 if [[ -d $initdir/lib
/modules
/$KERNEL_VER ]] && \
442 ! depmod
-a -b "$initdir" $KERNEL_VER; then
443 dfatal
"\"depmod -a $KERNEL_VER\" failed."
448 install_depmod_files
() {
449 inst
/lib
/modules
/$KERNEL_VER/modules.order
450 inst
/lib
/modules
/$KERNEL_VER/modules.
builtin
454 # install plymouth, if found... else remove plymouth service files
455 # if [ -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
456 # PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$TEST_BASE_DIR/test-functions" \
457 # /usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
458 # dracut_install plymouth plymouthd
460 rm -f $initdir/{usr
/lib
,etc
}/systemd
/system
/plymouth
* $initdir/{usr
/lib
,etc
}/systemd
/system
/*/plymouth
*
464 install_ld_so_conf
() {
465 cp -a /etc
/ld.so.conf
* $initdir/etc
466 ldconfig
-r "$initdir"
469 install_config_files
() {
470 inst
/etc
/sysconfig
/init || true
476 inst
/etc
/nsswitch.conf
477 inst
/etc
/pam.conf || true
478 inst
/etc
/securetty || true
481 # we want an empty environment
482 > $initdir/etc
/environment
483 > $initdir/etc
/machine-id
485 echo systemd-testsuite
> $initdir/etc
/hostname
487 if [[ "$LOOKS_LIKE_SUSE" ]]; then
488 ROOTMOUNT
="/dev/sda1 / ${FSTYPE} rw 0 1"
490 ROOTMOUNT
="LABEL=systemd / ${FSTYPE} rw 0 1"
493 cat >$initdir/etc
/fstab
<<EOF
498 install_basic_tools
() {
499 [[ $BASICTOOLS ]] && dracut_install
$BASICTOOLS
500 dracut_install
-o sushell
501 # in Debian ldconfig is just a shell script wrapper around ldconfig.real
502 dracut_install
-o ldconfig.real
505 install_debug_tools
() {
506 [[ $DEBUGTOOLS ]] && dracut_install
$DEBUGTOOLS
510 # install libnss_files for login
511 NSS_LIBS
=$
(LD_DEBUG
=files getent passwd
2>&1 >/dev
/null |
sed -n '/calling init: .*libnss_/ {s!^.* /!/!; p}')
512 dracut_install
$NSS_LIBS
516 inst
$ROOTLIBDIR/system
/dbus.socket
517 inst
$ROOTLIBDIR/system
/dbus.service
520 /etc
/dbus-1
/usr
/share
/dbus-1
-xtype f \
521 |
while read file; do
528 if [[ "$LOOKS_LIKE_DEBIAN" ]] && type -p dpkg-architecture
&>/dev
/null
; then
529 find "/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/security" -xtype f
531 find /lib
*/security
-xtype f
533 find /etc
/pam.d
/etc
/security
-xtype f
534 ) |
while read file; do
538 # pam_unix depends on unix_chkpwd.
539 # see http://www.linux-pam.org/Linux-PAM-html/sag-pam_unix.html
540 dracut_install
-o unix_chkpwd
542 [[ "$LOOKS_LIKE_DEBIAN" ]] &&
543 cp /etc
/pam.d
/systemd-user
$initdir/etc
/pam.d
/
545 # set empty root password for easy debugging
546 sed -i 's/^root:x:/root::/' $initdir/etc
/passwd
551 /usr
/lib
/kbd
/keymaps
/include
/* \
552 /usr
/lib
/kbd
/keymaps
/i386
/include
/* \
553 /usr
/lib
/kbd
/keymaps
/i386
/qwerty
/us.
*; do
554 [[ -f $i ]] ||
continue
561 /usr
/lib
/kbd
/consolefonts
/eurlatgr
* \
562 /usr
/lib
/kbd
/consolefonts
/latarcyrheb-sun16
*; do
563 [[ -f $i ]] ||
continue
569 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
570 [ -f ${_terminfodir}/l
/linux
] && break
572 dracut_install
-o ${_terminfodir}/l
/linux
576 cp $TEST_BASE_DIR/testsuite.target
$initdir/etc
/systemd
/system
/
577 cp $TEST_BASE_DIR/end.service
$initdir/etc
/systemd
/system
/
579 mkdir
-p $initdir/etc
/systemd
/system
/testsuite.target.wants
580 ln -fs $TEST_BASE_DIR/testsuite.service
$initdir/etc
/systemd
/system
/testsuite.target.wants
/testsuite.service
581 ln -fs $TEST_BASE_DIR/end.service
$initdir/etc
/systemd
/system
/testsuite.target.wants
/end.service
583 # make the testsuite the default target
584 ln -fs testsuite.target
$initdir/etc
/systemd
/system
/default.target
587 setup_nspawn_root
() {
588 rm -fr $TESTDIR/nspawn-root
589 ddebug
"cp -ar $initdir $TESTDIR/nspawn-root"
590 cp -ar $initdir $TESTDIR/nspawn-root
591 # we don't mount in the nspawn root
592 rm -f $TESTDIR/nspawn-root
/etc
/fstab
596 mkdir
-p $initdir/run
597 mkdir
-p $initdir/etc
/systemd
/system
598 mkdir
-p $initdir/var
/log
/journal
600 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
601 if [ -L "/$d" ]; then
608 ln -sfn /run
"$initdir/var/run"
609 ln -sfn /run
/lock
"$initdir/var/lock"
614 local _so_regex
='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
617 LC_ALL
=C ldd
"$_bin" 2>/dev
/null |
while read _line
; do
618 [[ $_line = 'not a dynamic executable' ]] && break
620 if [[ $_line =~
$_so_regex ]]; then
621 _file
=${BASH_REMATCH[1]}
622 [[ -e ${initdir}/$_file ]] && continue
623 inst_library
"$_file"
627 if [[ $_line =~ not\ found
]]; then
628 dfatal
"Missing a shared library required by $_bin."
629 dfatal
"Run \"ldd $_bin\" to find out what it is."
631 dfatal
"dracut cannot create an initrd."
638 [[ -e $STATEFILE ]] && .
$STATEFILE
639 if [[ -z "$TESTDIR" ]] ||
[[ ! -d "$TESTDIR" ]]; then
640 TESTDIR
=$
(mktemp
--tmpdir=/var
/tmp
-d -t systemd-test.XXXXXX
)
641 echo "TESTDIR=\"$TESTDIR\"" > $STATEFILE
647 initdir
=$TESTDIR/root
651 ## @brief Converts numeric logging level to the first letter of level name.
653 # @param lvl Numeric logging level in range from 1 to 6.
654 # @retval 1 if @a lvl is out of range.
655 # @retval 0 if @a lvl is correct.
656 # @result Echoes first letter of level name.
669 ## @brief Internal helper function for _do_dlog()
671 # @param lvl Numeric logging level.
672 # @param msg Message.
673 # @retval 0 It's always returned, even if logging failed.
675 # @note This function is not supposed to be called manually. Please use
676 # dtrace(), ddebug(), or others instead which wrap this one.
678 # This function calls _do_dlog() either with parameter msg, or if
679 # none is given, it will read standard input and will use every line as
683 # dwarn "This is a warning"
684 # echo "This is a warning" | dwarn
688 [ -z "$LOG_LEVEL" ] && return 0
689 [ $1 -le $LOG_LEVEL ] ||
return 0
690 local lvl
="$1"; shift
691 local lvlc
=$
(_lvl2char
"$lvl") ||
return 0
693 if [ $# -ge 1 ]; then
697 echo "$lvlc: " "$line"
702 ## @brief Logs message at TRACE level (6)
704 # @param msg Message.
705 # @retval 0 It's always returned, even if logging failed.
709 [ -n "$debug" ] && set -x ||
:
712 ## @brief Logs message at DEBUG level (5)
714 # @param msg Message.
715 # @retval 0 It's always returned, even if logging failed.
719 # [ -n "$debug" ] && set -x || :
722 ## @brief Logs message at INFO level (4)
724 # @param msg Message.
725 # @retval 0 It's always returned, even if logging failed.
729 [ -n "$debug" ] && set -x ||
:
732 ## @brief Logs message at WARN level (3)
734 # @param msg Message.
735 # @retval 0 It's always returned, even if logging failed.
739 [ -n "$debug" ] && set -x ||
:
742 ## @brief Logs message at ERROR level (2)
744 # @param msg Message.
745 # @retval 0 It's always returned, even if logging failed.
749 # [ -n "$debug" ] && set -x || :
752 ## @brief Logs message at FATAL level (1)
754 # @param msg Message.
755 # @retval 0 It's always returned, even if logging failed.
759 [ -n "$debug" ] && set -x ||
:
763 # Generic substring function. If $2 is in $1, return 0.
764 strstr
() { [ "${1#*$2*}" != "$1" ]; }
766 # normalize_path <path>
767 # Prints the normalized path, where it removes any duplicated
768 # and trailing slashes.
770 # $ normalize_path ///test/test//
774 set -- "${1//+(\/)//}"
779 # convert_abs_rel <from> <to>
780 # Prints the relative path, when creating a symlink to <to> from <from>.
782 # $ convert_abs_rel /usr/bin/test /bin/test-2
784 # $ ln -s $(convert_abs_rel /usr/bin/test /bin/test-2) /usr/bin/test
786 local __current __absolute __abssize __cursize __newpath
789 set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
791 # corner case #1 - self looping link
792 [[ "$1" == "$2" ]] && { echo "${1##*/}"; return; }
794 # corner case #2 - own dir link
795 [[ "${1%/*}" == "$2" ]] && { echo "."; return; }
797 IFS
="/" __current
=($1)
798 IFS
="/" __absolute
=($2)
800 __abssize
=${#__absolute[@]}
801 __cursize
=${#__current[@]}
803 while [[ ${__absolute[__level]} == ${__current[__level]} ]]
806 if (( __level
> __abssize || __level
> __cursize
))
812 for ((__i
= __level
; __i
< __cursize-1
; __i
++))
816 __newpath
=$__newpath"/"
818 __newpath
=$__newpath".."
821 for ((__i
= __level
; __i
< __abssize
; __i
++))
823 if [[ -n $__newpath ]]
825 __newpath
=$__newpath"/"
827 __newpath
=$__newpath${__absolute[__i]}
834 # Install a directory, keeping symlinks as on the original system.
835 # Example: if /lib points to /lib64 on the host, "inst_dir /lib/file"
836 # will create ${initdir}/lib64, ${initdir}/lib64/file,
837 # and a symlink ${initdir}/lib -> lib64.
839 [[ -e ${initdir}/"$1" ]] && return 0 # already there
841 local _dir
="$1" _part
="${1%/*}" _file
842 while [[ "$_part" != "${_part%/*}" ]] && ! [[ -e "${initdir}/${_part}" ]]; do
847 # iterate over parent directories
848 for _file
in $_dir; do
849 [[ -e "${initdir}/$_file" ]] && continue
850 if [[ -L $_file ]]; then
851 inst_symlink
"$_file"
854 mkdir
-m 0755 -p "${initdir}/$_file" ||
return 1
855 [[ -e "$_file" ]] && chmod --reference="$_file" "${initdir}/$_file"
856 chmod u
+w
"${initdir}/$_file"
861 # $1 = file to copy to ramdisk
862 # $2 (optional) Name for the file on the ramdisk
863 # Location of the image dir is assumed to be $initdir
864 # We never overwrite the target if it exists.
866 [[ -f "$1" ]] ||
return 1
867 strstr
"$1" "/" ||
return 1
869 local _src
=$1 target
="${2:-$1}"
870 if ! [[ -d ${initdir}/$target ]]; then
871 [[ -e ${initdir}/$target ]] && return 0
872 [[ -L ${initdir}/$target ]] && return 0
873 [[ -d "${initdir}/${target%/*}" ]] || inst_dir "${target%/*}"
875 # install checksum files also
876 if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then
877 inst
"${_src%/*}/.${_src##*/}.hmac" "${target%/*}/.${target##*/}.hmac"
879 ddebug
"Installing $_src"
880 cp --sparse=always
-pfL "$_src" "${initdir}/$target"
883 # find symlinks linked to given library file
885 # Function searches for symlinks by stripping version numbers appended to
886 # library filename, checks if it points to the same target and finally
887 # prints the list of symlinks to stdout.
890 # rev_lib_symlinks libfoo.so.8.1
891 # output: libfoo.so.8 libfoo.so
892 # (Only if libfoo.so.8 and libfoo.so exists on host system.)
894 [[ ! $1 ]] && return 0
896 local fn
="$1" orig
="$(readlink -f "$1")" links
=''
898 [[ ${fn} =~ .
*\.so\..
* ]] ||
return 1
900 until [[ ${fn##*.} == so
]]; do
902 [[ -L ${fn} && $(readlink -f "${fn}") == ${orig} ]] && links+=" ${fn}"
908 # Same as above, but specialized to handle dynamic libraries.
909 # It handles making symlinks according to how the original library
912 local _src="$1" _dest=${2:-$1} _lib _reallib _symlink
913 strstr "$1" "/" || return 1
914 [[ -e $initdir/$_dest ]] && return 0
915 if [[ -L $_src ]]; then
916 # install checksum files also
917 if [[ -e "${_src%/*}/.
${_src##*/}.hmac
" ]]; then
918 inst "${_src%/*}/.${_src##*/}.hmac" "${_dest%/*}/.${_dest##*/}.hmac
"
920 _reallib=$(readlink -f "$_src")
921 inst_simple "$_reallib" "$_reallib"
922 inst_dir "${_dest%/*}"
923 [[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/}
924 ln -sfn $
(convert_abs_rel
"${_dest}" "${_reallib}") "${initdir}/${_dest}"
926 inst_simple
"$_src" "$_dest"
929 # Create additional symlinks. See rev_symlinks description.
930 for _symlink
in $
(rev_lib_symlinks
$_src) $
(rev_lib_symlinks
$_reallib); do
931 [[ -e $initdir/$_symlink ]] ||
{
932 ddebug
"Creating extra symlink: $_symlink"
933 inst_symlink
$_symlink
938 # find a binary. If we were not passed the full path directly,
939 # search in the usual places to find the binary.
941 if [[ -z ${1##/*} ]]; then
942 if [[ -x $1 ]] ||
{ strstr
"$1" ".so" && ldd
$1 &>/dev
/null
; }; then
951 # Same as above, but specialized to install binary executables.
952 # Install binary executable, and all shared library dependencies, if any.
955 _bin
=$
(find_binary
"$1") ||
return 1
957 [[ -e $initdir/$_target ]] && return 0
958 [[ -L $_bin ]] && inst_symlink
$_bin $_target && return 0
960 local _so_regex
='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
962 LC_ALL
=C ldd
"$_bin" 2>/dev
/null |
while read _line
; do
963 [[ $_line = 'not a dynamic executable' ]] && break
965 if [[ $_line =~
$_so_regex ]]; then
966 _file
=${BASH_REMATCH[1]}
967 [[ -e ${initdir}/$_file ]] && continue
968 inst_library
"$_file"
972 if [[ $_line =~ not\ found
]]; then
973 dfatal
"Missing a shared library required by $_bin."
974 dfatal
"Run \"ldd $_bin\" to find out what it is."
976 dfatal
"dracut cannot create an initrd."
980 inst_simple
"$_bin" "$_target"
983 # same as above, except for shell scripts.
984 # If your shell script does not start with shebang, it is not a shell script.
987 _bin
=$
(find_binary
"$1") ||
return 1
989 local _line _shebang_regex
990 read -r -n 80 _line
<"$_bin"
991 # If debug is set, clean unprintable chars to prevent messing up the term
992 [[ $debug ]] && _line
=$
(echo -n "$_line" |
tr -c -d '[:print:][:space:]')
993 _shebang_regex
='(#! *)(/[^ ]+).*'
994 [[ $_line =~
$_shebang_regex ]] ||
return 1
995 inst
"${BASH_REMATCH[2]}" && inst_simple
"$_bin" "$@"
998 # same as above, but specialized for symlinks
1000 local _src
=$1 _target
=${2:-$1} _realsrc
1001 strstr
"$1" "/" ||
return 1
1002 [[ -L $1 ]] ||
return 1
1003 [[ -L $initdir/$_target ]] && return 0
1004 _realsrc
=$
(readlink
-f "$_src")
1005 if ! [[ -e $initdir/$_realsrc ]]; then
1006 if [[ -d $_realsrc ]]; then
1007 inst_dir
"$_realsrc"
1012 [[ ! -e $initdir/${_target%/*} ]] && inst_dir
"${_target%/*}"
1013 [[ -d ${_target%/*} ]] && _target=$(readlink -f ${_target%/*})/${_target##*/}
1014 ln -sfn $
(convert_abs_rel
"${_target}" "${_realsrc}") "$initdir/$_target"
1017 # attempt to install any programs specified in a udev rule
1018 inst_rule_programs
() {
1021 if grep -qE 'PROGRAM==?"[^ "]+' "$1"; then
1022 for _prog
in $
(grep -E 'PROGRAM==?"[^ "]+' "$1" |
sed -r 's/.*PROGRAM==?"([^ "]+).*/\1/'); do
1023 if [ -x /lib
/udev
/$_prog ]; then
1024 _bin
=/lib
/udev
/$_prog
1026 _bin
=$
(find_binary
"$_prog") ||
{
1027 dinfo
"Skipping program $_prog using in udev rule $(basename $1) as it cannot be found"
1032 #dinfo "Installing $_bin due to it's use in the udev rule $(basename $1)"
1033 dracut_install
"$_bin"
1038 # udev rules always get installed in the same place, so
1039 # create a function to install them to make life simpler.
1041 local _target
=/etc
/udev
/rules.d _rule _found
1043 inst_dir
"/lib/udev/rules.d"
1045 for _rule
in "$@"; do
1046 if [ "${rule#/}" = "$rule" ]; then
1047 for r
in /lib
/udev
/rules.d
/etc
/udev
/rules.d
; do
1048 if [[ -f $r/$_rule ]]; then
1050 inst_simple
"$_found"
1051 inst_rule_programs
"$_found"
1055 for r
in '' .
/ $dracutbasedir/rules.d
/; do
1056 if [[ -f ${r}$_rule ]]; then
1058 inst_simple
"$_found" "$_target/${_found##*/}"
1059 inst_rule_programs
"$_found"
1062 [[ $_found ]] || dinfo
"Skipping udev rule: $_rule"
1067 # general purpose installation function
1068 # Same args as above.
1074 2) [[ ! $initdir && -d $2 ]] && export initdir
=$2
1075 [[ $initdir = $2 ]] && set $1;;
1076 3) [[ -z $initdir ]] && export initdir
=$2
1078 *) dfatal
"inst only takes 1 or 2 or 3 arguments"
1081 for _x
in inst_symlink inst_script inst_binary inst_simple
; do
1082 $_x "$@" && return 0
1087 # install any of listed files
1089 # If first argument is '-d' and second some destination path, first accessible
1090 # source is installed into this path, otherwise it will installed in the same
1091 # path as source. If none of listed files was installed, function return 1.
1092 # On first successful installation it returns with 0 status.
1096 # inst_any -d /bin/foo /bin/bar /bin/baz
1098 # Lets assume that /bin/baz exists, so it will be installed as /bin/foo in
1103 [[ $1 = '-d' ]] && to
="$2" && shift 2
1106 if [[ -e $f ]]; then
1107 [[ $to ]] && inst
"$f" "$to" && return 0
1108 inst
"$f" && return 0
1115 # dracut_install [-o ] <file> [<file> ... ]
1116 # Install <file> to the initramfs image
1117 # -o optionally install the <file> and don't fail, if it is not there
1120 if [[ $1 = '-o' ]]; then
1124 while (($# > 0)); do
1125 if ! inst
"$1" ; then
1126 if [[ $_optional = yes ]]; then
1127 dinfo
"Skipping program $1 as it cannot be found and is" \
1128 "flagged to be optional"
1130 dfatal
"Failed to install $1"
1138 # Install a single kernel module along with any firmware it may require.
1139 # $1 = full path to kernel module to install
1140 install_kmod_with_fw
() {
1141 # no need to go further if the module is already installed
1143 [[ -e "${initdir}/lib/modules/$KERNEL_VER/${1##*/lib/modules/$KERNEL_VER/}" ]] \
1146 [[ -e "$initdir/.kernelmodseen/${1##*/}" ]] && return 0
1148 if [[ $omit_drivers ]]; then
1149 local _kmod
=${1##*/}
1152 if [[ "$_kmod" =~
$omit_drivers ]]; then
1153 dinfo
"Omitting driver $_kmod"
1156 if [[ "${1##*/lib/modules/$KERNEL_VER/}" =~
$omit_drivers ]]; then
1157 dinfo
"Omitting driver $_kmod"
1162 [ -d "$initdir/.kernelmodseen" ] && \
1163 > "$initdir/.kernelmodseen/${1##*/}"
1165 inst_simple
"$1" "/lib/modules/$KERNEL_VER/${1##*/lib/modules/$KERNEL_VER/}" \
1168 local _modname
=${1##*/} _fwdir _found _fw
1169 _modname
=${_modname%.ko*}
1170 for _fw
in $
(modinfo
-k $KERNEL_VER -F firmware
$1 2>/dev
/null
); do
1172 for _fwdir
in $fw_dir; do
1173 if [[ -d $_fwdir && -f $_fwdir/$_fw ]]; then
1174 inst_simple
"$_fwdir/$_fw" "/lib/firmware/$_fw"
1178 if [[ $_found != yes ]]; then
1179 if ! grep -qe "\<${_modname//-/_}\>" /proc
/modules
; then
1180 dinfo
"Possible missing firmware \"${_fw}\" for kernel module" \
1181 "\"${_modname}.ko\""
1183 dwarn
"Possible missing firmware \"${_fw}\" for kernel module" \
1184 "\"${_modname}.ko\""
1191 # Do something with all the dependencies of a kernel module.
1192 # Note that kernel modules depend on themselves using the technique we use
1193 # $1 = function to call for each dependency we find
1194 # It will be passed the full path to the found kernel module
1195 # $2 = module to get dependencies for
1196 # rest of args = arguments to modprobe
1197 # _fderr specifies FD passed from surrounding scope
1198 for_each_kmod_dep
() {
1199 local _func
=$1 _kmod
=$2 _cmd _modpath _options _found
=0
1201 modprobe
"$@" --ignore-install --show-depends $_kmod 2>&${_fderr} |
(
1202 while read _cmd _modpath _options
; do
1203 [[ $_cmd = insmod
]] ||
continue
1204 $_func ${_modpath} ||
exit $?
1207 [[ $_found -eq 0 ]] && exit 1
1212 # filter kernel modules to install certain modules that meet specific
1214 # $1 = search only in subdirectory of /kernel/$1
1215 # $2 = function to call with module name to filter.
1216 # This function will be passed the full path to the module to test.
1217 # The behavior of this function can vary depending on whether $hostonly is set.
1218 # If it is, we will only look at modules that are already in memory.
1219 # If it is not, we will look at all kernel modules
1220 # This function returns the full filenames of modules that match $1
1221 filter_kernel_modules_by_path
() (
1222 local _modname _filtercmd
1223 if ! [[ $hostonly ]]; then
1224 _filtercmd
='find "$KERNEL_MODS/kernel/$1" "$KERNEL_MODS/extra"'
1225 _filtercmd
+=' "$KERNEL_MODS/weak-updates" -name "*.ko" -o -name "*.ko.gz"'
1226 _filtercmd
+=' -o -name "*.ko.xz"'
1227 _filtercmd
+=' 2>/dev/null'
1229 _filtercmd
='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename '
1230 _filtercmd
+='-k $KERNEL_VER 2>/dev/null'
1232 for _modname
in $
(eval $_filtercmd); do
1234 *.ko
) "$2" "$_modname" && echo "$_modname";;
1235 *.ko.gz
) gzip -dc "$_modname" > $initdir/$$.ko
1236 $2 $initdir/$$.ko
&& echo "$_modname"
1237 rm -f $initdir/$$.ko
1239 *.ko.xz
) xz
-dc "$_modname" > $initdir/$$.ko
1240 $2 $initdir/$$.ko
&& echo "$_modname"
1241 rm -f $initdir/$$.ko
1246 find_kernel_modules_by_path
() (
1247 if ! [[ $hostonly ]]; then
1248 find "$KERNEL_MODS/kernel/$1" "$KERNEL_MODS/extra" "$KERNEL_MODS/weak-updates" \
1249 -name "*.ko" -o -name "*.ko.gz" -o -name "*.ko.xz" 2>/dev
/null
1251 cut
-d " " -f 1 </proc
/modules \
1252 |
xargs modinfo
-F filename
-k $KERNEL_VER 2>/dev
/null
1256 filter_kernel_modules
() {
1257 filter_kernel_modules_by_path drivers
"$1"
1260 find_kernel_modules
() {
1261 find_kernel_modules_by_path drivers
1264 # instmods [-c] <kernel module> [<kernel module> ... ]
1265 # instmods [-c] <kernel subsystem>
1266 # install kernel modules along with all their dependencies.
1267 # <kernel subsystem> can be e.g. "=block" or "=drivers/usb/storage"
1269 [[ $no_kernel = yes ]] && return
1270 # called [sub]functions inherit _fderr
1273 if [[ $1 = '-c' ]]; then
1278 function inst1mod
() {
1279 local _ret
=0 _mod
="$1"
1282 if [ -f $KERNEL_MODS/modules.
${_mod#=} ]; then
1283 ( [[ "$_mpargs" ]] && echo $_mpargs
1284 cat "${KERNEL_MODS}/modules.${_mod#=}" ) \
1287 ( [[ "$_mpargs" ]] && echo $_mpargs
1288 find "$KERNEL_MODS" -path "*/${_mod#=}/*" -printf '%f\n' ) \
1292 --*) _mpargs
+=" $_mod" ;;
1293 i2o_scsi
) return ;; # Do not load this diagnostic-only module
1296 # if we are already installed, skip this module and go on
1298 [[ -f "$initdir/.kernelmodseen/${_mod%.ko}.ko" ]] && return
1300 if [[ $omit_drivers ]] && [[ "$1" =~
$omit_drivers ]]; then
1301 dinfo
"Omitting driver ${_mod##$KERNEL_MODS}"
1304 # If we are building a host-specific initramfs and this
1305 # module is not already loaded, move on to the next one.
1306 [[ $hostonly ]] && ! grep -qe "\<${_mod//-/_}\>" /proc
/modules \
1307 && ! echo $add_drivers |
grep -qe "\<${_mod}\>" \
1310 # We use '-d' option in modprobe only if modules prefix path
1311 # differs from default '/'. This allows us to use Dracut with
1312 # old version of modprobe which doesn't have '-d' option.
1313 local _moddirname
=${KERNEL_MODS%%/lib/modules/*}
1314 [[ -n ${_moddirname} ]] && _moddirname
="-d ${_moddirname}/"
1316 # ok, load the module, all its dependencies, and any firmware
1318 for_each_kmod_dep install_kmod_with_fw
$_mod \
1319 --set-version $KERNEL_VER ${_moddirname} $_mpargs
1326 function instmods_1
() {
1328 if (($# == 0)); then # filenames from stdin
1330 inst1mod
"${_mod%.ko*}" ||
{
1331 if [ "$_check" = "yes" ]; then
1332 dfatal
"Failed to install $_mod"
1338 while (($# > 0)); do # filenames as arguments
1339 inst1mod
${1%.ko*} ||
{
1340 if [ "$_check" = "yes" ]; then
1341 dfatal
"Failed to install $1"
1350 local _ret _filter_not_found
='FATAL: Module .* not found.'
1352 # Capture all stderr from modprobe to _fderr. We could use {var}>...
1353 # redirections, but that would make dracut require bash4 at least.
1354 eval "( instmods_1 \"\$@\" ) ${_fderr}>&1" \
1355 |
while read line
; do [[ "$line" =~
$_filter_not_found ]] && echo $line ||
echo $line >&2 ;done | derror
1361 # inst_libdir_file [-n <pattern>] <file> [<file>...]
1362 # Install a <file> located on a lib directory to the initramfs image
1363 # -n <pattern> install non-matching files
1364 inst_libdir_file
() {
1365 if [[ "$1" == "-n" ]]; then
1368 for _dir
in $libdirs; do
1370 for _f
in "$_dir"/$_i; do
1371 [[ "$_i" =~
$_pattern ]] ||
continue
1372 [[ -e "$_i" ]] && dracut_install
"$_i"
1377 for _dir
in $libdirs; do
1379 for _f
in "$_dir"/$_i; do
1380 [[ -e "$_f" ]] && dracut_install
"$_f"
1388 ln -fs ..
/usr
/bin
/systemctl
$initdir/bin
/
1389 ln -fs ..
/usr
/lib
/systemd
$initdir/lib
/
1390 inst_simple
"/usr/lib/systemd/system/haveged.service"
1393 # can be overridden in specific test
1395 umount
$TESTDIR/root
2>/dev
/null || true
1396 [[ $LOOPDEV ]] && losetup
-d $LOOPDEV || true
1401 if [ -z "$TEST_NO_QEMU" ]; then
1403 check_result_qemu ||
return 1
1405 dwarn
"can't run QEMU, skipping"
1408 if [ -z "$TEST_NO_NSPAWN" ]; then
1410 check_result_nspawn ||
return 1
1412 dwarn
"can't run systemd-nspawn, skipping"
1419 if [[ $UID != "0" ]]; then
1420 echo "TEST: $TEST_DESCRIPTION [SKIPPED]: not root" >&2
1425 [[ $libdir ]] ||
for libdir
in /lib64
/lib
; do
1426 [[ -d $libdir ]] && libdirs
+=" $libdir" && break
1429 [[ $usrlibdir ]] ||
for usrlibdir
in /usr
/lib64
/usr
/lib
; do
1430 [[ -d $usrlibdir ]] && libdirs
+=" $usrlibdir" && break
1433 mkdir
-p "$STATEDIR"
1438 while (($# > 0)); do
1441 echo "TEST RUN: $TEST_DESCRIPTION"
1443 echo "TEST RUN: $TEST_DESCRIPTION [OK]"
1445 echo "TEST RUN: $TEST_DESCRIPTION [FAILED]"
1449 echo "TEST SETUP: $TEST_DESCRIPTION"
1453 echo "TEST CLEANUP: $TEST_DESCRIPTION"
1460 echo -n "TEST: $TEST_DESCRIPTION ";
1462 test_setup
&& test_run
1468 ) </dev
/null
>"$TESTLOG" 2>&1 || ret
=$?
1469 if [ $ret -eq 0 ]; then