Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/xdg-utils/tests/include/testfuncs.sh

Issue 151098: Patch from mdm@google.com... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 verify_test_context() {
2 if [ -z "$TEST_NAME" -a ! "$USING_TET" ]; then
3 echo "A test context must be established with 'test_start <name> '!"
4 exit 255
5 fi
6 }
7
8 ## record the test a name.
9 test_start () {
10
11 TEST_NAME="$*"
12 verify_test_context
13 TEST_STATUS=PASS
14
15 if [ $USING_TET ]; then
16 tet_infoline $TEST_NAME
17 FAIL=N
18 else
19 echo -n "[`date`] $TEST_NAME: "
20 fi
21
22 }
23
24 test_infoline() {
25 verify_test_context
26 FAIL_MESSAGE="$FAIL_MESSAGE\n$*"
27 if [ "$USING_TET" ] ; then
28 tet_infoline $*
29 fi
30 }
31
32 test_fail() {
33 FAIL=Y
34 TEST_STATUS=FAIL
35 test_infoline $*
36 }
37
38 ## provide a nice way to document the test purpose
39 test_purpose() {
40 verify_test_context
41 # TODO: generate a manpage or something.
42 }
43 test_note() {
44 #verify_test_context
45 # TODO: generate even more docs.
46 tmp=1
47 }
48
49 ## Used for setup/dependency verification.
50 test_init() {
51 verify_test_context
52 }
53
54 test_status() {
55 TEST_STATUS="$1"
56 test_infoline "$2"
57 }
58
59 ## Called after test_init()
60 test_procedure() {
61 verify_test_context
62 ## Make sure nothing screwed up in initilization
63 if [ "$TEST_STATUS" != "PASS" ]; then
64 # Something failed before we could get to the test.
65 FAIL=N
66 test_result NORESULT "Initilization failed!"
67 fi
68 }
69
70 ## Must be within test_procedure
71 test_failoverride() {
72 STAT=${1-WARN}
73 if [ "$TEST_STATUS" == FAIL ] ; then
74 FAIL=N
75 test_status "$STAT"
76 fi
77 }
78
79 ## Report the test's result.
80 test_result() {
81 verify_test_context
82
83 # Set status appropriately
84 if [ ! -z "$1" ]; then
85 TEST_STATUS=$1
86 # account for TET
87 if [ "$TEST_STATUS" = "FAIL" ] ; then
88 FAIL=Y
89 fi
90 fi
91 # if we have a message, save it
92 if [ ! -z "$2" ]; then
93 test_infoline $2
94 fi
95 if [ "$USING_TET" ]; then
96 tet_result $TEST_STATUS
97 fi
98 # not using tet, so print nice explanation
99
100 [ -z "$USING_TET" ] && echo -n "$TEST_STATUS"
101
102 ## Result codes MUST agree with tet_codes
103 ## for LSB/tet integration.
104 case "$TEST_STATUS" in
105 PASS ) RESULT=0
106 ;;
107 FAIL ) RESULT=1
108 [ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
109 ;;
110 UNTESTED ) RESULT=5
111 [ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
112 ;;
113 NORESULT ) RESULT=7
114 [ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
115 ;;
116 WARN ) RESULT=10
117 [ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
118 ;;
119 *) RESULT=1
120 [ -z "$USING_TET" ] && echo -ne " - UNKNOWN STATUS\n$FAI L_MESSAGE"
121 ;;
122 esac
123 #fi
124 [ -z "$USING_TET" ] && echo ""
125 exit "$RESULT"
126 }
127
128 infofile() # write file to journal using tet_infoline
129 {
130 # $1 is file name, $2 is prefix for tet_infoline
131
132 prefix="$2"
133 while read line
134 do
135 test_infoline "$prefix$line"
136 done < "$1"
137 }
138
OLDNEW
« no previous file with comments | « third_party/xdg-utils/tests/include/testcontrol.sh ('k') | third_party/xdg-utils/tests/spec/test_specification.odt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698