~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/test_server/doc/src/test_server_ctrl.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
 
3
 
 
4
<erlref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>2007</year>
 
8
      <year>2008</year>
 
9
      <holder>Ericsson AB, All Rights Reserved</holder>
 
10
    </copyright>
 
11
    <legalnotice>
 
12
  The contents of this file are subject to the Erlang Public License,
 
13
  Version 1.1, (the "License"); you may not use this file except in
 
14
  compliance with the License. You should have received a copy of the
 
15
  Erlang Public License along with this software. If not, it can be
 
16
  retrieved online at http://www.erlang.org/.
 
17
 
 
18
  Software distributed under the License is distributed on an "AS IS"
 
19
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
20
  the License for the specific language governing rights and limitations
 
21
  under the License.
 
22
 
 
23
  The Initial Developer of the Original Code is Ericsson AB.
 
24
    </legalnotice>
 
25
 
 
26
    <title>The Test Server Controller</title>
 
27
    <prepared>Siri Hansen</prepared>
 
28
    <responsible></responsible>
 
29
    <docno></docno>
 
30
    <approved></approved>
 
31
    <checked></checked>
 
32
    <date></date>
 
33
    <rev></rev>
 
34
    <file>test_server_ctrl_ref.sgml</file>
 
35
  </header>
 
36
  <module>test_server_ctrl</module>
 
37
  <modulesummary>This module provides a low level interface to the Test Server.</modulesummary>
 
38
  <description>
 
39
    <p>The <c>test_server_ctrl</c> module provides a low level
 
40
      interface to the Test Server. This interface is normally
 
41
      not used directly by the tester, but through a framework built 
 
42
      on top of <c>test_server_ctrl</c>.
 
43
      </p>
 
44
    <p>Common Test is such a framework, well suited for automated
 
45
      black box testing of target systems of any kind (not necessarily
 
46
      implemented in Erlang). Common Test is also a very useful tool for
 
47
      white box testing Erlang programs and OTP applications. 
 
48
      Please see the Common Test User's Guide and reference manual for 
 
49
      more information.
 
50
      </p>
 
51
    <p>If you want to write your own framework, some more information
 
52
      can be found in the chapter "Writing your own test server
 
53
      framework" in the Test Server User's Guide. Details about the
 
54
      interface provided by <c>test_server_ctrl</c> follows below.
 
55
      </p>
 
56
  </description>
 
57
  <funcs>
 
58
    <func>
 
59
      <name>start() -> Result</name>
 
60
      <name>start(ParameterFile) -> Result</name>
 
61
      <fsummary>Starts the test server.</fsummary>
 
62
      <type>
 
63
        <v>Result = ok | {error, {already_started, pid()}</v>
 
64
        <v>ParameterFile = atom() | string()</v>
 
65
      </type>
 
66
      <desc>
 
67
        <p>This function starts the test server. If the parameter file
 
68
          is given, it indicates that the target is remote. In that case
 
69
          the target node is started and a socket connection is
 
70
          established between the controller and the target node.
 
71
          </p>
 
72
        <p>The parameter file is a text file containing key-value
 
73
          tuples. Each tuple must be followed by a dot-newline
 
74
          sequence. The following key-value tuples are allowed:
 
75
          </p>
 
76
        <taglist>
 
77
          <tag><c>{type,PlatformType}</c></tag>
 
78
          <item>This is an atom indicating the target platform type,
 
79
           currently supported: <c>PlatformType = vxworks</c>          <br></br>
 
80
Mandatory
 
81
          </item>
 
82
          <tag><c>{target,TargetHost}</c></tag>
 
83
          <item>This is the name of the target host, can be atom or
 
84
           string.
 
85
                    <br></br>
 
86
Mandatory
 
87
          </item>
 
88
          <tag><c>{slavetargets,SlaveTargets}</c></tag>
 
89
          <item>This is a list of available hosts where slave nodes
 
90
           can be started. The hostnames are given as atoms or strings.
 
91
                    <br></br>
 
92
Optional, default <c>SlaveTargets = []</c></item>
 
93
          <tag><c>{longnames,Bool}</c></tag>
 
94
          <item>This indicates if longnames shall be used, i.e. if the
 
95
          <c>-name</c> option should be used for the target node
 
96
           instead of <c>-sname</c>          <br></br>
 
97
Optional, default <c>Bool = false</c></item>
 
98
          <tag><c>{master, {MasterHost, MasterCookie}}</c></tag>
 
99
          <item>If target is remote and the target node is started as
 
100
           a slave node, this option indicates which master and 
 
101
           cookie to use. The given master
 
102
           will also be used as master for slave nodes started with
 
103
          <c>test_server:start_node/3</c>. It is expected that the
 
104
          <c>erl_boot_server</c> is started on the master node before
 
105
           the <c>test_server_ctrl:start/1</c> function is called.
 
106
                    <br></br>
 
107
Optional, if not given the test server controller node
 
108
           is used as master and the <c>erl_boot_server</c> is
 
109
           automatically started.</item>
 
110
        </taglist>
 
111
      </desc>
 
112
    </func>
 
113
    <func>
 
114
      <name>stop() -> ok</name>
 
115
      <fsummary>Stops the test server immediately.</fsummary>
 
116
      <desc>
 
117
        <p>This stops the test server (both controller and target) and
 
118
          all its activity.  The running test suite (if any) will be
 
119
          halted.</p>
 
120
      </desc>
 
121
    </func>
 
122
    <func>
 
123
      <name>add_dir(Name, Dir) -> ok</name>
 
124
      <name>add_dir(Name, Dir, Pattern) -> ok</name>
 
125
      <name>add_dir(Name, [Dir|Dirs]) -> ok</name>
 
126
      <name>add_dir(Name, [Dir|Dirs], Pattern) -> ok</name>
 
127
      <fsummary>Add a directory to the job queue.</fsummary>
 
128
      <type>
 
129
        <v>Name = term()</v>
 
130
        <d>The jobname for this directory.</d>
 
131
        <v>Dir = term()</v>
 
132
        <d>The directory to scan for test suites.</d>
 
133
        <v>Dirs = [term()]</v>
 
134
        <d>List of directories to scan for test suites.</d>
 
135
        <v>Pattern = term()</v>
 
136
        <d>Suite match pattern. Directories will be scanned for Pattern_SUITE.erl files.</d>
 
137
      </type>
 
138
      <desc>
 
139
        <p>Puts a collection of suites matching (*_SUITE) in given
 
140
          directories into the job queue. <c>Name</c> is an arbitrary
 
141
          name for the job, it can be any erlang term. If <c>Pattern</c>
 
142
          is given, only modules matching <c>Pattern*</c> will be added.</p>
 
143
      </desc>
 
144
    </func>
 
145
    <func>
 
146
      <name>add_module(Mod) -> ok</name>
 
147
      <name>add_module(Name, [Mod|Mods]) -> ok</name>
 
148
      <fsummary>Add a module to the job queue with or without a given name.</fsummary>
 
149
      <type>
 
150
        <v>Mod = atom()</v>
 
151
        <v>Mods = [atom()]</v>
 
152
        <d>The name(s) of the module(s) to add.</d>
 
153
        <v>Name = term()</v>
 
154
        <d>Name for the job.</d>
 
155
      </type>
 
156
      <desc>
 
157
        <p>This function adds a module or a list of modules, to the
 
158
          test servers job queue. <c>Name</c> may be any Erlang
 
159
          term. When <c>Name</c> is not given, the job gets the name of
 
160
          the module.</p>
 
161
      </desc>
 
162
    </func>
 
163
    <func>
 
164
      <name>add_case(Mod, Case) -> ok</name>
 
165
      <fsummary>Adds one test case to the job queue.</fsummary>
 
166
      <type>
 
167
        <v>Mod = atom()</v>
 
168
        <d>Name of the module the test case is in.</d>
 
169
        <v>Case = atom() </v>
 
170
        <d>Function name of the test case to add.</d>
 
171
      </type>
 
172
      <desc>
 
173
        <p>This function will add one test case to the job queue. The
 
174
          job will be given the module's name.</p>
 
175
      </desc>
 
176
    </func>
 
177
    <func>
 
178
      <name>add_case(Name, Mod, Case) -> ok</name>
 
179
      <fsummary>Equivalent to add_case/2, but with specified name.</fsummary>
 
180
      <type>
 
181
        <v>Name = string()</v>
 
182
        <d>Name to use for the test job.</d>
 
183
      </type>
 
184
      <desc>
 
185
        <p>Equivalent to <c>add_case/2</c>, but the test job will get
 
186
          the specified name.</p>
 
187
      </desc>
 
188
    </func>
 
189
    <func>
 
190
      <name>add_cases(Mod, Cases) -> ok</name>
 
191
      <fsummary>Adds a list of test cases to the job queue.</fsummary>
 
192
      <type>
 
193
        <v>Mod = atom()</v>
 
194
        <d>Name of the module the test case is in.</d>
 
195
        <v>Cases = [Case] </v>
 
196
        <v>Case = atom() </v>
 
197
        <d>Function names of the test cases to add.</d>
 
198
      </type>
 
199
      <desc>
 
200
        <p>This function will add one or more test cases to the job
 
201
          queue. The job will be given the module's name.</p>
 
202
      </desc>
 
203
    </func>
 
204
    <func>
 
205
      <name>add_cases(Name, Mod, Cases) -> ok</name>
 
206
      <fsummary>Equivalent to add_cases/2, but with specified name.</fsummary>
 
207
      <type>
 
208
        <v>Name = string()</v>
 
209
        <d>Name to use for the test job.</d>
 
210
      </type>
 
211
      <desc>
 
212
        <p>Equivalent to <c>add_cases/2</c>, but the test job will get
 
213
          the specified name.</p>
 
214
      </desc>
 
215
    </func>
 
216
    <func>
 
217
      <name>add_spec(TestSpecFile) -> ok | {error, nofile}</name>
 
218
      <fsummary>Adds a test specification file to the job queue.</fsummary>
 
219
      <type>
 
220
        <v>TestSpecFile = string()</v>
 
221
        <d>Name of the test specification file</d>
 
222
      </type>
 
223
      <desc>
 
224
        <p>This function will add the content of the given test
 
225
          specification file to the job queue. The job will be given the
 
226
          name of the test specification file, e.g. if the file is
 
227
          called <c>test.spec</c>, the job will be called <c>test</c>.
 
228
          </p>
 
229
        <p>See the reference manual for the test server application
 
230
          for details about the test specification file.</p>
 
231
      </desc>
 
232
      </func>
 
233
      <func>
 
234
        <name>add_dir_with_skip(Name, [Dir|Dirs], Skip) -> ok</name>
 
235
        <name>add_dir_with_skip(Name, [Dir|Dirs], Pattern, Skip) -> ok</name>
 
236
        <name>add_module_with_skip(Mod, Skip) -> ok</name>
 
237
        <name>add_module_with_skip(Name, [Mod|Mods], Skip) -> ok</name>
 
238
        <name>add_case_with_skip(Mod, Case, Skip) -> ok</name>
 
239
        <name>add_case_with_skip(Name, Mod, Case, Skip) -> ok</name>
 
240
        <name>add_cases_with_skip(Mod, Cases, Skip) -> ok</name>
 
241
        <name>add_cases_with_skip(Name, Mod, Cases, Skip) -> ok</name>
 
242
        <fsummary>Same purpose as functions listed above, but with extra Skip argument.</fsummary>
 
243
        <type>
 
244
        <v>Skip = [SkipItem]</v>
 
245
        <d>List of items to be skipped from the test.</d>
 
246
        <v>SkipItem = {Mod,Comment} | {Mod,Case,Comment} | {Mod,Cases,Comment}</v>
 
247
        <v>Mod = atom()</v>
 
248
        <d>Test suite name.</d>
 
249
        <v>Comment = string()</v>
 
250
        <d>Reason why suite or case is being skipped.</d>
 
251
        <v>Cases = [Case]</v>
 
252
        <v>Case = atom()</v>
 
253
        <d>Name of test case function.</d>
 
254
        </type>
 
255
        <desc>
 
256
          <p>These functions add test jobs just like the add_dir, add_module,
 
257
            add_case and add_cases functions above, but carry an additional
 
258
            argument, Skip. Skip is a list of items that should be skipped
 
259
            in the current test run. Test job items that occur in the Skip
 
260
            list will be logged as SKIPPED with the associated Comment.</p>
 
261
        </desc>
 
262
    </func>
 
263
    <func>
 
264
      <name>add_tests_with_skip(Name, Tests, Skip) -> ok</name>
 
265
      <fsummary>Adds different types of jobs to the run queue.</fsummary>
 
266
      <type>
 
267
        <v>Name = term()</v>
 
268
        <d>The jobname for this directory.</d>
 
269
        <v>Tests = [TestItem]</v>
 
270
        <d>List of jobs to add to the run queue.</d>
 
271
        <v>TestItem = {Dir,all,all} | {Dir,Mods,all} | {Dir,Mod,Cases}</v>
 
272
        <v>Dir = term()</v>
 
273
        <d>The directory to scan for test suites.</d>
 
274
        <v>Mods = [Mod]</v>
 
275
        <v>Mod = atom()</v>
 
276
        <d>Test suite name.</d>
 
277
        <v>Cases = [Case]</v>
 
278
        <v>Case = atom()</v>
 
279
        <d>Name of test case function.</d>
 
280
        <v>Skip = [SkipItem]</v>
 
281
        <d>List of items to be skipped from the test.</d>
 
282
        <v>SkipItem = {Mod,Comment} | {Mod,Case,Comment} | {Mod,Cases,Comment}</v>
 
283
        <v>Comment = string()</v>
 
284
        <d>Reason why suite or case is being skipped.</d>
 
285
      </type>
 
286
        <desc>
 
287
        <p>This function adds various test jobs to the test_server_ctrl
 
288
        job queue. These jobs can be of different type (all or specific suites 
 
289
        in one directory, all or specific cases in one suite, etc). It is also
 
290
        possible to get particular items skipped by passing them along in the
 
291
        Skip list (see the add_*_with_skip functions above).</p>
 
292
        </desc>
 
293
    </func>
 
294
    <func>
 
295
      <name>abort_current_testcase(Reason) -> ok | {error,no_testcase_running}</name>
 
296
      <fsummary>Aborts the test case currently executing.</fsummary>
 
297
      <type>
 
298
      <v>Reason = term()</v>
 
299
      <d>The reason for stopping the test case, which will be printed in the log.</d>
 
300
      </type>
 
301
        <desc>
 
302
        <p>When calling this function, the currently executing test case will be aborted.
 
303
           It is the user's responsibility to know for sure which test case is currently
 
304
           executing. The function is therefore only safe to call from a function which
 
305
           has been called (or synchronously invoked) by the test case.</p>
 
306
        </desc>
 
307
    </func>
 
308
    <func>
 
309
      <name>set_levels(Console, Major, Minor) -> ok</name>
 
310
      <fsummary>Sets the levels of I/O.</fsummary>
 
311
      <type>
 
312
        <v>Console = integer()</v>
 
313
        <d>Level for I/O to be sent to console.</d>
 
314
        <v>Major = integer()</v>
 
315
        <d>Level for I/O to be sent to the major logfile.</d>
 
316
        <v>Minor = integer()</v>
 
317
        <d>Level for I/O to be sent to the minor logfile.</d>
 
318
      </type>
 
319
      <desc>
 
320
        <p>Determines where I/O from test suites/test server will
 
321
          go. All text output from test suites and the test server is
 
322
          tagged with a priority value which ranges from 0 to 100, 100
 
323
          being the most detailed. (see the section about log files in
 
324
          the user's guide). Output from the test cases (using
 
325
          <c>io:format/2</c>) has a detail level of 50. Depending on the
 
326
          levels set by this function, this I/O may be sent to the
 
327
          console, the major log file (for the whole test suite) or to
 
328
          the minor logfile (separate for each test case).
 
329
          </p>
 
330
        <p>All output with detail level:</p>
 
331
        <list type="bulleted">
 
332
          <item>Less than or equal to <c>Console</c> is displayed on
 
333
           the screen (default 1)
 
334
          </item>
 
335
          <item>Less than or equal to <c>Major</c> is logged in the
 
336
           major log file (default 19)
 
337
          </item>
 
338
          <item>Greater than or equal to <c>Minor</c> is logged in the
 
339
           minor log files (default 10)
 
340
          </item>
 
341
        </list>
 
342
        <p>To view the currently set thresholds, use the
 
343
          <c>get_levels/0</c> function.</p>
 
344
      </desc>
 
345
    </func>
 
346
    <func>
 
347
      <name>get_levels() -> {Console, Major, Minor}</name>
 
348
      <fsummary>Returns the current levels.</fsummary>
 
349
      <desc>
 
350
        <p>Returns the current levels. See <c>set_levels/3</c> for
 
351
          types.</p>
 
352
      </desc>
 
353
    </func>
 
354
    <func>
 
355
      <name>jobs() -> JobQueue</name>
 
356
      <fsummary>Returns the job queue.</fsummary>
 
357
      <type>
 
358
        <v>JobQueue = [{list(), pid()}]</v>
 
359
      </type>
 
360
      <desc>
 
361
        <p>This function will return all the jobs currently in the job
 
362
          queue.</p>
 
363
      </desc>
 
364
    </func>
 
365
    <func>
 
366
      <name>multiply_timetraps(N) -> ok</name>
 
367
      <fsummary>All timetraps started after this will be multiplied by N.</fsummary>
 
368
      <type>
 
369
        <v>N = integer() | infinity</v>
 
370
      </type>
 
371
      <desc>
 
372
        <p>This function should be called before a test is started
 
373
          which requires extended timetraps, e.g. if extensivie tracing
 
374
          is used. All timetraps started after this call will be
 
375
          multiplied by <c>N</c>.</p>
 
376
      </desc>
 
377
    </func>
 
378
    <func>
 
379
      <name>cover(Application,Analyse) -> ok</name>
 
380
      <name>cover(CoverFile,Analyse) -> ok</name>
 
381
      <name>cover(App,CoverFile,Analyse) -> ok</name>
 
382
      <fsummary>Informs the test_server controller that next test shall run with code coverage analysis.</fsummary>
 
383
      <type>
 
384
        <v>Application = atom()</v>
 
385
        <d>OTP application to cover compile</d>
 
386
        <v>CoverFile = string()</v>
 
387
        <d>Name of file listing modules to exclude from or include in cover compilation. The filename must include full path to the file.</d>
 
388
        <v>Analyse = details | overview</v>
 
389
      </type>
 
390
      <desc>
 
391
        <p>This function informs the test_server controller that next
 
392
          test shall run with code coverage analysis. All timetraps will
 
393
          automatically be multiplied by 10 when cover i run.
 
394
          </p>
 
395
        <p><c>Application</c> and <c>CoverFile</c> indicates what to
 
396
          cover compile. If <c>Application</c> is given, the default is
 
397
          that all modules in the <c>ebin</c> directory of the
 
398
          application will be cover compiled. The <c>ebin</c> directory
 
399
          is found by adding <c>ebin</c> to
 
400
          <c>code:lib_dir(Application)</c>.
 
401
          </p>
 
402
        <p>A <c>CoverFile</c> can have the following entries:</p>
 
403
        <code type="none">
 
404
{exclude, all | ExcludeModuleList}.
 
405
{include, IncludeModuleList}.        </code>
 
406
        <p>Note that each line must end with a full
 
407
          stop. <c>ExcludeModuleList</c> and <c>IncludeModuleList</c>
 
408
          are lists of atoms, where each atom is a module name.
 
409
          </p>
 
410
        <p>If both an <c>Application</c> and a <c>CoverFile</c> is
 
411
          given, all modules in the application are cover compiled,
 
412
          except for the modules listed in <c>ExcludeModuleList</c>. The
 
413
          modules in <c>IncludeModuleList</c> are also cover compiled.
 
414
          </p>
 
415
        <p>If a <c>CoverFile</c> is given, but no <c>Application</c>,
 
416
          only the modules in <c>IncludeModuleList</c> are cover
 
417
          compiled.
 
418
          </p>
 
419
        <p><c>Analyse</c> indicates the detail level of the cover
 
420
          anlysis. If <c>Analyse = details</c>, each cover compiled
 
421
          module will be analysed with
 
422
          <c>cover:analyse_to_file/1</c>. If <c>Analyse = overview</c>
 
423
          an overview of all cover compiled modules is created, listing
 
424
          the number of covered and not covered lines for each module.
 
425
          </p>
 
426
        <p>If the test following this call starts any slave or peer
 
427
          nodes with <c>test_server:start_node/3</c>, the same cover
 
428
          compiled code will be loaded on all nodes. If the loading
 
429
          fails, e.g. if the node runs an old version of OTP, the node
 
430
          will simply not be a part of the coverage analysis. Note that
 
431
          slave or peer nodes must be stopped with
 
432
          <c>test_server:stop_node/1</c> for the node to be part of the
 
433
          coverage analysis, else the test server will not be able to
 
434
          fetch coverage data from the node.
 
435
          </p>
 
436
        <p>When the test is finished, the coverage analysis is
 
437
          automatically completed, logs are created and the cover
 
438
          compiled modules are unloaded. If another test is to be run
 
439
          with coverage analysis, <c>test_server_ctrl:cover/2/3</c> must
 
440
          be called again.
 
441
          </p>
 
442
      </desc>
 
443
    </func>
 
444
    <func>
 
445
      <name>cross_cover_analyse(Level) -> ok</name>
 
446
      <fsummary>Analyse cover data collected from all tests</fsummary>
 
447
      <type>
 
448
        <v>Level = details | overview</v>
 
449
      </type>
 
450
      <desc>
 
451
        <p>Analyse cover data collected from all tests. The modules
 
452
          analysed are the ones listed in the cross cover file
 
453
          <c>cross.cover</c> in the current directory of the test
 
454
          server.</p>
 
455
        <p>The modules listed in the <c>cross.cover</c> file are
 
456
          modules that are heavily used by other applications than the
 
457
          one they belong to. This function should be run after all
 
458
          tests are completed, and the result will be stored in a file
 
459
          called cross_cover.html in the run.&lt;timestamp&gt;
 
460
          directory of the application the modules belong to.
 
461
          </p>
 
462
        <p>The <c>cross.cover</c> file contains elements like this:</p>
 
463
        <pre>
 
464
{App,Modules}.        </pre>
 
465
        <p>where <c>App</c> can be an application name or the atom
 
466
          <c>all</c>. The application (or all applications) will cover
 
467
          compile the listed <c>Modules</c>.
 
468
          </p>
 
469
      </desc>
 
470
    </func>
 
471
    <func>
 
472
      <name>trc(TraceInfoFile) -> ok | {error, Reason}</name>
 
473
      <fsummary>Starts call trace on target and slave nodes</fsummary>
 
474
      <type>
 
475
        <v>TraceInfoFile = atom() | string()</v>
 
476
        <d>Name of a file defining which functions to trace and how</d>
 
477
      </type>
 
478
      <desc>
 
479
        <p>This function starts call trace on target and on slave or
 
480
          peer nodes that are started or will be started by the test
 
481
          suites.
 
482
          </p>
 
483
        <p>Timetraps are not extended automatically when tracing is
 
484
          used. Use <c>multiply_timetraps/1</c> if necessary.
 
485
          </p>
 
486
        <p>Note that the trace support in the test server is in a very
 
487
          early stage of the implementation, and thus not yet as
 
488
          powerful as one might wish for.
 
489
          </p>
 
490
        <p>The trace information file specified by the
 
491
          <c>TraceInfoFile</c> argument is a text file containing one or
 
492
          more of the following elements:
 
493
          </p>
 
494
        <list type="bulleted">
 
495
          <item><c>{SetTP,Module,Pattern}.</c></item>
 
496
          <item><c>{SetTP,Module,Function,Pattern}.</c></item>
 
497
          <item><c>{SetTP,Module,Function,Arity,Pattern}.</c></item>
 
498
          <item><c>ClearTP.</c></item>
 
499
          <item><c>{ClearTP,Module}.</c></item>
 
500
          <item><c>{ClearTP,Module,Function}.</c></item>
 
501
          <item><c>{ClearTP,Module,Function,Arity}.</c></item>
 
502
        </list>
 
503
        <taglist>
 
504
          <tag><c>SetTP = tp | tpl</c></tag>
 
505
          <item>This is maps to the corresponding functions in the
 
506
          <c>ttb</c> module in the <c>observer</c>
 
507
           application. <c>tp</c> means set trace pattern on global
 
508
           function calls. <c>tpl</c> means set trace pattern on local
 
509
           and global function calls.
 
510
          </item>
 
511
          <tag><c>ClearTP =  ctp | ctpl | ctpg</c></tag>
 
512
          <item>This is maps to the corresponding functions in the
 
513
          <c>ttb</c> module in the <c>observer</c>
 
514
           application. <c>ctp</c> means clear trace pattern (i.e. turn
 
515
           off) on global and local function calls. <c>ctpl</c> means
 
516
           clear trace pattern on local function calls only and <c>ctpg</c>
 
517
           means clear trace pattern on global function calls only.
 
518
          </item>
 
519
          <tag><c>Module = atom()</c></tag>
 
520
          <item>The module to trace
 
521
          </item>
 
522
          <tag><c>Function = atom()</c></tag>
 
523
          <item>The name of the function to trace
 
524
          </item>
 
525
          <tag><c>Arity = integer()</c></tag>
 
526
          <item>The arity of the function to trace
 
527
          </item>
 
528
          <tag><c>Pattern = [] | match_spec()</c></tag>
 
529
          <item>The trace pattern to set for the module or
 
530
           function. For a description of the match_spec() syntax,
 
531
           please turn to the User's guide for the runtime system
 
532
           (erts). The chapter "Match Specification in Erlang" explains
 
533
           the general match specification language.
 
534
          </item>
 
535
        </taglist>
 
536
        <p>The trace result will be logged in a (binary) file called
 
537
          <c>NodeName-test_server</c> in the current directory of the
 
538
          test server controller node. The log must be formatted using
 
539
          <c>ttb:format/1/2</c>.
 
540
          </p>
 
541
        <p>This is valid for all targets except the OSE/Delta target
 
542
          for which all nodes will be logged and automatically formatted
 
543
          in one single text file called <c>allnodes-test_server</c>.</p>
 
544
      </desc>
 
545
    </func>
 
546
    <func>
 
547
      <name>stop_trace() -> ok | {error, not_tracing}</name>
 
548
      <fsummary>Stops tracing on target and slave nodes.</fsummary>
 
549
      <desc>
 
550
        <p>This function stops tracing on target, and on slave or peer
 
551
          nodes that are currently running. New slave or peer nodes will
 
552
          no longer be traced after this.</p>
 
553
      </desc>
 
554
    </func>
 
555
  </funcs>
 
556
 
 
557
  <section>
 
558
    <title>FUNCTIONS INVOKED FROM COMMAND LINE</title>
 
559
    <p>The following functions are supposed to be invoked from the
 
560
      command line using the <c>-s</c> option when starting the erlang
 
561
      node.</p>
 
562
  </section>
 
563
  <funcs>
 
564
    <func>
 
565
      <name>run_test(CommandLine) -> ok</name>
 
566
      <fsummary>Runs the tests specified on the command line.</fsummary>
 
567
      <type>
 
568
        <v>CommandLine = FlagList</v>
 
569
      </type>
 
570
      <desc>
 
571
        <p>This function is supposed to be invoked from the
 
572
          commandline. It starts the test server, interprets the
 
573
          argument supplied from the commandline, runs the tests
 
574
          specified and when all tests are done, stops the test server
 
575
          and returns to the Erlang prompt.
 
576
          </p>
 
577
        <p>The <c>CommandLine</c> argument is a list of command line
 
578
          flags, typically <c>['KEY1', Value1, 'KEY2', Value2, ...]</c>. 
 
579
          The valid command line flags are listed below.
 
580
          </p>
 
581
        <p>Under a UNIX command prompt, this function can be invoked like this:
 
582
                    <br></br>
 
583
<c>erl -noshell -s test_server_ctrl run_test KEY1 Value1 KEY2 Value2 ... -s erlang halt</c></p>
 
584
        <p>Or make an alias (this is for unix/tcsh)          <br></br>
 
585
<c>alias erl_test 'erl -noshell -s test_server_ctrl run_test \\!* -s erlang halt'</c></p>
 
586
        <p>And then use it like this          <br></br>
 
587
<c>erl_test KEY1 Value1 KEY2 Value2 ...</c>          <br></br>
 
588
</p>
 
589
        <p>The valid command line flags are</p>
 
590
        <taglist>
 
591
          <tag><c>DIR dir</c></tag>
 
592
          <item>Adds all test modules in the directory <c>dir</c> to
 
593
           the job queue.
 
594
          </item>
 
595
          <tag><c>MODULE mod</c></tag>
 
596
          <item>Adds the module <c>mod</c> to the job queue.
 
597
          </item>
 
598
          <tag><c>CASE mod case</c></tag>
 
599
          <item>Adds the case <c>case</c> in module <c>mod</c> to the
 
600
           job queue.
 
601
          </item>
 
602
          <tag><c>SPEC spec</c></tag>
 
603
          <item>Runs the test specification file <c>spec</c>.
 
604
          </item>
 
605
          <tag><c>SKIPMOD mod</c></tag>
 
606
          <item>Skips all test cases in the module <c>mod</c></item>
 
607
          <tag><c>SKIPCASE mod case</c></tag>
 
608
          <item>Skips the test case <c>case</c> in module <c>mod</c>.
 
609
          </item>
 
610
          <tag><c>NAME name</c></tag>
 
611
          <item>Names the test suite to something else than the
 
612
           default name. This does not apply to <c>SPEC</c> which keeps
 
613
           it's names.
 
614
          </item>
 
615
          <tag><c>PARAMETERS parameterfile</c></tag>
 
616
          <item>Specifies the parameter file to use when starting
 
617
           remote target
 
618
          </item>
 
619
          <tag><c>COVER app cover_file analyse</c></tag>
 
620
          <item>Indicates that the test should be run with cover
 
621
           alanysis. <c>app</c>, <c>cover_file</c> and <c>analyse</c>
 
622
           corresponds to the parameters to
 
623
          <c>test_server_ctrl:cover/3</c>. If no cover file is used,
 
624
           the atom <c>none</c> should be given.
 
625
          </item>
 
626
          <tag><c>TRACE traceinfofile</c></tag>
 
627
          <item>Specifies a trace information file. When this option
 
628
           is given, call tracing is started on the target node and all
 
629
           slave or peer nodes that are started. The trace information
 
630
           file specifies which modules and functions to trace. See the
 
631
           function <c>trc/1</c> above for more information about the
 
632
           syntax of this file.
 
633
          </item>
 
634
        </taglist>
 
635
      </desc>
 
636
    </func>
 
637
  </funcs>
 
638
 
 
639
  <section>
 
640
    <title>FRAMEWORK CALLBACK FUNCTIONS</title>
 
641
    <p>A test server framework can be defined by setting the
 
642
      environment variable <c>TEST_SERVER_FRAMEWORK</c> to a module
 
643
      name. This module will then be framework callback module, and it
 
644
      must export the following function:</p>
 
645
  </section>
 
646
  <funcs>
 
647
    <func>
 
648
      <name>get_suite(Mod,Func) -> TestCaseList</name>
 
649
      <fsummary>Get subcases.</fsummary>
 
650
      <type>
 
651
        <v>Mod = atom()</v>
 
652
        <v>Func = atom()</v>
 
653
        <v>TestCaseList = [,SubCase]</v>
 
654
      </type>
 
655
      <desc>
 
656
        <p>This function is called before a test case is started. The
 
657
          purpose is to retrieve a list of subcases. The default
 
658
          behaviour of this function should be to call
 
659
          <c>Mod:Func(suite)</c> and return the result from this call.</p>
 
660
      </desc>
 
661
    </func>
 
662
    <func>
 
663
      <name>init_tc(Mod,Func,Args) -> {ok,Args}</name>
 
664
      <fsummary>Preparation for a test case.</fsummary>
 
665
      <type>
 
666
        <v>Mod = atom()</v>
 
667
        <v>Func = atom()</v>
 
668
        <v>Args = [tuple()]</v>
 
669
        <d>Normally Args = [Config]</d>
 
670
      </type>
 
671
      <desc>
 
672
        <p>This function is called when a test case is started. It is
 
673
          called on the process executing the test case function
 
674
          (<c>Mod:Func</c>). Typical use of this function can be to alter
 
675
          the input parameters to the test case function (<c>Args</c>) or
 
676
          to set properties for the executing process.</p>
 
677
      </desc>
 
678
    </func>
 
679
    <func>
 
680
      <name>end_tc(Mod,Func,Args) -> ok</name>
 
681
      <fsummary>Cleanup after a test case.</fsummary>
 
682
      <type>
 
683
        <v>Mod = atom()</v>
 
684
        <v>Func = atom()</v>
 
685
        <v>Args = [tuple()]</v>
 
686
        <d>Normally Args = [Config]</d>
 
687
      </type>
 
688
      <desc>
 
689
        <p>This function is called when a test case is completed. It is
 
690
          called on the process where the test case function
 
691
          (<c>Mod:Func</c>) was executed. Typical use of this function can
 
692
          be to clean up stuff done by <c>init_tc/3</c>.</p>
 
693
      </desc>
 
694
    </func>
 
695
    <func>
 
696
      <name>report(What,Data) -> ok</name>
 
697
      <fsummary>Progress report for test.</fsummary>
 
698
      <type>
 
699
        <v>What = atom()</v>
 
700
        <v>Data = term()</v>
 
701
      </type>
 
702
      <desc>
 
703
        <p>This function is called in order to keep the framework upto
 
704
          date about the progress of the test. This is useful e.g. if the
 
705
          framework implements a GUI where the progress information is
 
706
          constantly updated. The following can be reported:
 
707
          </p>
 
708
        <p><c>What = tests_start, Data = {Name,NumCases}</c>          <br></br>
 
709
<c>What = tests_done, Data = {Ok,Failed,Skipped}</c>          <br></br>
 
710
<c>What = tc_start, Data = {Mod,Func}</c>          <br></br>
 
711
<c>What = tc_done, Data = {Mod,Func,Result}</c></p>
 
712
      </desc>
 
713
    </func>
 
714
    <func>
 
715
      <name>error_notification(Mod, Case, Args, Error) -> ok</name>
 
716
      <fsummary>Inform framework of crashing testcase.</fsummary>
 
717
      <type>
 
718
        <v>Mod = atom()</v>
 
719
        <d>Test suite name.</d>
 
720
        <v>Case = atom()</v>
 
721
        <d>Name of test case function.</d>
 
722
        <v>Args = [tuple()]</v>
 
723
        <d>Normally Args = [Config]</d>
 
724
        <v>Error = {Reason,Location}</v>
 
725
        <v>Reason = term()</v>
 
726
        <d>Reason for termination.</d>
 
727
        <v>Location = unknown | [{Mod,Case,Line}]</v>
 
728
        <d>Last known position in Mod before termination.</d>
 
729
        <v>Line = integer()</v>
 
730
        <d>Line number in file Mod.erl.</d> 
 
731
      </type>
 
732
      <desc>
 
733
        <p>This function is called as the result of testcase Mod:Case failing
 
734
          with Reason at Location. The function is intended mainly to aid
 
735
          specific logging or error handling in the framework application. Note
 
736
          that for Location to have relevant values (i.e. other than unknown), 
 
737
          the <c>line</c> macro or <c>test_server_line</c> parse transform must 
 
738
          be used. For details, please see the section about test suite line numbers
 
739
          in the <c>test_server</c> reference manual page.</p>
 
740
      </desc>
 
741
    </func>
 
742
    <func>
 
743
      <name>warn(What) -> boolean()</name>
 
744
      <fsummary>Ask framework if test server should issue a warning for What.</fsummary>
 
745
      <type>
 
746
        <v>What = processes | nodes</v>
 
747
      </type>
 
748
      <desc>
 
749
        <p>The test server checks the number of processes and nodes
 
750
          before and after the test is executed. This function is a
 
751
          question to the framework if the test server should warn when
 
752
          the number of processes or nodes has changed during the test
 
753
          execution. If <c>true</c> is returned, a warning will be written
 
754
          in the test case minor log file.</p>
 
755
      </desc>
 
756
    </func>
 
757
    <func>
 
758
      <name>target_info() -> InfoStr</name>
 
759
      <fsummary>Print info about the target system to the test case log.</fsummary>
 
760
      <type>
 
761
        <v>InfoStr = string() | ""</v>
 
762
      </type>
 
763
      <desc>
 
764
        <p>The test server will ask the framework for information about
 
765
          the test target system and print InfoStr in the test case
 
766
          log file below the host information.</p>
 
767
      </desc>
 
768
    </func>
 
769
  </funcs>
 
770
</erlref>
 
771