]>
git.ipfire.org Git - thirdparty/dracut.git/blob - test/test-functions
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 [[ -e .testdir
]] && . .testdir
8 if [[ -z "$TESTDIR" ]] ||
[[ ! -d "$TESTDIR" ]]; then
9 TESTDIR
=$
(mktemp
-d --tmpdir="/var/tmp" -t dracut-test.XXXXXX
)
11 echo "TESTDIR=\"$TESTDIR\"" > .testdir
14 command -v test_check
&>/dev
/null || test_check
() {
18 # terminal sequence to set color to a 'success' color (currently: green)
19 function SETCOLOR_SUCCESS
() { echo -en '\033[0;32m'; }
20 # terminal sequence to set color to a 'failure' color (currently: red)
21 function SETCOLOR_FAILURE
() { echo -en '\033[0;31m'; }
22 # terminal sequence to set color to a 'warning' color (currently: yellow)
23 function SETCOLOR_WARNING
() { echo -en '\033[0;33m'; }
24 # terminal sequence to reset to the default color.
25 function SETCOLOR_NORMAL
() { echo -en '\033[0;39m'; }
28 if (( $EUID != 0 )); then
29 SETCOLOR_FAILURE
; echo "Tests must be run as root! Please use 'sudo'."; SETCOLOR_NORMAL
38 echo "TEST RUN: $TEST_DESCRIPTION"
39 test_check
&& test_run
43 echo "TEST SETUP: $TEST_DESCRIPTION"
44 test_check
&& test_setup
47 echo "TEST CLEANUP: $TEST_DESCRIPTION"
54 echo -n "TEST: $TEST_DESCRIPTION ";
55 if ! test_check
2&>test.log
; then
61 if [ "$V" != "1" ]; then
63 test_setup
&& test_run
69 ) </dev
/null
>test.log
2>&1
73 test_setup
&& test_run
79 ) </dev
/null
2>&1 |
tee test.log
83 if [ $ret -eq 0 ]; then
92 echo "see $(pwd)/test.log"