1
This directory contains the test suite of Mnesia.
2
Compile it with "erl -make".
4
Test cases are identified with a {Mod, Fun} tuple that maps
5
to a function Mod:Fun(Config), where the test case hopefully
6
is implemented. The test suite is organized in a hierarchy
7
with {mnesia_SUITE, all} as the top.
9
The module called mt, implements various convenience functions
10
to ease up the execution of test cases. It does also provide
11
aliases for some test cases. For example the atom Mod is an
12
alias for {Mod, all}, the atom all for {mnesia_SUITE, all},
13
evil for mnesia_evil_coverage_test etc.
17
Displays the test case structure from TestCase
18
and downwards the hierarchy. E.g. mt:struct(all)
19
will display the entire test suite.
21
mt:t(TestCase), mt:t(TestCase, Config)
23
Runs a single test case or a hierarchy of test cases.
24
mt:t(silly) is be a good starter, but you may also
25
try mt:t(all) directly if you feel lucky.
27
The identity of the last run test case and the outcome of
28
it is stored on file. mt:t() will re-run the last test case.
30
The Config argument contains various configuration
31
parameters for the test cases, such as which nodes that
32
are available for running the test suite. The default
33
settings should be enough for the most. Use mt:read_config()
34
to get the current default setting and change it with
35
mt:write_config(Config).
39
Generates html documentation for the test suite.
41
In order to be able to run the test suite, the Erlang node must
42
be started with the distribution enabled and the code path must
43
be set to the mnesia/ebin, mnesia/examples, and mnesia/test
44
directories. E.g. the following would do:
46
erl -sname a -pa $top/examples -pa $top/src -pa $top/ebin
48
where $top is the path to the Mnesia installation. Many test
49
cases needs 2 or 3 nodes. The node names may explicitly be
50
stated as test suite configuration parameters, but by default
51
the extra node names are generated. In this example the names
52
will be: a, a1 and a2. It is enough to start the first node
53
manually, the extra nodes will automatically be started if
56
The attached UNIX shell script mt, does not work on all
57
platforms, but it may be used as a source for inspiration. It
58
starts three Erlang nodes in one xterm's each. The main xterm
59
(a@localhost) logs all output in the Erlang shell to a
60
file. The file is piped thru grep to easily find successful
61
test cases (i.e. test cases that encountered an error).
63
During development we want to be able to run the test cases
64
in the debugger. This demands a little bit of preparations:
66
- Start the neccessary number of nodes (normally 3).
67
This may either be done by running the mt script or
68
by starting the main node and then invoke mt:start_nodes()
69
to start the extra nodes with slave.
71
- Ensure that the nodes are connected. The easiest way to do
72
this is by invoking mt:ping().
74
- Load all files that needs to be interpreted. This is typically
75
all Mnesia files plus the test case. By invoking mnesia:ni()
76
and mnesia:ni([TestModule]) the neccessary modules will be
77
loaded on all CONNECTED nodes.
79
The test case execution is supervised in order to ensure that no test
80
case exceeds its maximum time limit, which by default is 5 minutes.
81
When the limit is reached, the running test case gets aborted and the
82
test server runs the next test case in line. This behaviour is useful
83
when running the entire test suite during the night, but it is really
84
annoying during debugging.
86
Use the "erl -mnesia_test_timeout" flag to disable the test case
89
Some mechanisms in Mnesia are almost impossible to test with a
90
white box technique. In order to be able to write predictable
91
test cases which tests the same thing every time it is run,
92
Mnesia has been instrumented with debug functions. These may be
93
controlled from a test program. For example to verify that the
94
commit protocols work it is essential that it is possible to
95
ensure that we are able to kill Mnesia in the most critical
96
situations. Normally Mnesia is compiled with the debug
97
functions disabled and this means that test cases which
98
requires this functionality will be skipped. The mnesia:ni(),
99
mentioned above, functions ensures that the interpreted code is
100
instrumented with Mnesia's debug functionality. The mnesia:nc()
101
functions compiles Mnesia with the debug setting enabled.
105
Hakan Mattsson <hakan@erix.ericsson.se>