1TESTING.SH(1)         User Contributed Perl Documentation        TESTING.SH(1)
2
3
4

NAME

6       BeakerLib - testing - asserting functions, watchdog and report
7

DESCRIPTION

9       This file contains functions related directly to testing. These
10       functions are various asserts affecting final result of the phase.
11       Watchdog and the report result function is included as well.
12

FUNCTIONS

14   Manual Asserts
15       rlPass
16
17       Manual assertion, asserts and logs PASS.
18
19           rlPass comment
20
21       comment
22           Short test summary.
23
24       Returns 0 and asserts PASS.
25
26       rlFail
27
28       Manual assertion, asserts and logs FAIL.
29
30           rlFail comment
31
32       comment
33           Short test summary.
34
35       Returns 1 and asserts FAIL.
36
37   Arithmetic Asserts
38       rlAssert0
39
40       Assertion checking for the equality of parameter to zero.
41
42           rlAssert0 comment value
43
44       comment
45           Short test summary, e.g. "Test if compilation ended successfully".
46
47       value
48           Integer value (usually return code of a command).
49
50       Returns 0 and asserts PASS when "value == 0".
51
52       rlAssertEquals
53
54       Assertion checking for the equality of two parameters.
55
56           rlAssertEquals comment value1 value2
57
58       comment
59           Short test summary, e.g. "Test if all 3 packages have been
60           downloaded".
61
62       value1
63           First parameter to compare, can be a number or a string
64
65       value2
66           Second parameter to compare, can be a number or a string
67
68       Returns 0 and asserts PASS when "value1 == value2".
69
70       rlAssertNotEquals
71
72       Assertion checking for the non-equality of two parameters.
73
74           rlAssertNotEquals comment value1 value2
75
76       comment
77           Short test summary, e.g. "Test if return code is not 139".
78
79       value1
80           First parameter to compare, can be a number or a string
81
82       value2
83           Second parameter to compare, can be a number or a string
84
85       Returns 0 and asserts PASS when "value1 != value2".
86
87       rlAssertGreater
88
89       Assertion checking whether first parameter is greater than the second
90       one.
91
92           rlAssertGreater comment value1 value2
93
94       comment
95           Short test summary, e.g. "Test whether there are running more
96           instances of program."
97
98       value1
99           Integer value.
100
101       value2
102           Integer value.
103
104       Returns 0 and asserts PASS when "value1 > value2".
105
106       rlAssertGreaterOrEqual
107
108       Assertion checking whether first parameter is greater or equal to the
109       second one.
110
111           rlAssertGreaterOrEqual comment value1 value2
112
113       comment
114           Short test summary (e.g. "There should present at least one...")
115
116       value1
117           Integer value.
118
119       value2
120           Integer value.
121
122       Returns 0 and asserts PASS when "value1 >= value2".
123
124   File Asserts
125       rlAssertExists
126
127       Assertion checking for the existence of a file.
128
129           rlAssertExists file
130
131       file
132           Path to the file.
133
134       Returns 0 and asserts PASS when "file" exists.
135
136       rlAssertNotExists
137
138       Assertion checking for the non-existence of a file.
139
140           rlAssertNotExists file
141
142       file
143           Path to the file.
144
145       Returns 0 and asserts PASS when "file" does not exist.
146
147       rlAssertGrep
148
149       Assertion checking if the file contains a pattern.
150
151           rlAssertGrep pattern file [options]
152
153       pattern
154           Regular expression to be searched for.
155
156       file
157           Path to the file.
158
159       options
160           Optional parameters to be passed to grep, default is "-q". Can be
161           used to perform case insensitive matches (-i), or using extended
162           (-E) or perl (-P) regular expressions.
163
164       Returns 0 and asserts PASS when "file" exists and contains given
165       "pattern".
166
167       rlAssertNotGrep
168
169       Assertion checking that the file does not contain a pattern.
170
171           rlAssertNotGrep pattern file [options]
172
173       pattern
174           Regular expression to be searched for.
175
176       file
177           Path to the file.
178
179       options
180           Optional parameters to be passed to grep, default is "-q". Can be
181           used to perform case insensitive matches (-i), or using extended
182           (-E) or perl (-P) regular expressions.
183
184       Returns 0 and asserts PASS when "file" exists and does not contain
185       given "pattern".
186
187       rlAssertDiffer
188
189       Assertion checking that two files differ (are not identical).
190
191           rlAssertDiffer file1 file2
192
193       file1
194           Path to first file1
195
196       file2
197           Path to second file
198
199       Returns 0 and asserts PASS when "file1" and "file2" differs.
200
201       rlAssertNotDiffer
202
203       Assertion checking that two files do not differ (are identical).
204
205           rlAssertNotDiffer file1 file2
206
207       file1
208           Path to first file1
209
210       file2
211           Path to second file
212
213       Returns 0 and asserts PASS when "file1" and "file2" do not differ.
214
215   Run, Watch, Report
216       rlRun
217
218       Run command with optional comment and make sure its exit code matches
219       expectations.
220
221           rlRun [-t] [-l] [-s] command [status[,status...]] [comment]
222
223       -t  If specified, stdout and stderr of the command output will be
224           tagged with strigs 'STDOUT: ' and 'STDERR: '.
225
226       -l  If specified, output of the command (tagged, if -t was specified)
227           is logged using rlLog function.
228
229       -s  Store stdout and stderr to a file (mixed together, as the user
230           would see it on a terminal) and set $rlRun_LOG variable to name of
231           the file. Caller is responsible for removing the file. When -t
232           option is used, the content of the file becomes tagged too.
233
234           If the -s option is not used, $rlRun_LOG is not modified and keeps
235           its content from the last "rlRun -s".
236
237       command
238           Command to run.
239
240       status
241           Expected exit code(s). Optional, default 0. If you expect more exit
242           codes, separate them with comma (e.g. "0,1" when both 0 and 1 are
243           OK and expected), or use from-to notation (i.e. "2-5" for
244           "2,3,4,5"), or combine them (e.g. "2-4,26" for "2,3,4,26").
245
246       comment
247           Short summary describing the action (optional, but recommended -
248           explain what are you doing here).
249
250       Returns the exit code of the command run. Asserts PASS when command's
251       exit status is in the list of expected exit codes.
252
253       Note: The output of rlRun is buffered when using "-t", "-l" or "-s"
254       option (they use unix pipes, which are buffered by nature). If you need
255       an unbuffered output just make sure that "expect" package is installed
256       on your system (its "unbuffer" tool will automatically be used to
257       produce unbuffered output).
258
259       rlWatchdog
260
261       Run "command". If it does not finish in specified time, then kill it
262       using "signal".
263
264           rlWatchdog command timeout [signal]
265
266       command
267           Command to run.
268
269       timeout
270           Timeout to wait, in seconds.
271
272       signal
273           Signal to use (optional, default KILL).
274
275       Returns 0 if the command ends normally, without need to be killed.
276
277       rlReport
278
279       Report test result to the test harness. The command to be used for
280       reporting is set by the respective plugin. You can also use the
281       $BEAKERLIB_COMMAND_REPORT_RESULT variable to use your custom command.
282
283           rlReport name result [score] [log]
284
285       name
286           Name of the test result.
287
288       result
289           Result (one of PASS, WARN, FAIL). If called with something else,
290           will use WARN.
291
292       score
293           Test score (optional).
294
295       log Optional log file to be submitted instead of default "OUTPUTFILE".
296

AUTHORS

298       ·   Ondrej Hudlicky <ohudlick@redhat.com>
299
300       ·   Petr Muller <pmuller@redhat.com>
301
302       ·   Jan Hutar <jhutar@redhat.com>
303
304       ·   Petr Splichal <psplicha@redhat.com>
305
306       ·   Ales Zelinka <azelinka@redhat.com>
307
308
309
310perl v5.10.1                      2010-05-12                     TESTING.SH(1)
Impressum