| 1 |
Rules for the Berkeley DB and Berkeley DB-XML test suites |
| 2 |
|
| 3 |
1. Test Naming |
| 4 |
|
| 5 |
The primary script for running Berkeley DB scripts is named |
| 6 |
'test.tcl'. The primary script for running DB-XML is named |
| 7 |
'xmltest.tcl'. |
| 8 |
|
| 9 |
Tests are named with a (prefix, test number) combination. The |
| 10 |
prefix indicates the type of test (lock, log, xml, etc.). The |
| 11 |
prefix 'test' is used for plain vanilla DB testing. Test numbers |
| 12 |
are 3 digits long, starting with 001. |
| 13 |
|
| 14 |
Procedures common to a group of tests, or to all tests, are placed |
| 15 |
in files named 'xxxutils.tcl'. At the moment, we have the following |
| 16 |
utilities files: |
| 17 |
|
| 18 |
testutils.tcl Utilities common to all DB tests |
| 19 |
reputils.tcl Utilities for replication testing. |
| 20 |
siutils.tcl Utilities for secondary index testing. |
| 21 |
xmlutils.tcl Utilities for XML testing. |
| 22 |
|
| 23 |
2. Internal test structure |
| 24 |
|
| 25 |
Each line within a test should be no more than 80 characters long. |
| 26 |
|
| 27 |
Each test starts with a section like the following: |
| 28 |
|
| 29 |
# See the file LICENSE for redistribution information. |
| 30 |
# |
| 31 |
# Copyright (c) 1996, 2013 Oracle and/or its affiliates. All rights reserved. |
| 32 |
# |
| 33 |
# $Id$ |
| 34 |
# |
| 35 |
# TEST test001 |
| 36 |
# TEST Small keys/data |
| 37 |
# TEST Put/get per key |
| 38 |
# TEST Dump file |
| 39 |
# TEST Close, reopen |
| 40 |
# TEST Dump file |
| 41 |
# TEST |
| 42 |
# TEST Use the first 10,000 entries from the dictionary. |
| 43 |
# TEST Insert each with self as key and data; retrieve each. |
| 44 |
# TEST After all are entered, retrieve all; compare output to original. |
| 45 |
# TEST Close file, reopen, do retrieve and re-verify. |
| 46 |
|
| 47 |
First we refer to the license and assert copyright, then comes the CVS |
| 48 |
header string. The section of lines beginning # TEST is used to |
| 49 |
automatically maintain the TESTS file, a listing of all tests and |
| 50 |
what they do. Use this section to briefly describe the test's purpose |
| 51 |
and structure. |
| 52 |
|
| 53 |
Next comes the main procedure of the test, which has the same name |
| 54 |
as the tcl file. The test should be liberally commented, and also |
| 55 |
should use 'puts' to send messages to the output file. |
| 56 |
|
| 57 |
Sections of a test are identified with letters: test001.a, test001.b, |
| 58 |
test001.c. |
| 59 |
|
| 60 |
Here's some typical output: |
| 61 |
|
| 62 |
puts "Test$tnum: $method ($args) $nentries equal key/data pairs" |
| 63 |
puts "\tTest$tnum.a: put/get loop" |
| 64 |
puts "\tTest$tnum.b: dump file" |
| 65 |
puts "\tTest$tnum.c: close, open, and dump file" |
| 66 |
puts "\tTest$tnum.d: close, open, and dump file in reverse direction" |
| 67 |
|
| 68 |
The reporting of the current value of the args is particularly |
| 69 |
useful, allowing us to say at a glance that "testxxx is failing in |
| 70 |
btree" or whatever. Each line of output must begin with the test name. |
| 71 |
We use this to separate expected informational output from errors. |
| 72 |
|
| 73 |
Ancillary procedures follow the main procedure. Procedures used |
| 74 |
by more than one test should go into the appropriate XXXutils.tcl |
| 75 |
file. |
| 76 |
|
| 77 |
3. Reporting failures |
| 78 |
|
| 79 |
Failures in tests are reported with a message starting with the |
| 80 |
prefix "FAIL:". Failures in tests are usually caught with the |
| 81 |
error_check_good and error_check_bad routines to compare an |
| 82 |
actual return value to an expected return value. These routines |
| 83 |
take care of putting the "FAIL:" prefix on the message. |
| 84 |
|
| 85 |
4. Running tests |
| 86 |
|
| 87 |
Any single test can be run from the tclsh prompt by typing the |
| 88 |
name of the test. If it's a test from the 'testxxx' group, you |
| 89 |
should also specify the method you'd like to test: |
| 90 |
|
| 91 |
log001 |
| 92 |
test001 btree |
| 93 |
|
| 94 |
To run one of the 'testxxx' tests for all methods, use the |
| 95 |
run_test procedure: |
| 96 |
|
| 97 |
run_test test001 |
| 98 |
|
| 99 |
Any group of tests (the subsystems lock, log, test, etc.) can be |
| 100 |
run by typing |
| 101 |
|
| 102 |
r $sub |
| 103 |
|
| 104 |
where sub is the name of the subsystem. |
| 105 |
|
| 106 |
For any of the following methods |
| 107 |
|
| 108 |
run_method |
| 109 |
run_secmethod |
| 110 |
run_secenv |
| 111 |
run_reptest |
| 112 |
run_repmethod |
| 113 |
run_envmethod |
| 114 |
run_recd |
| 115 |
|
| 116 |
you can type |
| 117 |
|
| 118 |
run (suffix method start stop). |
| 119 |
|
| 120 |
For example, to run test010 through test020 in btree using |
| 121 |
run_method: |
| 122 |
|
| 123 |
run method btree 10 20 |
| 124 |
|
| 125 |
Or the same tests in repmethod: |
| 126 |
|
| 127 |
run repmethod btree 10 20 |
| 128 |
|
| 129 |
Notice the missing underbar. |
| 130 |
|
| 131 |
If you omit the start and stop numbers, you'll get all the tests: |
| 132 |
|
| 133 |
run method btree |
| 134 |
|
| 135 |
run_recd is a special case, in that it runs the recdxxx tests; |
| 136 |
all the others run the testxxx tests. |
| 137 |
|
| 138 |
To run the standard test suite, type run_std at the tclsh prompt. |
| 139 |
To run all the tests, type run_all. |
| 140 |
|
| 141 |
If you are running run_std or run_all, you may use the run_parallel |
| 142 |
interface to speed things up or to test under conditions of high |
| 143 |
system load. Run_parallel creates a list of all tests in the run, |
| 144 |
reorders the tests randomly, then runs the tests in a number of |
| 145 |
parallel processes. To run run_std in five processes type |
| 146 |
|
| 147 |
run_parallel 5 run_std |