ra_testscenario.py 10.4 KB
Newer Older
1
2
3
4
import collections

from z3gi.model.ra import Action

5
6
labels = ["label"]

7
8
def act(val, label=None):
    if label is None:
9
        return Action(labels[0], val)
10
11
12
    else:
        return Action(label, val)

13
14


15
16
17
18
"""Test scenarios contain a list of traces together with the number of locations and registers of the SUT generating
 these traces.
"""
RaTestScenario = collections.namedtuple('RaTestCase',
19
20
                                        ('description',
                                            'traces',
21
22
23
24
25
26
27
                                    'nr_locations',
                                    'nr_registers'
                                    ))

# Define data

# store something and accept, as long as you give the stored value, accept, otherwise go back to start and reject
28
sut_m1 = RaTestScenario("store_1_remember_while_eq_then_restore", [([], False),
29
30
31
32
33
34
35
36
37
38
39
40
41
                         ([act(9)], True),
                         ([act(5), act(5)], True),
                         ([act(6), act(6)], True),
                         ([act(1), act(7)], False),
                         ([act(8), act(4)], False),
                         ([act(8), act(2), act(2)], True),
                         ([act(4), act(3), act(3), act(1)], False),
                         ([act(0), act(1), act(1), act(6), act(4)], True),
                         ([act(1), act(2), act(2), act(6), act(9), act(9)], True),
                         ([act(1), act(2), act(1)], True)
                         ], 2, 1)

# doing three transitions, and accept if the first and third parameters are the same
42
sut_m2 = RaTestScenario("store_1_true_then_remember", [
43
44
45
46
47
48
49
50
51
    ([act(1)], True),
    ([act(1), act(1)], False),
    ([act(1), act(2)], False),
    ([act(1), act(1), act(1)], True),
    ([act(1), act(1), act(2)], False),
    ([act(1), act(2), act(1)], True),
    ([act(1), act(2), act(3)], False),
    ([act(1), act(1), act(1), act(1)], False),
    ([act(1), act(1), act(1), act(2)], False),
Paul Fiterau Brostean's avatar
Paul Fiterau Brostean committed
52
53
54
55
56
57
    ([act(1), act(1), act(2), act(1)], False),
    ([act(1), act(1), act(2), act(2)], False),
    ([act(1), act(2), act(1), act(1)], False),
    ([act(1), act(2), act(1), act(2)], False),
    ([act(1), act(2), act(2), act(1)], False),
    ([act(1), act(2), act(2), act(2)], False),
58
    # This is a check for Rick, ignore the traces below
Paul Fiterau Brostean's avatar
Paul Fiterau Brostean committed
59
60
    # ([act(1), act(1), act(2), act(1), act(1)], False),
    # ([act(1), act(1), act(2), act(1), act(2)], True)
61
], 4, 1)
62
63

# check for unique valuedness (non-UV 4 LOC, UV 5 LOC)
64
sut_m3 = RaTestScenario ("store_2_select_either_UV", [
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
   ([], False),
   ([act(1)], False),
   ([act(1), act(1)], False),
   ([act(1), act(2)], False),
   ([act(1), act(1), act(1)], True),
   ([act(1), act(2), act(1)], True),
   ([act(1), act(2), act(2)], True),
   ([act(1), act(2), act(3)], False),
   # add this and it's no longer SAT with 3 locations
   ([act(1), act(2), act(2), act(1), act(3)], True),
   ([act(1), act(1), act(1), act(1)], True),
   ([act(1), act(1), act(2), act(1)], True),
   ([act(0), act(1), act(2), act(2)], False),
   ([act(0), act(1), act(2), act(0)], True),
    ([act(0), act(1), act(2), act(1)], True),
   ([act(1), act(1), act(1), act(2)], True),
   ([act(1), act(1), act(1), act(1), act(2)], True),
   ([act(1), act(1), act(1), act(1), act(2), act(2)], True),
   ([act(1), act(1), act(1), act(2), act(2)], True),
   ([act(1), act(1), act(1), act(2), act(3)], True),
   ([act(1), act(2), act(2), act(2)], True),
   ([act(1), act(2), act(2), act(1)], True),
   ([act(1), act(2), act(3), act(4), act(1)], True),
   ([act(1), act(2), act(2), act(2), act(3)], True)
89
], 5, 2)
90
91
92

# check for non-shifting property (3 LOC NS, 4 LOC non-NS)
# expect this system to require one additional location than if our constraints allowed value shifting between registers
93
sut_m4 = RaTestScenario ("store_2_toggle_select_NS", [
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
   ([], False),
   ([act(1)], False),
   ([act(1), act(1)], False),
   ([act(1), act(2)], False),
   ([act(1), act(1), act(1)], False),
   ([act(1), act(2), act(1)], True),
   ([act(1), act(2), act(2)], False),
   ([act(1), act(2), act(3)], False),
   ([act(1), act(2), act(1), act(2)], True),
   ([act(1), act(2), act(1), act(1)], False),
   ([act(1), act(2), act(1), act(3)], False),
   ([act(1), act(2), act(1), act(3), act(3)], False),
   # add this and it is no longer SAT (for 3 locations)
   ([act(1), act(2), act(1), act(2), act(1)], True),
   ([act(1), act(2), act(1), act(3)], False),
   ([act(1), act(2), act(2), act(1)], False),
   ([act(1), act(2), act(1), act(1)], False),
   ([act(1), act(2), act(1), act(2)], True),
   ([act(1), act(2), act(1), act(2), act(1)], True),
   ([act(1), act(2), act(1), act(2), act(1), act(2)], True)
114
], 5, 2)
115
116

# Go to an accepting sink if the third value is different than the first two, else go to a rejecting sink
117
sut_m5 = RaTestScenario("store_2_third_diff", [
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
    ([], False),
    ([act(0)], False),
    ([act(0), act(0)], False),
    ([act(0), act(1)], False),
    ([act(0), act(0), act(0)], False),
    ([act(0), act(0), act(1)], True),
    ([act(0), act(1), act(0)], False),
    ([act(0), act(1), act(1)], False),
    ([act(0), act(1), act(2)], True),
    ([act(0), act(0), act(0), act(0)], False),
    ([act(0), act(0), act(0), act(1)], False),
    ([act(0), act(0), act(1), act(0)], True),
    ([act(0), act(0), act(1), act(1)], True),
    ([act(0), act(0), act(1), act(2)], True),
    ([act(0), act(1), act(0), act(0)], False),
    ([act(0), act(1), act(0), act(1)], False),
    ([act(0), act(1), act(0), act(2)], False),
    ([act(0), act(1), act(1), act(0)], False),
    ([act(0), act(1), act(1), act(1)], False),
    ([act(0), act(1), act(1), act(2)], False),
    ([act(0), act(1), act(2), act(0)], True),
    ([act(0), act(1), act(2), act(1)], True),
    ([act(0), act(1), act(2), act(2)], True),
    ([act(0), act(1), act(2), act(3)], True),
    ([act(0), act(0), act(0), act(0), act(0)], False),
    ([act(0), act(0), act(0), act(0), act(1)], False),
    ([act(0), act(0), act(0), act(1), act(0)], False),
    ([act(0), act(0), act(0), act(1), act(1)], False),
    ([act(0), act(0), act(0), act(1), act(2)], False),
    ([act(0), act(0), act(1), act(0), act(0)], True),
    ([act(0), act(0), act(1), act(0), act(1)], True),
    ([act(0), act(0), act(1), act(0), act(2)], True),
    ([act(0), act(0), act(1), act(1), act(0)], True),
    ([act(0), act(0), act(1), act(1), act(1)], True),
    ([act(0), act(0), act(1), act(1), act(2)], True),
    ([act(0), act(0), act(1), act(2), act(0)], True),
    ([act(0), act(0), act(1), act(2), act(1)], True),
    ([act(0), act(0), act(1), act(2), act(2)], True),
    ([act(0), act(0), act(1), act(2), act(3)], True),
    ([act(0), act(1), act(0), act(0), act(0)], False),
    ([act(0), act(1), act(0), act(0), act(1)], False),
    ([act(0), act(1), act(0), act(0), act(2)], False),
    ([act(0), act(1), act(0), act(1), act(0)], False),
    ([act(0), act(1), act(0), act(1), act(1)], False),
    ([act(0), act(1), act(0), act(1), act(2)], False),
    ([act(0), act(1), act(0), act(2), act(0)], False),
    ([act(0), act(1), act(0), act(2), act(1)], False),
    ([act(0), act(1), act(0), act(2), act(2)], False),
    ([act(0), act(1), act(0), act(2), act(3)], False),
    ([act(0), act(1), act(1), act(0), act(0)], False),
    ([act(0), act(1), act(1), act(0), act(1)], False),
    ([act(0), act(1), act(1), act(0), act(2)], False),
    ([act(0), act(1), act(1), act(1), act(0)], False),
    ([act(0), act(1), act(1), act(1), act(1)], False),
    ([act(0), act(1), act(1), act(1), act(2)], False),
    ([act(0), act(1), act(1), act(2), act(0)], False),
    ([act(0), act(1), act(1), act(2), act(1)], False),
    ([act(0), act(1), act(1), act(2), act(2)], False),
    ([act(0), act(1), act(1), act(2), act(3)], False),
    ([act(0), act(1), act(2), act(0), act(0)], True),
    ([act(0), act(1), act(2), act(0), act(1)], True),
    ([act(0), act(1), act(2), act(0), act(2)], True),
    ([act(0), act(1), act(2), act(0), act(3)], True),
    ([act(0), act(1), act(2), act(1), act(0)], True),
    ([act(0), act(1), act(2), act(1), act(1)], True),
    ([act(0), act(1), act(2), act(1), act(2)], True),
    ([act(0), act(1), act(2), act(1), act(3)], True),
    ([act(0), act(1), act(2), act(2), act(0)], True),
    ([act(0), act(1), act(2), act(2), act(1)], True),
    ([act(0), act(1), act(2), act(2), act(2)], True),
    ([act(0), act(1), act(2), act(2), act(3)], True),
    ([act(0), act(1), act(2), act(3), act(0)], True),
    ([act(0), act(1), act(2), act(3), act(1)], True),
    ([act(0), act(1), act(2), act(3), act(2)], True),
    ([act(0), act(1), act(2), act(3), act(3)], True),
    ([act(0), act(1), act(2), act(3), act(4)], True),
], 5, 2)

data_m6 = [
    ([], False),
    ([act(0)], True),
    ([act(0), act(0)], False),
    ([act(0), act(1)], False),
    #([act(0), act(0), act(0)], ???),
    ([act(0), act(0), act(1)], False),
    ([act(0), act(1), act(0)], True),
    ([act(0), act(1), act(1)], False),
    ([act(0), act(1), act(2)], False),
    #([act(0), act(0), act(0), act(0)], ???),
    #([act(0), act(0), act(0), act(1)], ???),
    #([act(0), act(0), act(1), act(0)], ???),
    ([act(0), act(0), act(1), act(1)], False),
    ([act(0), act(0), act(1), act(2)], False),
    ([act(0), act(1), act(0), act(0)], False),
    ([act(0), act(1), act(0), act(1)], True),
    ([act(0), act(1), act(0), act(2)], False),
    ([act(0), act(1), act(1), act(0)], True),
    ([act(0), act(1), act(1), act(1)], True),
    ([act(0), act(1), act(1), act(2)], True),
    ([act(0), act(1), act(2), act(0)], True),
    ([act(0), act(1), act(2), act(1)], False),
    ([act(0), act(1), act(2), act(2)], False),
    ([act(0), act(1), act(2), act(3)], False),
]

data_m7 = [
    ([], False),
    ([act(0)], False),
    ([act(0), act(0)], False),
    ([act(0), act(1)], False),
    ([act(0), act(0), act(0)], False),
    ([act(0), act(0), act(1)], True),
#    ([act(0), act(1), act(0)], False),
#    ([act(0), act(1), act(1)], False),
#    ([act(0), act(1), act(2)], True),
]

Rick Smetsers's avatar
Rick Smetsers committed
235
236
237
238
239
240
241
242
# IO
data_m8 = [
    [(act(0, 'in'), act(100, 'OK')), (act(0, 'in'), act(101, 'OK')), (act(0, 'in'), act(102, 'OK')), (act(0, 'in'), act(103, 'OK'))],
    [(act(0, 'in'), act(100, 'OK')), (act(0, 'in'), act(101, 'OK')), (act(0, 'in'), act(102, 'OK')), (act(1, 'in'), act(103, 'NOK'))],
    [(act(0, 'in'), act(100, 'OK')), (act(0, 'in'), act(101, 'OK')), (act(1, 'in'), act(102, 'NOK')), (act(0, 'in'), act(103, 'OK'))],
    [(act(0, 'in'), act(100, 'OK')), (act(1, 'in'), act(101, 'NOK')), (act(0, 'in'), act(102, 'OK')), (act(0, 'in'), act(103, 'OK'))],
    [(act(1, 'in'), act(100, 'NOK')), (act(0, 'in'), act(101, 'OK')), (act(0, 'in'), act(102, 'OK')), (act(0, 'in'), act(103, 'OK'))],
]