Update testing cases due to changes of issue 24130
[occt.git] / dox / dev_guides / tests / tests.md
CommitLineData
72b7576f 1 Automated Testing System {#dev_guides__tests}
2======================================
3
4@section testmanual_1 Introduction
5
6This document provides overview and practical guidelines for work with OCCT automatic testing system.
7Reading this section *Introduction* should be sufficient for OCCT developers to use the test system
8to control non-regression of the modifications they implement in OCCT. Other sections provide
9more in-depth description of the test system, required for modifying the tests and adding new test cases.
10
11@subsection testmanual_1_1 Basic Information
12
13OCCT automatic testing system is organized around DRAW Test Harness [1],
14a console application based on Tcl (a scripting language) interpreter extended by OCCT-related commands.
15Standard OCCT tests are included with OCCT sources and are located in subdirectory *tests*
16 of the OCCT root folder. Other test folders can be included in the scope of the test system,
17 e.g. for testing applications based on OCCT.
18Logically the tests are organized in three levels:
19
20 * Group: group of related test grids, usually relating to some part of OCCT functionality (e.g. blend)
21 * Grid: set of test cases within a group, usually aimed at testing some particular aspect or mode of execution of the relevant functionality (e.g. buildevol)
22 * Test case: script implementing individual test (e.g. K4)
23
24Some tests involve data files (typically CAD models) which are located separately
25 and are not included with OCCT code. The archive with publicly available
26 test data files should be downloaded and installed independently on OCCT code from dev.opencascade.org.
27
28@subsection testmanual_1_2 Intended Use of Automatic Tests
29
30Each modification made in OCCT code must be checked for non-regression
31by running the whole set of tests. The developer who does the modification
32is responsible for running and ensuring non-regression on the tests that are available to him.
33Note that many tests are based on data files that are confidential and thus available only at OPEN CASCADE.
34Thus official certification testing of the changes before integration to master branch
35of official OCCT Git repository (and finally to the official release) is performed by OPEN CASCADE in any case.
36
37Each new non-trivial modification (improvement, bug fix, new feature) in OCCT
38should be accompanied by a relevant test case suitable for verifying that modification.
39This test case is to be added by developer who provides the modification.
40If a modification affects result of some test case(s),
41either the modification should be corrected (if it causes regression)
42or affected test cases should be updated to account for the modification.
43
44The modifications made in the OCCT code and related test scripts
45should be included in the same integration to master branch.
46
47@subsection testmanual_1_3 Quick Start
48
49@subsubsection testmanual_1_3_1 Setup
50
51Before running tests, make sure to define environment variable CSF_TestDataPath
52pointing to the directory containing test data files.
53(The publicly available data files can be downloaded
54from http://dev.opencascade.org separately from OCCT code.)
55The recommended way for that is adding a file *DrawInitAppli*
56in the directory which is current at the moment of starting DRAWEXE (normally it is $CASROOT).
57This file is evaluated automatically at the DRAW start. Example:
58
59~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
60set env(CSF_TestDataPath) d:/occt/tests_data
61return ;# this is to avoid an echo of the last command above in cout
62~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63
64All tests are run from DRAW command prompt, thus first run draw.tcl or draw.sh to start DRAW.
65
66@subsubsection testmanual_1_3_2 Running Tests
67
68To run all tests, type command *testgrid* followed by path
69to the new directory where results will be saved.
70It is recommended that this directory should be new or empty;
71use option –overwrite to allow writing logs in existing non-empty directory.
72
73Example:
74
75~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
76 Draw[]> testgrid d:/occt/results-2012-02-27
77~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78
79If empty string is given as log directory name, the name will be generated automatically
80using current date and time, prefixed by *results_*. Example:
81
82~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
83 Draw[]> testgrid {}
84~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85
86For running only some group or a grid of tests,
87give additional arguments indicating group and (if needed) grid. Example:
88
89~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
90 Draw[]> testgrid d:/occt/results-2012-02-28 blend simple
91~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92
93As the tests progress, the result of each test case is reported.
94At the end of the log summary of test cases is output,
95including list of detected regressions and improvements, if any. Example:
96
97
98~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
99 Tests summary
100
101 CASE 3rdparty export A1: OK
102 ...
103 CASE pipe standard B1: BAD (known problem)
104 CASE pipe standard C1: OK
105 No regressions
106 Total cases: 208 BAD, 31 SKIPPED, 3 IMPROVEMENT, 1791 OK
107 Elapsed time: 1 Hours 14 Minutes 33.7384512019 Seconds
108 Detailed logs are saved in D:/occt/results_2012-06-04T0919
109~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110
111The tests are considered as non-regressive if only OK, BAD (i.e. known problem),
112and SKIPPED (i.e. not executed, e.g. because of lack of data file) statuses are reported.
113See <a href="#testmanual_3_4">Grid’s *cases.list* file</a> chapter for details.
114
115The detailed logs of running tests are saved in the specified directory and its sub-directories.
116Cumulative HTML report summary.html provides links to reports on each test case.
117An additional report TESTS-summary.xml is output in JUnit-style XML format
118that can be used for integration with Jenkins or other continuous integration system.
119Type *help testgrid* in DRAW prompt to get help on additional options supported by testgrid command.
120
121~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
122 Draw[3]> help testgrid
123 testgrid: Run all tests, or specified group, or one grid
124 Use: testgrid logdir [group [grid]] [options...]
125 Allowed options are:
126 -verbose {0-2}: verbose level, 0 by default, can be set to 1 or 2
127 -parallel N: run in parallel with up to N processes (default 0)
128 -refresh N: save summary logs every N seconds (default 60)
129 -overwrite: force writing logs in existing non-empty directory
130~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131
132@subsubsection testmanual_1_3_3 Running Single Test
133
134To run single test, type command *test*’ followed by names of group, grid, and test case.
135
136Example:
137
138~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
139 Draw[1]> test blend simple A1
140 CASE blend simple A1: OK
141 Draw[2]>
142~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143
144Note that normally intermediate output of the script is not shown.
145To see intermediate commands and their output, type command *decho on*
146before running the test case. (Type ‘decho off’ to disable echoing when not needed.)
147The detailed log of the test can also be obtained after the test execution by command *dlog get*.
148
149@section testmanual_2 Organization of Test Scripts
150
151@subsection testmanual_2_1 General Layout
152
153Standard OCCT tests are located in subdirectory tests of the OCCT root folder ($CASROOT).
154Additional test folders can be added to the test system
155by defining environment variable CSF_TestScriptsPath.
156This should be list of paths separated by semicolons (*;*) on Windows
157or colons (*:*) on Linux or Mac. Upon DRAW launch,
158path to tests sub-folder of OCCT is added at the end of this variable automatically.
159Each test folder is expected to contain:
160
161 * Optional file parse.rules defining patterns for interpretation of test results, common for all groups in this folder
162 * One or several test group directories.
163
164Each group directory contains:
165
166 * File grids.list that identifies this test group and defines list of test grids in it.
167 * Test grids (sub-directories), each containing set of scripts for test cases, and optional files cases.list, parse.rules, begin, and end.
168 * Optional sub-directory data
169 * Optional file parse.rules
170 * Optional files begin and end
171
172By convention, names of test groups, grids, and cases should contain no spaces and be lowercase.
173Names begin, end, data, parse.rules, grids.list, cases.list are reserved.
174General layout of test scripts is shown on Figure 1.
175
dba69de2 176@image html /dev_guides/tests/images/tests_image001.png
177@image latex /dev_guides/tests/images/tests_image001.png
72b7576f 178
179Figure 1. Layout of tests folder
180
181@subsection testmanual_2_2 Test Groups
182
183@subsubsection testmanual_2_2_1 Group Names
184
185Test folder usually contains several directories representing test groups (Group 1, Group N).
186Each directory contains test grids for certain OCCT functionality.
187The name of directory corresponds to this functionality.
188Example:
189
190@verbatim
191 caf
192 mesh
193 offset
194@endverbatim
195
196@subsubsection testmanual_2_2_2 Group's *grids.list* File
197
198The test group must contain file *grids.list* file
199which defines ordered list of grids in this group in the following format:
200
201~~~~~~~~~~~~~~~~~
202001 gridname1
203002 gridname2
204...
205NNN gridnameN
206~~~~~~~~~~~~~~~~~
207
208Example:
209
210~~~~~~~~~~~~~~~~~
211 001 basic
212 002 advanced
213~~~~~~~~~~~~~~~~~
214
215@subsubsection testmanual_2_2_3 Group's *begin* File
216
217The file *begin* is a Tcl script. It is executed before every test in current group.
218Usually it loads necessary Draw commands, sets common parameters and defines
219additional Tcl functions used in test scripts.
220Example:
221
222~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
223 pload TOPTEST ;# load topological command
224 set cpulimit 300 ;# set maximum time allowed for script execution
225~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
226
227@subsubsection testmanual_2_2_4 Group's *end* File
228
229The file end is a TCL script. It is executed after every test in current group.
230Usually it checks the results of script work, makes a snap-shot
231of the viewer and writes *TEST COMPLETED* to the output.
232Note: *TEST COMPLETED* string should be presented in output
233in order to signal that test is finished without crash.
234See <a href="#testmanual_3">Creation And Modification Of Tests</a> chapter for more information.
235Example:
236
237~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
238 if { [isdraw result] } {
239 checkshape result
240 } else {
241 puts *Error: The result shape can not be built*
242 }
243 puts *TEST COMPLETED*
244~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
245
246@subsubsection testmanual_2_2_5 Group’s *parse.rules* File
247
248The test group may contain *parse.rules* file.
249This file defines patterns used for analysis of the test execution log
250and deciding the status of the test run.
251Each line in the file should specify a status (single word),
252followed by a regular expression delimited by slashes (*/*)
253that will be matched against lines in the test output log to check if it corresponds to this status.
254The regular expressions support subset of the Perl re syntax.
255The rest of the line can contain a comment message
256which will be added to the test report when this status is detected.
257Example:
258
259~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
260 FAILED /\b[Ee]xception\b/ exception
261 FAILED /\bError\b/ error
262 SKIPPED /Cannot open file for reading/ data file is missing
263 SKIPPED /Could not read file .*, abandon/ data file is missing
264~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
265
266Lines starting with a *#* character and blank lines are ignored to allow comments and spacing.
267See <a href="#testmanual_2_3_4">Interpretation of test results</a> chapter for details.
268
269If a line matches several rules, the first one applies.
270Rules defined in the grid are checked first, then rules in group,
271then rules in the test root directory. This allows defining some rules on the grid level
272with status IGNORE to ignore messages that would otherwise be treated as errors due to the group level rules.
273Example:
274
275~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
276 FAILED /\bFaulty\b/ bad shape
277 IGNORE /^Error [23]d = [\d.-]+/ debug output of blend command
278 IGNORE /^Tcl Exception: tolerance ang : [\d.-]+/ blend failure
279~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
280
281@subsection testmanual_2_3 Test Grids
282
283@subsubsection testmanual_2_3_1 Grid Names
284
285Group folder can have several sub-directories (Grid 1… Grid N) defining test grids.
286Each test grid directory contains a set of related test cases.
287The name of directory should correspond to its contents.
288
289Example:
290
291caf
292 basic
293 bugs
294 presentation
295
296Where **caf** is the name of test group and *basic*, *bugs*, *presentation*, etc are the names of grids.
297
298@subsubsection testmanual_2_3_2 Grid’s *begin* File
299
300The file *begin* is a TCL script. It is executed before every test in current grid.
301Usually it sets variables specific for the current grid.
302Example:
303
304~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
305 set command bopfuse ;# command tested in this grid
306~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
307
308@subsubsection testmanual_2_3_3 Grid’s *end* File
309
310The file *end* is a TCL script. It is executed after every test in current grid.
311Usually it executes specific sequence of commands common for all tests in the grid.
312Example:
313
314~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
315 vdump $logdir/${casename}.gif ;# makes a snap-shot of AIS viewer
316~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317
318@subsubsection testmanual_2_3_4 Grid’s *cases.list* File
319
320The grid directory can contain an optional file cases.list
321defining alternative location of the test cases.
322This file should contain singe line defining the relative path to collection of test cases.
323
324Example:
325
326../data/simple
327
328This option is used for creation of several grids of tests with the same data files
329and operations but performed with differing parameters.
330The common scripts are usually located place in common
331subdirectory of the test group (data/simple as in example).
332If cases.list file exists then grid directory should not contain any test cases.
333The specific parameters and pre- and post-processing commands
334for the tests execution in this grid should be defined in the begin and end files.
335
336@subsection testmanual_2_4 Test Cases
337
338The test case is TCL script which performs some operations using DRAW commands
339and produces meaningful messages that can be used to check the result for being valid.
340Example:
341
342~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
343 pcylinder c1 10 20 ;# create first cylinder
344 pcylinder c2 5 20 ;# create second cylinder
345 ttranslate c2 5 0 10 ;# translate second cylinder to x,y,z
346 bsection result c1 c2 ;# create a section of two cylinders
347 checksection result ;# will output error message if result is bad
348~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349
350The test case can have any name (except reserved names begin, end, data, cases.list, parse.rules).
351For systematic grids it is usually a capital English letter followed by a number.
352
353Example:
354
355@verbatim
356 A1
357 A2
358 B1
359 B2
360@endverbatim
361
362Such naming facilitates compact representation of results
363of tests execution in tabular format within HTML reports.
364
365@subsection testmanual_2_5 Directory *data*
366
367The test group may contain subdirectory data.
368Usually it contains data files used in tests (BREP, IGES, STEP, etc.)
369and / or test scripts shared by different test grids
370(in subdirectories, see <a href="#testmanual_2_3_4">Grid’s *cases.list* file</a> chapter).
371
372@section testmanual_3 Creation And Modification Of Tests
373
374This section describes how to add new tests and update existing ones.
375
376@subsection testmanual_3_1 Choosing Group, Grid, and Test Case Name
377
378The new tests are usually added in context of processing some bugs.
379Such tests in general should be added to group bugs, in the grid
380corresponding to the affected OCCT functionality.
381New grids can be added as necessary to contain tests on functionality not yet covered by existing test grids.
382The test case name in the bugs group should be prefixed by ID
383of the corresponding issue in Mantis (without leading zeroes).
384It is recommended to add a suffix providing a hint on the situation being tested.
385If more than one test is added for a bug, they should be distinguished by suffixes;
386either meaningful or just ordinal numbers.
387
388Example:
389
390~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
391 12345_coaxial
392 12345_orthogonal_1
393 12345_orthogonal_2
394~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
395
396In the case if new test corresponds to functionality for which
397specific group of tests exists (e.g. group mesh for BRepMesh issues),
398this test can be added (or moved later by OCC team) to this group.
399
400@subsection testmanual_3_2 Adding Data Files Required for a Test
401
402It is advisable that tests scripts should be made self-contained whenever possible,
403so as to be usable in environments where data files are not available.
404For that simple geometric objects and shapes can be created using DRAW commands in the test script itself.
405If test requires some data file, it should be put to subdirectory data of the test grid.
406Note that when test is integrated to master branch,
407OCC team can move data file to data files repository,
408so as to keep OCCT sources repository clean from big data files.
409When preparing a test script, try to minimize size of involved data model.
410For instance, if problem detected on a big shape can be reproduced on a single face
411extracted from that shape, use only this face in the test.
412
413@subsection testmanual_3_3 Implementation of the Script
414
415Test should run commands necessary to perform the operations being tested,
416in a clean DRAW session. This includes loading necessary functionality by *pload* command,
417if this is not done by *begin* script. The messages produced by commands in standard output
418should include identifiable messages on the discovered problems if any.
419Usually the script represents a set of commands that a person would run interactively
420to perform the operation and see its results, with additional comments to explain what happens.
421Example:
422
423~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
424 # Simple test of fusing box and sphere
425 box b 10 10 10
426 sphere s 5
427 bfuse result b s
428 checkshape result
429~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430
431Make sure that file parse.rules in the grid or group directory contains
432regular expression to catch possible messages indicating failure of the test.
433For instance, for catching errors reported by *checkshape* command
434relevant grids define a rule to recognize its report by the word *Faulty*: FAILED /\bFaulty\b/ bad shape
435For the messages generated in the script the most natural way is to use the word *Error* in the message.
436Example:
437
438~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
439 set expected_length 11
440 if { [expr $actual_length - $expected_length] > 0.001 } {
441 puts *Error: The length of the edge should be $expected_length*
442 }
443~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
444
445At the end, the test script should output *TEST COMPLETED* string
446to mark successful completion of the script.
447This is often done by the end script in the grid.
448When test script requires data file, use Tcl procedure *locate_data_file*
449to get path to the data file, rather than explicit path.
450This will allow easy move of the data file from OCCT repository
451to the data files repository without a need to update test script.
452Example:
453
454~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
455 stepread [locate_data_file CAROSKI_COUPELLE.step] a *
456~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
457
458When test needs to produce some snapshots or other artifacts,
459use Tcl variable logdir as location where such files should be put.
460Command *testgrid* sets this variable to the subdirectory of the results folder
461corresponding to the grid. Command *test* sets it to $CASROOT/tmp unless it is already defined.
462Use Tcl variable casename to prefix all the files produced by the test.
463This variable is set to the name of the test case.
464Example:
465
466~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
467 xwd $logdir/${casename}.gif
468 vdisplay result; vfit
469 vdump $logdir/${casename}-axo.gif
470 vfront; vfit
471 vdump $logdir/${casename}-front.gif
472~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
473
474could produce:
475
476~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
477 A1.gif
478 A1-axo.gif
479 A1-front.gif
480~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
481
482@subsection testmanual_3_4 Interpretation of Test Results
483
484The result of the test is evaluated by checking its output against patterns
485defined in the files parse.rules of the grid and group.
486The OCCT test system recognizes five statuses of the test execution:
487
488 * SKIPPED: reported if line matching SKIPPED pattern is found (prior to any FAILED pattern). This indicates that the test cannot be run in the current environment; most typical case is absence of the required data file.
489 * FAILED: reported if some line matching pattern with status FAILED is found (unless it is masked by preceding IGNORE pattern or a TODO statement, see below), or if message TEST COMPLETED is not found at the end. This indicates that test produces bad or unexpected result, and usually highlights a regression.
490 * BAD: reported if test script output contains one or several TODO statements and corresponding number of matching lines in the log. This indicates a known problem (see 3.5). The lines matching TODO statements are not checked against other patterns and thus will not cause a FAILED status.
491 * IMPROVEMENT: reported if test script output contains TODO statement for which no corresponding line is found. This is possible indication of improvement (known problem disappeared).
492 * OK: If none of the above statuses have been assigned. This means test passed without problems.
493
494Other statuses can be specified in the parse.rules files, these will be classified as FAILED.
495Before integration of the change to OCCT repository, all tests should return either OK or BAD status.
496The new test created for unsolved problem should return BAD.
497The new test created for a fixed problem should return FAILED without the fix, and OK with the fix.
498
499@subsection testmanual_3_5 Marking BAD Cases
500
501If the test produces invalid result at a certain moment then the corresponding bug
502should be created in the OCCT issue tracker [3], and the problem should be marked as TODO in the test script.
503The following statement should be added to such test script:
504
505~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
506 puts *TODO BugNumber ListOfPlatforms: RegularExpression*
507~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
508
509where:
510
511 * BugNumber is an ID of the bug in the tracker. For example: #12345
512 * ListOfPlatform is a list of platforms at which the bug is reproduced (e.g. Mandriva2008, Windows or All).
513
514*Note: the platform name is custom for the OCCT test system;*
515*it can be consulted as value of environment variable os_type defined in DRAW.*
516
517Example:
518
519~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
520 Draw[2]> puts $env(os_type)
521 windows
522~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
523
524 * RegularExpression is a regular expression which should be matched against the line indicating the problem in the script output.
525Example:
526
527~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
528 puts *TODO #22622 Mandriva2008: Abort .* an exception was raised*
529~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
530
531Parser checks the output of the test and if an output line matches
532the RegularExpression then it will be assigned a BAD status instead of FAILED.
533For each output line matching to an error expression a separate TODO line
534must be added to mark the test as BAD.
535If not all the TODO statements are found in the test log,
536the test will be considered as possible improvement.
537To mark the test as BAD for an incomplete case
538(when final TEST COMPLETE message is missing)
539the expression *TEST INCOMPLETE* should be used instead of regular expression.
540
541Example:
542
543~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
544 puts *TODO OCC22817 All: exception.+There are no suitable edges*
545 puts *TODO OCC22817 All: \\*\\* Exception \\*\\**
546 puts *TODO OCC22817 All: TEST INCOMPLETE*
547~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
548
549@section testmanual_4 Extended Use
550
551@subsection testmanual_4_1 Running Tests on Older Versions of OCCT
552
553Sometimes it might be necessary to run tests on previous versions of OCCT (up to to 6.5.3)
554that do not include this test system. This can be done by adding DRAW configuration file DrawAppliInit
555in the directory which is current by the moment of DRAW startup,
556to load test commands and define necessary environment. Example
557(assume that d:/occt contains up-to-date version of OCCT sources
558with tests, and test data archive is unpacked to d:/test-data):
559
560~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
561 set env(CASROOT) d:/occt
562 set env(CSF_TestScriptsPath) $env(CASROOT)/tests
563 source $env(CASROOT)/src/DrawResources/TestCommands.tcl
564 set env(CSF_TestDataPath) d:/test-data
565 return
566~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
567
568Note that on older versions of OCCT the tests are run in compatibility mode
569and not all output of the test command can be captured;
570this can lead to absence of some error messages (can be reported as improvement).
571
572@subsection testmanual_4_2 Adding Custom Tests
573
574You can extend the test system by adding your own tests.
575For that it is necessary to add paths to the directory where these tests are located,
576and additional data directory(ies), to the environment variables CSF_TestScriptsPath and CSF_TestDataPath.
577The recommended way for doing this is using DRAW configuration file DrawAppliInit
578located in the directory which is current by the moment of DRAW startup.
579
580Use Tcl command *_path_separator* to insert platform-dependent separator to the path list.
581Example:
582~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
583 set env(CSF_TestScriptsPath) \
584 $env(TestScriptsPath)[_path_separator]d:/MyOCCTProject/tests
585 set env(CSF_TestDataPath) \
586 d:/occt/test-data[_path_separator]d:/MyOCCTProject/tests
587 return ;# this is to avoid an echo of the last command above in cout
588~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
589
590@section testmanual_5 References
591
592-# DRAW Test Harness User’s Guide
593-# Perl regular expressions, http://perldoc.perl.org/perlre.html
594-# OCCT MantisBT issue tracker, http://tracker.dev.opencascade.org