test-functions revision 898720b7e9cf3bdf7a93e435cbed5dd6942ecf9b
b0e8629055a766d4555a005a283c2889a5974945Mark Andrews# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# ex: ts=8 sw=4 sts=4 et filetype=sh
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews for d in usr/bin usr/sbin bin etc lib "$libdir" sbin tmp usr var var/log; do
b0e8629055a766d4555a005a283c2889a5974945Mark Andrews for d in dev proc sys sysroot root run run/lock run/initramfs; do
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews local _so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews LC_ALL=C ldd "$_bin" 2>/dev/null | while read _line; do
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews [[ $_line = 'not a dynamic executable' ]] && break
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews if [[ $_line =~ $_so_regex ]]; then
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews [[ -e ${initdir}/$_file ]] && continue
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews if [[ $_line =~ not\ found ]]; then
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews dfatal "Missing a shared library required by $_bin."
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews dfatal "Run \"ldd $_bin\" to find out what it is."
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews if [[ -z "$TESTDIR" ]] || [[ ! -d "$TESTDIR" ]]; then
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews TESTDIR=$(mktemp --tmpdir=/var/tmp -d -t systemd-test.XXXXXX)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews## @brief Converts numeric logging level to the first letter of level name.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @param lvl Numeric logging level in range from 1 to 6.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @retval 1 if @a lvl is out of range.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @retval 0 if @a lvl is correct.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @result Echoes first letter of level name.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews *) return 1;;
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews## @brief Internal helper function for _do_dlog()
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @param lvl Numeric logging level.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @param msg Message.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @retval 0 It's always returned, even if logging failed.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @note This function is not supposed to be called manually. Please use
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# dtrace(), ddebug(), or others instead which wrap this one.
b0e8629055a766d4555a005a283c2889a5974945Mark Andrews# This function calls _do_dlog() either with parameter msg, or if
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# none is given, it will read standard input and will use every line as
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# This enables:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# dwarn "This is a warning"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# echo "This is a warning" | dwarn
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews [ $1 -le $LOG_LEVEL ] || return 0
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews if [ $# -ge 1 ]; then
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews while read line; do
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews## @brief Logs message at TRACE level (6)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @param msg Message.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @retval 0 It's always returned, even if logging failed.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews## @brief Logs message at DEBUG level (5)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @param msg Message.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# @retval 0 It's always returned, even if logging failed.
while [[ ${__absolute[__level]} == ${__current[__level]} ]]
if [[ -n $__newpath ]]
if [[ -L $_file ]]; then
# rev_lib_symlinks libfoo.so.8.1
if [[ -L $_src ]]; then
[[ -L $_bin ]] && inst_symlink $_bin $_target && return 0
if [[ $_line =~ $_so_regex ]]; then
_file=${BASH_REMATCH[1]}
local _bin
local _line _shebang_regex
[[ $_line =~ $_shebang_regex ]] || return 1
if [[ -d $_realsrc ]]; then
if [[ -f $r/$_rule ]]; then
if [[ -f ${r}$_rule ]]; then
local _x
case $# in
[[ $initdir = $2 ]] && set $1;;
for _x in inst_symlink inst_script inst_binary inst_simple; do
local to f
if [[ $_optional = yes ]]; then
local _pattern=$1
case $1 in
--run)
ret=$?
exit $ret;;
--setup)
--clean)
--all)
ret=$?
exit $ret
ret=$?
exit $ret;;