Project

General

Profile

C++TESK Test Engines » History » Version 2

Alexander Kamkin, 05/22/2014 10:48 AM

1 1 Mikhail Chupilko
h1. C++TESK Test Engines
2
3 2 Alexander Kamkin
{{toc}}
4
5 1 Mikhail Chupilko
h2. Introduction
6
7
This document describes _test engines_ included into library of C++TESK Testing ToolKit (hereafter С++TESK). _Test engine_ is a core of _stimulus generator_, which is a component of _test system_ being responsible for construction of stimulus sequence (_test actions_) for _target system_. Stimuli can be represented as parameterized target system operation calls. Sequence of stimuli is called _test sequence_. _Test scenario_, being input information for test engine, is a high-level specification of test defining available for test stimuli. Test sequence is constructed as a result of interpretation of given scenario by test engine. It should be noticed that all test engines have the same interface which let different test engines be used for execution of given test scenario.
8
9
Library of C++TESK includes two test engines: @fsm@ (_Finite State Machine_) and @rnd@ (_Random_), located in namespace @cpptesk::ts::engine@. The former (@fsm@) makes traversing of finite state machine _state graph_ described in implicit form in test scenario. The criterion of test completeness in this case is visiting of all states reachable from initial state (it means also traversing of all arcs outgoing from reachable states). Test engine @rnd@ constructs test sequence _randomly_ selecting random either stimulus or set of available stimuli at each work step. Test is finished when given work steps are passed. More detailed information about test engines can be found in correspondent chapters of this document.
10
11
Before reading the rest part of this document, it is recommended to read about development of test scenario by means of C++TESK. This information is contained, e.g., by document _«С++TESK Hardware Edition: Quick Reference»_ (chapter _«Development of test scenario»_).
12
13
h2. Test scenario structure
14
15
From test engine point of view, test scenario consists of two main parts: (1) _stimulus iterator_ and (2) _state calculation function_.
16
17
h3. Stimulus iterator
18
19
_Stimulus iterator_ is set by _scenario methods_ of scenario class. Each scenario method iterates parameters of some stimulus using typical loop-constructions being available in C++ (for, while etc.). Iterations are performed by means of _iteration variables_ which are the fields of _iteration context_ being a parameter of scenario method. Iteration variables can be accessed by means of macro @CPPTESK_ITERATION_VARIABLE(name)@. Macro @CPPTESK_ITERATION_BEGIN@ precedes iterations and macro @CPPTESK_ITERATION_END@ finishes them. Implementation of stimulus application to target system is located inside of set of loops in block @CPPTESK_ITERATION_ACTION{...}@. Stimulus application finishes by calling macro @CPPTESK_ITERATION_YIELD(verdict)@.
20
21
Typical scenario method has the following structure.
22
23
<pre><code class="cpp">
24
bool MyScenario::ScenarioMethod(AbcCtx &ctx) {
25
    int &a = CPPTESK_ITERATION_VARIABLE(a);
26
    ...
27
    int &z = CPPTESK_ITERATION_VARIABLE(z);
28
    
29
    CPPTESK_ITERATION_BEGIN
30
    for(a = 0; a < Na; a++)
31
    ...
32
    for(z = 0; z < Nz; z++) {
33
        CPPTESK_ITERATION_ACTION {
34
            ...
35
            CPPTESK_ITERATION_YIELD(...);
36
        }
37
    }
38
    CPPTESK_ITERATION_END
39
}
40
</code></pre>
41
42
Scenario method @ScenarioMethod@ for given reference model state (_specification state_) @ModelState@ produces stimulus set, where each stimulus is identified by integer numbers from range @[0, Nmax(ScenarioMethod, ModelState)-1]@, where @Nmax(ScenarioMethod, ModelState)@ is the number of executions of block @CPPTESK_ITERATION_ACTION@ for scenario methods of given reference model state.
43
44
Aggregated stimulus iterator is obtained by “aggregation” of iterators defined in scenario methods. Test scenario stimulus iterator describes a set of all possible stimuli and introduces current test scenario-wide system of stimulus identification. If reference model state ModelState is fixed, stimuli are identified by integer numbers from range @[0, Nmax(ModelState)-1]@, where @Nmax(ModelState)=i=0,n-1 {Nmax(ScenarioMethodi, ModelState)}@. Numeration of stimuli accounts order of scenario method registration.
45
46
h3. State calculation function
47
48
State calculation function is defined in state calculation method of scenario class. Type of return value can be scalar (int, float, etc.) or of string type @(std::string)@. Return value is interpreted as reference model state at some level of abstraction.
49
50
State calculation function is unnecessary test scenario component and used only by test engine @fsm@.
51
52
h2. Test engines
53
54
Test engines are controlled by command line parameters; some of them are common for all engines.
55
* _--cpu_ — running test host device identifier (this parameter is sensible only in distributed testing);
56
* _--length_ — length of test sequence (in current version of C++TESK Testing ToolKit test engine @fsm@ ignores parameter _--length_);
57
* _--print-progress_ — print of test progress.
58
59
h3. Common command line parameters
60
61
*Parameter cpu*
62
63
Parameter _--cpu integer_ sets identifier of host device (computer, microprocessor or core) which runs current test. This parameter is used only in case of distributed among several host devices testing. The main purpose of this parameter is varying of test executions at different host devices. E.g., this parameter is used for random seed setting and in choosing of the following stimulus (graph arc) by test engine fsm.
64
65
*Parameter length*
66
67
Parameter _--length integer_ restricts the length of test sequence generated by test engine. When the length is equal to the given number, test is finished.
68
69
*Option print-progress*
70
71
Option _--print-progress_ turns on print of test execution progress (state graph exploration).
72
73
*Default values*
74
75
Option _--print-progress_ is turned off by default, parameters _--cpu_ and _--length_ have the following values.
76
77
_--cpu 0 --length 1000_
78
79
h3. Test engine @fsm@
80
81
Test engine @fsm@ generates test sequence by finite state machine state graph exploration. The graph is represented implicitly in test scenario. The criterion of test completeness is visiting of all states being reachable from the initial state and traversing all arcs issuing from them.
82
83
*Brief algorithm description*
84
85
Test engine fsm works in the following way. At each step it has current state computed. There are two ways: (1) this state has non traversed arcs (it is more correct to speak about _stimuli_ not _arcs_ as in case of nondeterministic graph one stimulus can correspond to several arcs issuing from the same state) and (2) all arcs issuing from this state have been traversed. It the first case test engine selects one of the non traversed arcs, applies correspondent stimulus to the target system and test keeps on going. The second case has two alternatives: (2.1) there are other states (from having been visited) with non traversed arcs, and (2.2) all known arcs have been traversed. In the first case test engine finds the way to the state with non traversed arcs. Eventually situation (2.1) becomes situation (1). In the second case test is finished.
86
87
*Command line parameters*
88
89
Test engine fsm supports the following command line options.
90
* _--randomize_ — randomization of arc selection;
91
* _--nondeterministic_ — support of nondeterministic arcs;
92
* _--dump-fsm_ — saving of state graph in file after test finalizing:
93
** _--full-graph_ — saving of the whole graph;
94
** _--forward-tree_ — saving of spanning tree.
95
96
_Option randomize_
97
98
Option _--randomize_ turns on randomized selection of the following arc. It means that if test engine has a choice which arc should be selected, test engine choose arc randomly. If this option is not set, arcs are selected in the order prescribed by their order in test scenario.
99
100
_Option nondeterministic_
101
102
Option _--nondeterministic_ turns on support of _nondeterministic graphs_, i.e. graphs where several arcs labeled by the same stimulus can issue from the same state. The main difficulty in traversing of nondeterministic graphs is absence of possibility of determination which arc has been traversed by applying some or other stimulus. It makes finding of paths with non traversed arcs more difficult.
103
104
Setting of option _--nondeterministic_ allows usage of nondeterministic arc during path finding (increasing class of supported graphs). If this option is not set, paths are constructed via deterministic arcs.
105
106
_Option dump-fsm_
107
108
Option _--dump-fsm_ is used for saving of state graph in file after test finalizing. File has fixed name fsm.gv; in this file data are represented in Graphviz format, which is an open source graph visualization package (http://www.graphviz.org).
109
110
_Option full-graph_
111
112
Option _--full-graph_ (set together with --dump-fsm) saves state graph as a whole.
113
114
*Notice*: options --full-graph and --forward-tree are incompatible.
115
116
_Option forward-tree_
117
118
Option _--forward-tree_ (set together with _--dump-fsm_) saves only state graph spanning tree.
119
120
*Notice*: options _--forward-tree_ and _--full-graph_ are incompatible.
121
122
_Default values_
123
124
Options _--randomize_, _--nondeterministic_, and _--dump-fsm_ are not set by default.
125
If option _--dump-fsm_ is set, state graph is saved as a whole by default.
126
127
h3. Test engine @rnd@
128
129
Test engine @rnd@ constructs test sequence randomly selecting random stimulus or random stimulus set from the list of allowed in test scenario stimuli at each work step. Test is finished when given number of stimulus is called.
130
131
*Brief algorithm description*
132
133
There are two modes of test engine @rnd@ work. The first one is sequential (see chapter _«Option sequential»_) and parallel (see chapter _«Option parallel»_).
134
In sequential mode all the stimuli, set up by test action iterator, are equitable. At each work step, identifier of stimulus is randomly selected from range @[0, Nmax(ModelState)-1]@, and correspondent stimulus is applied.
135
136
In parallel mode stimulus with identifier 0 has a special meaning playing role of delay stimulus. All the other stimuli are not allowed to shift simulation time (they are “immediate” actions without waiting of reactions for them). In this mode at each work step random stimulus sequence (_multi stimulus_) is created. This sequence is finished by stimulus with identifier 0. In the other words, several stimuli are applied in parallel, and then some delay happens.
137
138
Size of multi stimulus depends on _load mode_. Test engine @rnd@ supports four load modes.
139
* _minimum load mode_ (see chapter _«Option min-load»_);
140
* _maximum load mode_ (see chapter _«Option max-load»_);
141
* _fixed load mode_ (see chapter _«Parameter fix-load»_);
142
* _variable load mode_ (see chapter _«Option var-load»_).
143
144
The criterion of test completeness is passing of certain number of test steps (see chapter _«Parameter length»_).
145
146
*Command line parameters*
147
148
Test engine rnd supports the following command line parameters.
149
* _--sequential_ — sequential mode;
150
* _--parallel_ — parallel mode:
151
* _--min-load_ — minimum load mode;
152
* _--max-load_ — maximum load mode;
153
* _--fix-load_ — fixed load mode;
154
* _--var-load_ — variable load mode.
155
156
_Option sequential_
157
158
Option _--sequential_ turns on sequential mode of test engine work. In this mode, test engine at each step selects random stimulus from the list of available in test scenario stimuli. Sequential mode is aimed for systems which does not support application of stimuli in parallel mode.
159
160
*Notice*: options _--sequential_ and _--parallel_ are mutually exclusive.
161
162
_Option parallel_
163
164
Option _--parallel_ turns on parallel mode of test engine work. In this mode, test engine at each step generates random stimulus sequence finished with stimulus with identifier 0 — delay stimulus (typically this is a scenario method without iterations called @nop()@ or @delay()@) . All the stimuli except stimulus 0 are supposed to run immediately. Despite their attempt to run some or other operation, their real start is performed only after calling stimulus 0 when time is shifted. Test step in parallel mode is schematically showed in figure 1.
165
166
TODO: no figure
167
*Figure 1. Test step in parallel mode*
168
169
*Notice*: options _--sequential_ and _--parallel_ are mutually exclusive.
170
171
_Option min-load_
172
173
Option _--min-load_ turns on minimal load mode allowing not more than one stimulus at each work step. This mode is typically used during debug of test system.
174
175
_Option max-load_
176
177
Option _--max-load_ turns on maximum load mode to apply all possible stimuli described in test scenario at each work step.
178
179
_Parameter fix-load_
180
181
Parameter _--fix-load load_percentage_ sets fixed load mode to apply certain part of stimuli at each work step. E.g., if _--fix-load 50_ is written, half of the whole stimulus set will be applied in parallel at each step.
182
183
_Option var-load_
184
185
Option _--var-load_ turns on variable load mode to let test system load be smoothly increased from minimum to maximum.
186
187
_Default values_
188
189
Option _--sequential_ is used by default.
190
191
If option _--parallel_ is used, variable load mode _--var-load_ is used by default.