0022978: Shading for a pipe shape is wrong
[occt.git] / dox / dev_guides / tests / tests.md
1  Automated Testing System  {#occt_dev_guides__tests}
2 ======================================
3
4 @tableofcontents
5
6 @section testmanual_1 Introduction
7
8 This document provides OCCT developers and contributors with an overview and practical guidelines for work with OCCT automatic testing system.
9
10 Reading the Introduction is sufficient for OCCT developers to use the test system to control non-regression of the modifications they implement in OCCT. Other sections provide a more in-depth description of the test system, required for modifying the tests and adding new test cases. 
11
12 @subsection testmanual_1_1 Basic Information
13
14 OCCT automatic testing system is organized around DRAW Test Harness @ref occt_user_guides__test_harness "DRAW Test Harness", a console application based on Tcl (a scripting language) interpreter extended by OCCT-related commands.
15
16 Standard OCCT tests are included with OCCT sources and are located in subdirectory *tests* of the OCCT root folder. Other test folders can be included in the test system, e.g. for testing applications based on OCCT.
17
18 The tests are organized in three levels:
19
20   * Group: a group of related test grids, usually testing a particular OCCT functionality (e.g. blend);
21   * Grid: a 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: a script implementing an individual test (e.g. K4).
23   
24 See <a href="#testmanual_5_1">Test Groups</a> for the current list of available test groups and grids.
25
26 Some tests involve data files (typically CAD models) which are located separately and are not included with OCCT code. The archive with publicly available test data files should be downloaded and installed independently on OCCT sources (from http://dev.opencascade.org).
27
28 @subsection testmanual_1_2 Intended Use of Automatic Tests
29
30 Each modification made in OCCT code must be checked for non-regression 
31 by running the whole set of tests. The developer who does the modification 
32 is responsible for running and ensuring non-regression for the tests available to him.
33
34 Note that many tests are based on data files that are confidential and thus available only at OPEN CASCADE. Thus official certification testing of the changes before integration to master branch of official OCCT Git repository (and finally to the official release) is performed by OPEN CASCADE in any case.
35
36 Each new non-trivial modification (improvement, bug fix, new feature) in OCCT should be accompanied by a relevant test case suitable for verifying that modification. This test case is to be added by the developer who provides the modification.
37
38 If a modification affects the result of an existing test case, either the modification should be corrected (if it causes regression) or the affected test cases should be updated to account for the modification. 
39
40 The modifications made in the OCCT code and related test scripts should be included in the same integration to the master branch.
41
42 @subsection testmanual_1_3 Quick Start
43
44 @subsubsection testmanual_1_3_1 Setup
45
46 Before running tests, make sure to define environment variable *CSF_TestDataPath* pointing to the directory containing test data files. 
47 (Publicly available data files can be downloaded from http://dev.opencascade.org separately from OCCT code.) 
48
49 For this it is recommended to add a file *DrawAppliInit* in the directory which is current at the moment of starting DRAWEXE (normally it is OCCT root directory, <i>$CASROOT </i>). This file is evaluated automatically at the DRAW start. 
50
51 Example (Windows)
52
53 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
54 set env(CSF_TestDataPath) $env(CSF_TestDataPath)\;d:/occt/test-data
55 return ;# this is to avoid an echo of the last command above in cout
56
57 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58 Note that variable *CSF_TestDataPath* is set to default value at DRAW start, pointing at the folder <i>$CASROOT/data</i>. 
59 In this example, subdirectory <i>d:/occt/test-data</i> is added to this path. Similar code could be used on Linux and Mac OS X except that on non-Windows platforms colon ‘:’ should be used as path separator instead of semicolon ‘;’.
60
61 All tests are run from DRAW command prompt (run *draw.tcl* or *draw.sh* to start it).
62
63 @subsubsection testmanual_1_3_2 Running Tests
64
65 To run all tests, type command *testgrid* 
66
67 Example:
68
69 ~~~~~
70 Draw[]> testgrid
71 ~~~~~
72
73 For running only a group or a grid of tests, give additional arguments indicating followed by path to the group and (if needed) the grid name.
74
75 Example:
76
77 ~~~~~
78 Draw[]> testgrid blend simple
79 ~~~~~
80
81
82 As the tests progress, the result of each test case is reported. 
83 At the end of the log a summary of test cases is output, 
84 including the list of detected regressions and improvements, if any. 
85
86
87 Example:
88
89 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
90     Tests summary
91
92     CASE 3rdparty export A1: OK 
93     ...
94     CASE pipe standard B1: BAD (known problem)
95     CASE pipe standard C1: OK
96     No regressions 
97     Total cases: 208 BAD, 31 SKIPPED, 3 IMPROVEMENT, 1791 OK
98     Elapsed time: 1 Hours 14 Minutes 33.7384512019 Seconds
99     Detailed logs are saved in D:/occt/results_2012-06-04T0919
100 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
102 The tests are considered as non-regressive if only OK, BAD (i.e. known problem), and SKIPPED (i.e. not executed, typically because of lack of a data file) statuses are reported. See <a href="#testmanual_3_5">Interpretation of test results</a> for details.
103
104 The results and detailed logs of the tests are saved by default to a subdirectory of the current folder, whose name is generated automatically using the current date and time, prefixed by word <i>"results_"</i> and Git branch name (if Git is available and current sources are managed by Git).
105 If necessary, a non-default output directory can be specified using option <i> –outdir</i> followed by a path to the directory. This directory should be new or empty; use option –overwrite to allow writing results in existing non-empty directory. 
106
107 Example:
108 ~~~~~
109 Draw[]> testgrid –outdir d:/occt/last_results -overwrite
110 ~~~~~
111 In the output directory, a cumulative HTML report summary.html provides links to reports on each test case. An additional report in JUnit-style XML format can be output for use in Jenkins or other continuous integration system.
112
113 Type <i>help testgrid</i> in DRAW prompt to get help on options supported by *testgrid* command.
114
115 For example: 
116
117 ~~~~~
118 Draw[3]> help testgrid
119 testgrid: Run all tests, or specified group, or one grid
120     Use: testgrid [group [grid]] [options...]
121     Allowed options are:
122     -parallel N: run N parallel processes (default is number of CPUs, 0 to disable)
123     -refresh N: save summary logs every N seconds (default 60, minimal 1, 0 to disable)
124     -outdir dirname: set log directory (should be empty or non-existing)
125     -overwrite: force writing logs in existing non-empty directory
126     -xml filename: write XML report for Jenkins (in JUnit-like format)
127 ~~~~~
128
129 @subsubsection testmanual_1_3_3 Running a Single Test
130
131 To run a single test, type command *test*’ followed by names of group, grid, and test case. 
132
133 Example:
134
135 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
136     Draw[1]> test blend simple A1
137     CASE blend simple A1: OK
138     Draw[2]>
139 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140
141 Note that normally an intermediate output of the script is not shown. The detailed log of the test can be obtained after the test execution by running command <i>"dlog get"</i>. 
142
143 To see intermediate commands and their output during the test execution, add one more argument 
144 <i>"echo"</i> at the end of the command line. Note that with this option the log is not collected and summary is not produced.
145
146 @subsubsection testmanual_1_3_4 Creating a New Test
147
148 The detailed rules of creation of new tests are given in <a href="#testmanual_3">section 3</a>. The following short description covers the most typical situations:
149
150 Use prefix “bug” followed by Mantis issue ID and, if necessary, additional suffixes, for naming the test script and DRAW commands specific for this test case.
151
152 1.      If the test requires C++ code, add it as new DRAW command(s) in one of files in *QABugs* package. Note that this package defines macros *QVERIFY* and *QCOMPARE*, thus code created for QTest or GoogleTest frameworks can be used with minimal modifications.
153 2.      Add script(s) for the test case in grid (subfolder) corresponding to the relevant OCCT module of the group bugs <i>($CASROOT/tests/bugs)</i>. See <a href="#testmanual_5_2">the correspondence map</a>.
154 3.      In the test script:
155         *       Load all necessary DRAW modules by command *pload*.
156         *       Use command *locate_data_file* to get a path to data files used by test script. (Make sure to have this command not inside catch statement if it is used.)
157         *       Use DRAW commands to reproduce the situation being tested.
158         *       If test case is added to describe existing problem and the fix is not available, add TODO message for each error to mark it as known problem. The TODO statements must be specific so as to match the actually generated messages but not all similar errors.
159         *       Make sure that in case of failure the test produces message containing word “Error” or other recognized by test system as error (see files parse.rules).
160 4.      If the test case uses data file(s) not yet present in the test database, these can be put to subfolder data of the test grid, and integrated to Git along with the test case.
161 5.      Check that the test case runs as expected (test for fix: OK with the fix, FAILED without the fix; test for existing problem: BAD), and integrate to Git branch created for the issue.
162
163 Example:
164
165 * Added files:
166 ~~~~~
167 git status –short
168 A tests/bugs/heal/data/OCC210a.brep
169 A tests/bugs/heal/data/OCC210a.brep
170 A tests/bugs/heal/bug210_1
171 A tests/bugs/heal/bug210_2
172 ~~~~~
173
174 * Test script
175
176 ~~~~~
177 puts "OCC210 (case 1): Improve FixShape for touching wires"
178
179 restore [locate_data_file OCC210a.brep] a 
180
181 fixshape result a 0.01 0.01
182 checkshape result
183 ~~~~~
184
185 @section testmanual_2 Organization of Test Scripts
186
187 @subsection testmanual_2_1 General Layout
188
189 Standard OCCT tests are located in subdirectory tests of the OCCT root folder ($CASROOT).
190
191 Additional test folders can be added to the test system by defining environment variable *CSF_TestScriptsPath*. This should be list of paths separated by semicolons (*;*) on Windows 
192 or colons (*:*) on Linux or Mac. Upon DRAW launch, path to tests sub-folder of OCCT is added at the end of this variable automatically. 
193
194 Each test folder is expected to contain:
195   * Optional file parse.rules defining patterns for interpretation of test results, common for all groups in this folder
196   * One or several test group directories. 
197
198 Each group directory contains:
199
200   * File *grids.list* that identifies this test group and defines list of test grids in it.
201   * Test grids (sub-directories), each containing set of scripts for test cases, and optional files *cases.list*, *parse.rules*, *begin* and *end*.
202   * Optional sub-directory data
203
204 By convention, names of test groups, grids, and cases should contain no spaces and be lower-case. 
205 The names *begin, end, data, parse.rules, grids.list* and *cases.list* are reserved. 
206
207 General layout of test scripts is shown in Figure 1.
208
209 @image html /dev_guides/tests/images/tests_image001.png "Layout of tests folder"
210 @image latex /dev_guides/tests/images/tests_image001.png "Layout of tests folder"
211
212
213 @subsection testmanual_2_2 Test Groups
214
215 @subsubsection testmanual_2_2_1 Group Names
216
217 The names of directories of test groups containing systematic test grids correspond to the functionality tested by each group.
218
219 Example:
220
221 ~~~~~
222   caf
223   mesh
224   offset
225 ~~~~~
226
227 Test group *bugs* is used to collect the tests coming from bug reports. Group *demo* collects tests of the test system, DRAW, samples, etc.
228
229 @subsubsection testmanual_2_2_2 File "grids.list" 
230
231 This test group contains file *grids.list*, which defines an ordered list of grids in this group in the following format:
232
233 ~~~~~~~~~~~~~~~~~
234 001 gridname1
235 002 gridname2
236 ...
237 NNN gridnameN
238 ~~~~~~~~~~~~~~~~~
239
240 Example:
241
242 ~~~~~~~~~~~~~~~~~
243     001 basic
244     002 advanced
245 ~~~~~~~~~~~~~~~~~
246
247 @subsubsection testmanual_2_2_3 File "begin"
248
249 This file is a Tcl script. It is executed before every test in the current group. 
250 Usually it loads necessary Draw commands, sets common parameters and defines 
251 additional Tcl functions used in test scripts.
252
253 Example:
254
255 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
256     pload TOPTEST ;# load topological command
257     set cpulimit 300 ;# set maximum time allowed for script execution
258 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259
260 @subsubsection testmanual_2_2_4 File "end"
261
262 This file is a TCL script. It is executed after every test in the current group. Usually it checks the results of script work, makes a snap-shot of the viewer and writes *TEST COMPLETED* to the output.
263
264 Note: *TEST COMPLETED* string should be present in the output to indicate that the test is finished without crash. 
265
266 See <a href="#testmanual_3">section 3</a> for more information.
267
268 Example:
269 ~~~~~
270     if { [isdraw result] } {
271         checkshape result
272     } else {
273         puts "Error: The result shape can not be built"
274     }
275     puts "TEST COMPLETED"
276 ~~~~~
277
278 @subsubsection testmanual_2_2_5 File "parse.rules"
279
280 The test group may contain *parse.rules* file. This file defines patterns used for analysis of the test execution log and deciding the status of the test run. 
281
282 Each line in the file should specify a status (single word), followed by a regular expression delimited by slashes (*/*) that will be matched against lines in the test output log to check if it corresponds to this status.
283
284 The regular expressions support a subset of the Perl *re* syntax. See also <a href=http://perldoc.perl.org/perlre.html>Perl regular expressions</a>.
285
286 The rest of the line can contain a comment message, which will be added to the test report when this status is detected.
287
288 Example:
289
290 ~~~~~
291     FAILED /\\b[Ee]xception\\b/ exception
292     FAILED /\\bError\\b/ error
293     SKIPPED /Cannot open file for reading/ data file is missing
294     SKIPPED /Could not read file .*, abandon/ data file is missing
295 ~~~~~
296
297 Lines starting with a *#* character and blank lines are ignored to allow comments and spacing.
298
299 See <a href="#testmanual_3_5">Interpretation of test results</a> chapter for details.
300
301 If a line matches several rules, the first one applies. Rules defined in the grid are checked first, then rules in the group, then rules in the test root directory. This allows defining some rules on the grid level with status *IGNORE* to ignore messages that would otherwise be treated as errors due to the group level rules.
302
303 Example:
304
305 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
306     FAILED /\\bFaulty\\b/ bad shape
307     IGNORE /^Error [23]d = [\d.-]+/ debug output of blend command
308     IGNORE /^Tcl Exception: tolerance ang : [\d.-]+/ blend failure
309 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310
311 @subsubsection testmanual_2_2_6  Directory "data"
312 The test group may contain subdirectory *data*, where test scripts shared by different test grids can be put. See also <a href="#testmanual_2_3_5">Directory *data*</a>.
313
314 @subsection testmanual_2_3 Test Grids
315
316 @subsubsection testmanual_2_3_1 Grid Names
317
318 The folder of a test group  can have several sub-directories (Grid 1… Grid N) defining test grids. 
319 Each directory contains a set of related test cases. The name of a directory should correspond to its contents.
320
321 Example:
322
323 ~~~~~
324 caf
325    basic
326    bugs
327    presentation
328 ~~~~~
329
330 Here *caf* is the name of the test group and *basic*, *bugs*, *presentation*, etc. are the names of grids.
331
332 @subsubsection testmanual_2_3_2 File "begin"
333
334 This file is a TCL script executed before every test in the current grid. 
335
336 Usually it sets variables specific for the current grid.
337
338 Example:
339
340 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
341     set command bopfuse ;# command tested in this grid
342 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
343
344 @subsubsection testmanual_2_3_3 File "end"
345
346 This file is a TCL script executed after every test in current grid. 
347
348 Usually it executes a specific sequence of commands common for all tests in the grid.
349
350 Example:
351
352 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
353     vdump $logdir/${casename}.gif ;# makes a snap-shot of AIS viewer
354 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
355
356 @subsubsection testmanual_2_3_4 File "cases.list"
357
358 The grid directory can contain an optional file cases.list 
359 defining an alternative location of the test cases. 
360 This file should contain a single line defining the relative path to the collection of test cases.
361
362 Example:
363
364 ~~~~~
365 ../data/simple
366 ~~~~~
367
368 This option is used for creation of several grids of tests with the same data files and operations but performed with differing parameters. The common scripts are usually located place in the common 
369 subdirectory of the test group, <i>data/simple</i> for example.
370
371 If file *cases.list*  exists, the grid directory should not contain any test cases. 
372 The specific parameters and pre- and post-processing commands 
373 for test execution in this grid should be defined in the files *begin* and *end*.
374
375
376 @subsubsection testmanual_2_3_5  Directory "data"
377
378 The test grid may contain subdirectory *data*, containing data files used in tests (BREP, IGES, STEP, etc.) of this grid.
379
380 @subsection testmanual_2_4 Test Cases
381
382 The test case is a TCL script, which performs some operations using DRAW commands 
383 and produces meaningful messages that can be used to check the validity of the result.
384
385 Example:
386
387 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
388     pcylinder c1 10 20 ;# create first cylinder
389     pcylinder c2 5 20 ;# create second cylinder
390     ttranslate c2 5 0 10 ;# translate second cylinder to x,y,z
391     bsection result c1 c2 ;# create a section of two cylinders
392     checksection result ;# will output error message if result is bad
393 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
394
395 The test case can have any name (except for the reserved names *begin, end, data, cases.list* and  *parse.rules*). 
396 For systematic grids it is usually a capital English letter followed by a number.
397
398 Example:
399
400 ~~~~~
401     A1
402     A2
403     B1
404     B2
405 ~~~~~
406
407 Such naming facilitates compact representation of tests execution results in tabular format within HTML reports.
408
409
410 @section testmanual_3 Creation And Modification Of Tests
411
412 This section describes how to add new tests and update existing ones.
413
414 @subsection testmanual_3_1 Choosing Group, Grid, and Test Case Name
415
416 The new tests are usually added in the frame of processing issues in OCCT Mantis tracker. 
417 Such tests in general should be added to group bugs, in the grid 
418 corresponding to the affected OCCT functionality. See <a href="#testmanual_5_2">Mapping of OCCT functionality to grid names in group *bugs*</a>.
419
420 New grids can be added as necessary to contain tests for the functionality not yet covered by existing test grids. 
421 The test case name in the bugs group should be prefixed by the ID of the corresponding issue in Mantis (without leading zeroes) with prefix *bug*. It is recommended to add a suffix providing a hint on the tested situation. If more than one test is added for a bug, they should be distinguished by suffixes; either meaningful or just ordinal numbers.
422
423 Example:
424
425 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
426     bug12345_coaxial
427     bug12345_orthogonal_1
428     bug12345_orthogonal_2
429 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430
431 If the new test corresponds to a functionality already covered by the existing systematic test grid (e.g. group *mesh* for *BRepMesh* issues), this test can be added (or moved later by OCC team) to that grid. 
432
433 @subsection testmanual_3_2 Adding Data Files Required for a Test
434
435 It is advisable to make self-contained test scripts whenever possible, so as they could be used in environments where data files are not available. For that simple geometric objects and shapes can be created using DRAW commands in the test script itself.
436
437 If the test requires a data file, it should be put to subdirectory *data* of the test grid. It is recommended to prefix the data file with the corresponding issue id prefixed by *bug*, e.g. *bug12345_face1.brep*, to avoid possible conflicts with names of existing data files. 
438
439 Note that when the test is integrated to the master branch, OCC team will move the data file to data files repository, so as to keep OCCT sources repository clean from data files.
440
441 When preparing a test script, try to minimize the size of involved data model. For instance, if the problem detected on a big shape can be reproduced on a single face extracted from that shape, use only that face in the test.
442
443
444 @subsection testmanual_3_3 Adding new DRAW commands
445
446 If the test cannot be implemented using available DRAW commands, consider the following possibilities:
447 * If the existing DRAW command can be extended to enable possibility required for a test in a natural way (e.g. by adding an option to activate a specific mode of the algorithm), this way is recommended. This change should be appropriately documented in a relevant Mantis issue.
448 * If the new command is needed to access OCCT functionality not exposed to DRAW previously, and this command can be potentially reused (for other tests), it should be added to the package where similar commands are implemented (use *getsource* DRAW command to get the package name). The name and arguments of the new command should be chosen to keep similarity with the existing commands. This change should be documented in a relevant Mantis issue.
449 * Otherwise the new command implementing the actions needed for this particular test should be added in *QABugs* package. The command name should be formed by the Mantis issue ID prefixed by *bug*, e.g. *bug12345*.
450
451 Note that a DRAW command is expected to return 0 in case of a normal completion, and 1 (Tcl exception) if it is incorrectly used (e.g. a wrong number of input arguments). Thus if the new command needs to report a test error, this should be done by outputting an appropriate error message rather than by returning a non-zero value.
452
453
454 @subsection testmanual_3_4 Script Implementation
455
456 The test should run commands necessary to perform the tested operations, in general assuming a clean DRAW session. The required DRAW modules should be loaded by *pload* command, if it is not done by *begin* script. The messages produced by commands in a standard output should include identifiable messages on the discovered problems if any. 
457
458 Usually the script represents a set of commands that a person would run interactively to perform the operation and see its results, with additional comments to explain what happens.
459
460 Example:
461 ~~~~~
462 # Simple test of fusing box and sphere
463 box b 10 10 10 
464 sphere s 5
465 bfuse result b s
466 checkshape result
467 ~~~~~
468
469 Make sure that file *parse.rules* in the grid or group directory contains a regular expression to catch possible messages indicating the failure of the test. 
470
471 For instance, for catching errors reported by *checkshape* command relevant grids define a rule to recognize its report by the word *Faulty*:
472
473 ~~~~~
474 FAILED /\bFaulty\b/ bad shape
475 ~~~~~
476
477 For the messages generated in the script it is recommended to use the word 'Error' in the error message.
478
479 Example:
480
481 ~~~~~
482 set expected_length 11
483 if { [expr $actual_length - $expected_length] > 0.001 } {
484     puts "Error: The length of the edge should be $expected_length"
485 }
486 ~~~~~
487
488 At the end, the test script should output *TEST COMPLETED* string to mark a successful completion of the script. This is often done by the *end* script in the grid.
489
490 When the test script requires a data file, use Tcl procedure *locate_data_file* to get a path to it, instead of putting the path explicitly. This will allow easy move of the data file from OCCT sources repository to the data files repository without the need to update the test script.
491
492 Example:
493
494 ~~~~~
495 stepread [locate_data_file CAROSKI_COUPELLE.step] a *
496 ~~~~~
497
498 When the test needs to produce some snapshots or other artefacts, use Tcl variable *logdir* as the location where such files should be put. Command *testgrid* sets this variable to the subdirectory of the results folder corresponding to the grid. Command *test* sets it to <i>$CASROOT/tmp</i> unless it is already defined. Use Tcl variable *casename* to prefix all files produced by the test. This variable is set to the name of the test case.
499
500 Example:
501 ~~~~~
502 xwd $logdir/${casename}.png
503 vdisplay result; vfit
504 vdump $logdir/${casename}-axo.png
505 vfront; vfit
506 vdump $logdir/${casename}-front.png
507 ~~~~~
508
509 would produce:
510 ~~~~~
511 A1.png
512 A1-axo.png
513 A1-front.png
514 ~~~~~
515
516 Note that OCCT must be built with FreeImage support to be able to produce usable images.
517
518 In order to ensure that the test works as expected in different environments, observe the following additional rules:
519 * Avoid using external commands such as *grep, rm,* etc., as these commands can be absent on another system (e.g. on Windows); use facilities provided by Tcl instead.
520 * Do not put call to *locate_data_file* in catch statement – this can prevent correct interpretation of the missing data file by the test system.
521
522
523 @subsection testmanual_3_5 Interpretation of test results
524
525 The result of the test is evaluated by checking its output against patterns defined in the files *parse.rules* of the grid and group.
526
527 The OCCT test system recognizes five statuses of the test execution:
528 * SKIPPED: reported if a line matching SKIPPED pattern is found (prior to any FAILED pattern). This indicates that the test cannot be run in the current environment; the most typical case is the absence of the required data file.
529 * FAILED: reported if a line matching pattern with status FAILED is found (unless it is masked by the preceding IGNORE pattern or a TODO statement), or if message TEST COMPLETED is not found at the end. This indicates that the test has produced a bad or unexpected result, and usually means a regression.
530 * BAD: reported if the test script output contains one or several TODO statements and the corresponding number of matching lines in the log. This indicates a known problem . The lines matching TODO statements are not checked against other patterns and thus will not cause a FAILED status.  
531 * IMPROVEMENT: reported if the test script output contains a TODO statement for which no corresponding line is found. This is a possible indication of improvement (a known problem has disappeared).
532 * OK: reported if none of the above statuses have been assigned. This means that the test has passed without problems.
533
534 Other statuses can be specified in *parse.rules* files, these will be classified as FAILED.
535
536 For integration of the change to OCCT repository, all tests should return either OK or BAD status.
537 The new test created for an unsolved problem should return BAD. The new test created for a fixed problem should return FAILED without the fix, and OK with the fix.
538
539 @subsection testmanual_3_6 Marking BAD cases
540
541 If the test produces an invalid result at a certain moment then corresponding bug should be created in the  OCCT issue tracker located at http://tracker.dev.opencascade.org, and the problem should be marked as TODO in the test script.
542
543 The following statement should be added to such a test script:
544 ~~~~~
545 puts "TODO BugNumber ListOfPlatforms: RegularExpression"
546 ~~~~~
547
548 Here:
549 * *BugNumber* is the bug ID in the tracker. For example: #12345.
550 * *ListOfPlatforms* is a list of platforms at which the bug is reproduced (e.g. Mandriva2008, Windows or All). Note that the platform name is custom for the OCCT test system; it corresponds to the value of environment variable *os_type* defined in DRAW.
551
552 Example:
553 ~~~~~
554 Draw[2]> puts $env(os_type)
555 windows
556 ~~~~~
557
558 * RegularExpression is a regular expression which should be matched against the line indicating the problem in the script output. 
559
560 Example:
561 ~~~~~
562 puts "TODO #22622 Mandriva2008: Abort .* an exception was raised"
563 ~~~~~
564
565 The parser checks the test output and if an output line matches the *RegularExpression* then it will be assigned a BAD status instead of FAILED.
566
567 A separate TODO line must be added for each output line matching an error expression to mark the test as BAD. If not all TODO messages are found in the test log, the test will be considered as possible improvement.
568
569 To mark the test as BAD for an incomplete case (when the final *TEST COMPLETE* message is missing) the expression *TEST INCOMPLETE* should be used instead of the regular expression. 
570
571 Example:
572
573 ~~~~~
574 puts "TODO OCC22817 All: exception.+There are no suitable edges"
575 puts "TODO OCC22817 All: \\*\\* Exception \\*\\*"
576 puts "TODO OCC22817 All: TEST INCOMPLETE"
577 ~~~~~
578
579
580
581 @section testmanual_4 Advanced Use
582
583 @subsection testmanual_4_1 Running Tests on Older Versions of OCCT
584
585 Sometimes it might be necessary to run tests on previous versions of OCCT (<= 6.5.4) that do not include this test system. This can be done by adding DRAW configuration file *DrawAppliInit* in the directory which is current by the moment of DRAW start-up, to load test commands and to define necessary environment.
586
587 Note: in OCCT 6.5.3, file *DrawAppliInit* already exists in <i>$CASROOT/src/DrawResources</i>, new commands should be added to this file instead of a new one in the current directory.
588
589 For example, let us assume that *d:/occt* contains an up-to-date version of OCCT sources with tests, and the test data archive is unpacked to *d:/test-data*):
590
591 ~~~~~
592 set env(CASROOT) d:/occt
593 set env(CSF_TestScriptsPath) $env(CASROOT)/tests
594 source $env(CASROOT)/src/DrawResources/TestCommands.tcl
595 set env(CSF_TestDataPath) $env(CASROOT)/data;d:/test-data
596 return
597 ~~~~~
598
599 Note that on older versions of OCCT the tests are run in compatibility mode and not all output of the test command can be captured; this can lead to absence of some error messages (can be reported as either a failure or an improvement).
600
601 @subsection testmanual_4_2 Adding custom tests
602
603 You can extend the test system by adding your own tests. For that it is necessary to add paths to the directory where these tests are located, and one or more additional data directories, to the environment variables *CSF_TestScriptsPath* and *CSF_TestDataPath*. The recommended way for doing this is using DRAW configuration file *DrawAppliInit* located in the directory which is current by the moment of DRAW start-up.
604
605 Use Tcl command <i>_path_separator</i> to insert a platform-dependent separator to the path list.
606
607 For example:
608 ~~~~~
609 set env(CSF_TestScriptsPath) \
610   $env(TestScriptsPath)[_path_separator]d:/MyOCCTProject/tests
611 set env(CSF_TestDataPath) \
612   d:/occt/test-data[_path_separator]d:/MyOCCTProject/data
613 return ;# this is to avoid an echo of the last command above in cout
614 ~~~~~
615
616 @subsection testmanual_4_3 Parallel execution of tests
617
618 For better efficiency, on computers with multiple CPUs the tests can be run in parallel mode. This is default behavior for command *testgrid* : the tests are executed in parallel processes (their number is equal to the number of CPUs available on the system). In order to change this behavior, use option  parallel followed by the number of processes to be used (1 or 0 to run sequentially).
619
620 Note that the parallel execution is only possible if Tcl extension package *Thread* is installed. It is included in *ActiveTcl* package, but can be absent in some Linux distributions. If this package is not available, *testgrid* command will output a warning message.
621
622 @subsection testmanual_4_4 Checking non-regression of performance, memory, and visualization
623
624 Some test results are very dependent on the characteristics of the workstation, where they are performed, and thus cannot be checked by comparison with some predefined values. These results can be checked for non-regression (after a change in OCCT code) by comparing them with the results produced by the version without this change. The most typical case is comparing the result obtained in a branch created for integration of a fix (CR***) with the results obtained on the master branch before that change is made.
625
626 OCCT test system provides a dedicated command *testdiff* for comparing CPU time of execution, memory usage, and images produced by the tests.
627
628 ~~~~~
629 testdiff dir1 dir2 [groupname [gridname]] [options...]
630 ~~~~~
631 Here *dir1* and *dir2* are directories containing logs of two test runs.
632
633 Possible options are:
634 * <i>-save \<filename\> </i> - saves the resulting log in a specified file (<i>$dir1/diff-$dir2.log</i> by default). HTML log is saved with the same name and extension .html;
635 * <i>-status {same|ok|all}</i> - allows filtering compared cases by their status:
636         * *same* - only cases with same status are compared (default);
637         * *ok*   - only cases with OK status in both logs are compared;
638         * *all*  - results are compared regardless of status;
639 * <i>-verbose \<level\> </i> - defines the scope of output data:
640         * 1 - outputs only differences;
641         * 2 - additionally outputs the list of logs and directories present in one of directories only;
642         * 3 - (by default) additionally outputs progress messages;
643
644 Example:
645
646 ~~~~~
647 Draw[]> testdiff results-CR12345-2012-10-10T08:00 results-master-2012-10-09T21:20 
648 ~~~~~
649
650 @section testmanual_5 APPENDIX
651
652 @subsection testmanual_5_1 Test groups
653
654 @subsubsection testmanual_5_1_1 3rdparty
655
656 This group allows testing the interaction of OCCT and 3rdparty products.
657
658 DRAW module: VISUALIZATION.
659
660 | Grid  | Commands      | Functionality |
661 | :---- | :----- | :------- | 
662 | export        | vexport       | export of images to different formats |
663 | fonts  | vtrihedron, vcolorscale, vdrawtext   | display of fonts |
664
665
666 @subsubsection testmanual_5_1_2 blend
667
668 This group allows testing blends (fillets) and related operations.
669
670 DRAW module: MODELING.
671
672 | Grid  | Commands      | Functionality |
673 | :---- | :----- | :------- | 
674 | simple        | blend | fillets on simple shapes |
675 | complex       | blend         | fillets on complex shapes, non-trivial geometry |
676 | tolblend_simple       | tolblend, blend | |
677 | buildevol     | buildevol     | |
678 | tolblend_buildvol |   tolblend, buildevol |   use of additional command tolblend |
679 | bfuseblend    | bfuseblend    | | 
680 | encoderegularity      | encoderegularity      | | 
681
682 @subsubsection testmanual_5_1_3 boolean
683
684 This group allows testing Boolean operations.
685
686 DRAW module: MODELING (packages *BOPTest* and *BRepTest*).
687
688 Grids names are based on name of the command used, with suffixes: 
689 * <i>_2d</i> – for tests operating with 2d objects (wires, wires, 3d objects, etc.); 
690 * <i>_simple</i> – for tests operating on simple shapes (boxes, cylinders, toruses, etc.);
691 * <i>_complex</i> – for tests dealing with complex shapes.
692
693 | Grid  | Commands      | Functionality |
694 | :---- | :----- | :------- | 
695 | bcommon_2d    | bcommon       | Common operation (old algorithm), 2d |
696 | bcommon_complex       | bcommon       | Common operation (old algorithm), complex shapes |
697 | bcommon_simple        | bcommon       | Common operation (old algorithm), simple shapes |
698 | bcut_2d       | bcut | Cut operation (old algorithm), 2d |
699 | bcut_complex  | bcut  | Cut operation (old algorithm), complex shapes |
700 | bcut_simple   | bcut |        Cut operation (old algorithm), simple shapes |
701 | bcutblend     | bcutblend     | | 
702 | bfuse_2d      | bfuse | Fuse operation (old algorithm), 2d |
703 | bfuse_complex | bfuse |       Fuse operation (old algorithm), complex shapes |
704 | bfuse_simple  | bfuse | Fuse operation (old algorithm), simple shapes |
705 | bopcommon_2d  | bopcommon |   Common operation, 2d |
706 | bopcommon_complex     | bopcommon     | Common operation, complex shapes | 
707 | bopcommon_simple      | bopcommon     | Common operation, simple shapes |
708 | bopcut_2d |   bopcut |        Cut operation, 2d |
709 | bopcut_complex |      bopcut |        Cut operation, complex shapes |
710 | bopcut_simple | bopcut        | Cut operation, simple shapes |
711 | bopfuse_2d    | bopfuse       | Fuse operation, 2d |
712 | bopfuse_complex       | bopfuse       | Fuse operation, complex shapes |
713 | bopfuse_simple        | bopfuse       | Fuse operation, simple shapes |
714 | bopsection    | bopsection    | Section |
715 | boptuc_2d     | boptuc        | |
716 | boptuc_complex        | boptuc        | |
717 | boptuc_simple | boptuc        | |
718 | bsection |    bsection        | Section (old algorithm) |
719
720 @subsubsection testmanual_5_1_4 bugs
721
722 This group allows testing cases coming from Mantis issues.
723
724 The grids are organized following OCCT module and category set for the issue in the Mantis tracker. 
725 See <a href="#testmanual_5_2">Mapping of OCCT functionality to grid names in group *bugs*</a> for details.
726
727 @subsubsection testmanual_5_1_5 caf
728
729 This group allows testing OCAF functionality.
730
731 DRAW module: OCAFKERNEL.
732
733 | Grid  | Commands      | Functionality |
734 | :---- | :----- | :------- | 
735 | basic | |     Basic attributes |
736 | bugs  | |     Saving and restoring of document |
737 | driver        | |     OCAF drivers |
738 | named_shape   | |     *TNaming_NamedShape* attribute |
739 | presentation  | | *AISPresentation* attributes |
740 | tree  | |     Tree construction attributes |
741 | xlink  | |    XLink attributes |
742
743 @subsubsection testmanual_5_1_6 chamfer
744
745 This group allows testing chamfer operations.
746
747 DRAW module: MODELING.
748
749 The test grid name is constructed depending on the type of the tested chamfers. Additional suffix <i>_complex</i> is used for test cases involving complex geometry (e.g. intersections of edges forming a chamfer); suffix <i>_sequence</i> is used for grids where chamfers are computed sequentially.
750
751 | Grid  | Commands      | Functionality |
752 | :---- | :----- | :------- | 
753 | equal_dist    | |     Equal distances from edge |
754 | equal_dist_complex    | |     Equal distances from edge, complex shapes |
755 | equal_dist_sequence   | |     Equal distances from edge, sequential operations |
756 | dist_dist     | |     Two distances from edge |
757 | dist_dist_complex     | |     Two distances from edge, complex shapes |
758 | dist_dist_sequence    | |     Two distances from edge, sequential operations |
759 | dist_angle    | |     Distance from edge and given angle |
760 | dist_angle_complex    | |     Distance from edge and given angle |
761 | dist_angle_sequence   | |     Distance from edge and given angle |
762
763 @subsubsection testmanual_5_1_7 demo
764
765 This group allows demonstrating how testing cases are created, and testing DRAW commands and the test system as a whole.
766
767 | Grid  | Commands      | Functionality |
768 | :---- | :----- | :------- | 
769 | draw  |  getsource, restore   | Basic DRAW commands |
770 | testsystem    | |     Testing system |
771 | samples       | |     OCCT samples | 
772
773
774 @subsubsection testmanual_5_1_8 draft
775
776 This group allows testing draft operations.
777
778 DRAW module: MODELING.
779
780 | Grid  | Commands      | Functionality |
781 | :---- | :----- | :------- | 
782 | Angle | depouille     | Drafts with angle (inclined walls) |
783
784
785 @subsubsection testmanual_5_1_9 feat
786
787 This group allows testing creation of features on a shape.
788
789 DRAW module: MODELING (package *BRepTest*).
790
791 | Grid  | Commands      | Functionality |
792 | :---- | :----- | :------- | 
793 | featdprism            | | |
794 | featlf                | | |
795 | featprism             | | |
796 | featrevol             | | | 
797 | featrf                | | |
798
799 @subsubsection testmanual_5_1_10 heal
800
801 This group allows testing the functionality provided by *ShapeHealing* toolkit.
802
803 DRAW module: XSDRAW
804
805 | Grid  | Commands      | Functionality |
806 | :---- | :----- | :------- | 
807 | fix_shape     | fixshape      | Shape healing | 
808 | fix_gaps      | fixwgaps      | Fixing gaps between edges on a wire |
809 | same_parameter        | sameparameter | Fixing non-sameparameter edges |
810 | fix_face_size | DT_ApplySeq   | Removal of small faces |
811 | elementary_to_revolution      | DT_ApplySeq   | Conversion of elementary surfaces to revolution |
812 | direct_faces  | directfaces   | Correction of axis of elementary surfaces | 
813 | drop_small_edges      | fixsmall      | Removal of small edges | 
814 | split_angle   | DT_SplitAngle |       Splitting periodic surfaces by angle |
815 | split_angle_advanced | DT_SplitAngle  | Splitting periodic surfaces by angle |
816 | split_angle_standard | DT_SplitAngle  | Splitting periodic surfaces by angle |
817 | split_closed_faces |  DT_ClosedSplit  | Splitting of closed faces |
818 | surface_to_bspline |  DT_ToBspl       | Conversion of surfaces to b-splines |
819 | surface_to_bezier | DT_ShapeConvert | Conversion of surfaces to bezier |
820 | split_continuity      | DT_ShapeDivide | Split surfaces by continuity criterion |
821 | split_continuity_advanced | DT_ShapeDivide | Split surfaces by continuity criterion |
822 | split_continuity_standard | DT_ShapeDivide | Split surfaces by continuity criterion |
823 | surface_to_revolution_advanced |      DT_ShapeConvertRev      | Convert elementary surfaces to revolutions, complex cases |
824 | surface_to_revolution_standard |      DT_ShapeConvertRev      | Convert elementary surfaces to revolutions, simple cases |
825
826 @subsubsection testmanual_5_1_11 mesh
827
828 This group allows testing shape tessellation (*BRepMesh*) and shading.
829
830 DRAW modules: MODELING (package *MeshTest*), VISUALIZATION (package *ViewerTest*)
831
832 | Grid  | Commands      | Functionality |
833 | :---- | :----- | :------- | 
834 | advanced_shading      | vdisplay      | Shading, complex shapes |
835 | standard_shading      | vdisplay      | Shading, simple shapes |
836 | advanced_mesh | mesh |        Meshing of complex shapes |
837 | standard_mesh | mesh |        Meshing of simple shapes |
838 | advanced_incmesh      | incmesh       | Meshing of complex shapes |
839 | standard_incmesh      | incmesh       | Meshing of simple shapes |
840 | advanced_incmesh_parallel | incmesh | Meshing of complex shapes, parallel mode |
841 | standard_incmesh_parallel | incmesh | Meshing of simple shapes, parallel mode |
842
843 @subsubsection testmanual_5_1_12 mkface
844
845 This group allows testing creation of simple surfaces.
846
847 DRAW module: MODELING (package *BRepTest*)
848
849 | Grid  | Commands      | Functionality |
850 | :---- | :----- | :------- | 
851 | after_trim | mkface   | |
852 | after_offset | mkface | |
853 | after_extsurf_and_offset      | mkface  | |   
854 | after_extsurf_and_trim | mkface       | | 
855 | after_revsurf_and_offset | mkface     | | 
856 | mkplane | mkplane     | |
857
858 @subsubsection testmanual_5_1_13 nproject
859
860 This group allows testing normal projection of edges and wires onto a face.
861
862 DRAW module: MODELING (package *BRepTest*) 
863
864 | Grid  | Commands      | Functionality |
865 | :---- | :----- | :------- | 
866 | Base  | nproject      |  |
867
868 @subsubsection testmanual_5_1_14 offset
869
870 This group allows testing offset functionality for curves and surfaces.
871
872 DRAW module: MODELING (package *BRepTest*) 
873
874 | Grid  | Commands      | Functionality |
875 | :---- | :----- | :------- | 
876 | compshape     | offsetcompshape       | Offset of shapes with removal of some faces | 
877 | faces_type_a  | offsetparameter, offsetload, offsetperform | Offset on a subset of faces with a fillet |
878 | faces_type_i  | offsetparameter, offsetload, offsetperform |  Offset on a subset of faces with a sharp edge |
879 | shape_type_a  | offsetparameter, offsetload, offsetperform |  Offset on a whole shape with a fillet |
880 | shape_type_i  | offsetparameter, offsetload, offsetperform |  Offset on a whole shape with a fillet |
881 | shape  | offsetshape  | |
882 | wire_closed_outside_0_005, wire_closed_outside_0_025, wire_closed_outside_0_075, wire_closed_inside_0_005, wire_closed_inside_0_025, wire_closed_inside_0_075, wire_unclosed_outside_0_005, wire_unclosed_outside_0_025, wire_unclosed_outside_0_075  |       mkoffset | 2d offset of closed and unclosed planar wires with different offset step and directions of offset ( inside / outside ) |
883         
884 @subsubsection testmanual_5_1_15 pipe
885
886 This group allows testing construction of pipes (sweeping of a contour along profile).
887
888 DRAW module: MODELING (package *BRepTest*) 
889
890 | Grid  | Commands      | Functionality |
891 | :---- | :----- | :------- | 
892 | Standard      | pipe  | |
893
894 @subsubsection testmanual_5_1_16 prism
895
896 This group allows testing construction of prisms.
897
898 DRAW module: MODELING (package *BRepTest*) 
899
900 | Grid  | Commands      | Functionality |
901 | :---- | :----- | :------- | 
902 | seminf | prism        | |
903
904 @subsubsection testmanual_5_1_17 sewing
905
906 This group allows testing sewing of faces by connecting edges.
907
908 DRAW module: MODELING (package *BRepTest*) 
909
910 | Grid  | Commands      | Functionality |
911 | :---- | :----- | :------- | 
912 | tol_0_01      | sewing | Sewing faces with tolerance 0.01 |
913 | tol_1 | sewing | Sewing faces with tolerance 1 |
914 | tol_100 | sewing | Sewing faces with tolerance 100 | 
915
916 @subsubsection testmanual_5_1_18 thrusection
917
918 This group allows testing construction of shell or a solid passing through a set of sections in a given sequence (loft).
919
920 | Grid  | Commands      | Functionality |
921 | :---- | :----- | :------- | 
922 | solids        | thrusection | Lofting with resulting solid | 
923 | not_solids | thrusection      | Lofting with resulting shell or face | 
924
925 @subsubsection testmanual_5_1_19 xcaf
926
927 This group allows  testing extended data exchange packages.
928
929 | Grid  | Commands      | Functionality |
930 | :---- | :----- | :------- | 
931 | dxc, dxc_add_ACL, dxc_add_CL, igs_to_dxc, igs_add_ACL, brep_to_igs_add_CL, stp_to_dxc, stp_add_ACL, brep_to_stp_add_CL, brep_to_dxc, add_ACL_brep, brep_add_CL        | | Subgroups are divided by format of source file, by format of result file and by type of document modification. For example, *brep_to_igs* means that the source shape in brep format was added to the document, which was saved into igs format after that. The postfix *add_CL* means that colors and layers were initialized in the document before saving and the postfix *add_ACL* corresponds to the creation of assembly and initialization of colors and layers in a document before saving. |
932         
933
934 @subsection testmanual_5_2 Mapping of OCCT functionality to grid names in group *bugs*
935
936 | OCCT Module / Mantis category | Toolkits      | Test grid in group bugs |
937 | :---------- | :--------- | :---------- | 
938 | Application Framework | PTKernel, TKPShape, TKCDF, TKLCAF, TKCAF, TKBinL, TKXmlL, TKShapeSchema, TKPLCAF, TKBin, TKXml, TKPCAF, FWOSPlugin, TKStdLSchema, TKStdSchema, TKTObj, TKBinTObj, TKXmlTObj | caf |
939 | Draw  | TKDraw, TKTopTest, TKViewerTest, TKXSDRAW, TKDCAF, TKXDEDRAW, TKTObjDRAW, TKQADraw, DRAWEXE, Problems of testing system |     draw | 
940 | Shape Healing | TKShHealing | heal |
941 | Mesh  | TKMesh, TKXMesh | mesh |
942 | Data Exchange | TKIGES        | iges |
943 | Data Exchange |       TKSTEPBase, TKSTEPAttr, TKSTEP209, TKSTEP |     step |
944 | Data Exchange |       TKSTL, TKVRML   | stlvrml |
945 | Data Exchange | TKXSBase, TKXCAF, TKXCAFSchema, TKXDEIGES, TKXDESTEP, TKXmlXCAF, TKBinXCAF | xde |
946 | Foundation Classes |  TKernel, TKMath | fclasses |
947 | Modeling_algorithms | TKGeomAlgo, TKTopAlgo, TKPrim, TKBO, TKBool, TKHLR, TKFillet, TKOffset, TKFeat, TKXMesh |       modalg |
948 | Modeling Data | TKG2d, TKG3d, TKGeomBase, TKBRep      | moddata |
949 | Visualization | TKService, TKV2d, TKV3d, TKOpenGl, TKMeshVS, TKNIS, TKVoxel   | vis |
950
951
952 @subsection testmanual_5_2 Recommended approaches to checking test results
953
954 @subsubsection testmanual_5_3_1 Shape validity
955
956 Run command *checkshape* on the result (or intermediate) shape and make sure that *parse.rules* of the test grid or group reports bad shapes (usually recognized by word "Faulty") as error.
957
958 Example
959 ~~~~~
960 checkshape result
961 ~~~~~
962
963 @subsubsection testmanual_5_3_2 Shape tolerance
964 The maximal tolerance of sub-shapes of each kind of the resulting shape can be extracted from output of tolerance command as follows:
965
966 ~~~~~
967 set tolerance [tolerance result]
968 regexp { *FACE +: +MAX=([-0-9.+eE]+)} $tolerance dummy max_face
969 regexp { *EDGE +: +MAX=([-0-9.+eE]+)} $tolerance dummy max_edgee
970 regexp { *VERTEX +: +MAX=([-0-9.+eE]+)} $tolerance dummy max_vertex
971 ~~~~~
972
973 @subsubsection testmanual_5_3_3 Shape volume, area, or length
974
975 Use command *vprops, sprops,* or *lprops* to correspondingly measure volume, area, or length of the shape produced by the test. The value can be extracted from the result of the command by *regexp*.
976
977 Example:
978 ~~~~~
979 # check area of shape result with 1% tolerance
980 regexp {Mass +: +([-0-9.+eE]+)} [sprops result] dummy area
981 if { abs($area - $expected) > 0.1 + 0.01 * abs ($area) } {
982     puts "Error: The area of result shape is $area, while expected $expected"
983 }
984 ~~~~~
985
986 @subsubsection testmanual_5_3_4 Memory leaks
987
988 The test system measures the amount of memory used by each test case, and considerable deviations (as well as overall difference) comparing with reference results will be reported by *testdiff* command.
989
990 The typical approach to checking memory leak on a particular operation is to run this operation in cycle measuring memory consumption at each step and comparing it with some threshold value. Note that file begin in group bugs defines command *checktrend* that can be used to analyze a sequence of memory measurements to get statistically based evaluation of the leak presence.
991
992 Example: 
993 ~~~~~
994 set listmem {}
995 for {set i 1} {$i < 100} {incr i} {
996     # run suspect operation 
997     …
998     # check memory usage (with tolerance equal to half page size)
999     lappend listmem [expr [meminfo w] / 1024]
1000     if { [checktrend $listmem 0 256 "Memory leak detected"] } {
1001         puts "No memory leak, $i iterations"
1002         break
1003     }
1004 }
1005 ~~~~~
1006
1007 @subsubsection testmanual_5_3_5 Visualization
1008
1009 Take a snapshot of the viewer, give it the name of the test case, and save in the directory indicated by Tcl variable *imagedir*. Note that this variable directs to the *log* directory if command *testgrid* is active, or to *tmp* subdirectory of the current folder if the test is run interactively.
1010
1011 ~~~~~
1012 vinit
1013 vclear
1014 vdisplay result
1015 vsetdispmode 1
1016 vfit
1017 vzfit
1018 vdump $imagedir/${casename}_shading.png
1019 ~~~~~
1020
1021 This image will be included in the HTML log produced by *testgrid* command and will be checked for non-regression through comparison of images by command *testdiff*.