summaryrefslogtreecommitdiffstats
path: root/tests/test_driver.sh
blob: 803f69f3fe79ec474fb820d7bb4ba44903b4d7d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh

TEST_COLOR=no
TEST_LOG=/dev/null
TEST_TRS=""

. $(dirname "$0")/driver.sh

test_setup "echo test start"
test_cleanup "echo test end"

test_setup "echo real start"
test_cleanup "echo real end"

test_group "test driver tests"

echo

echo "test should PASS"
test_result 0 foo
test_run echo foo

echo "test should FAIL"
test_result 0 foo
test_run echo bar

echo "test should XPASS"
test_result 1 foo
test_run echo foo

echo "test should FAIL"
test_result 1 foo
test_run echo bar

echo "test should XFAIL"
test_result 1 --
test_run false

echo "test should FAIL"
test_result 1 --
test_run echo foo && false

echo "test should SKIP"
test_result 0 --
test_skip
test_run echo foo

echo

echo_stderr ()
{
	echo "$*" >&2
}

test_wrapper echo_stderr

echo "match stderr"
test_result 0 --
test_result_stderr foo
test_run foo

test_wrapper

echo

result_filter ()
{
	sed -e 's#[0-9][0-9][0-9]#NUM3#g' \
	    -e 's#[0-9][0-9]#NUM2#g'
}

test_result 0 NUM2
test_run echo 42

test_result 0 NUM3
test_run echo 666

echo

prefix_output ()
{
	echo "output: $*"
}

test_wrapper prefix_output

test_result 0 "output: foobar"
test_run foobar

echo
OpenPOWER on IntegriCloud