summaryrefslogtreecommitdiff
path: root/tests/library.at
blob: 164ae789ddefa86299e892493e53350179b31a43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
AT_BANNER([library unit tests])

AT_SETUP([flow extractor])
AT_CHECK([$PYTHON3 $srcdir/flowgen.py >/dev/null])
AT_CHECK([ovstest test-flows flows pcap], [0], [checked 247 packets, 0 errors
])
AT_CLEANUP

AT_SETUP([TCP/IP checksumming])
AT_CHECK([ovstest test-csum], [0], [....#....#....####................................#................................#
])
AT_CLEANUP

AT_SETUP([hash functions])
AT_CHECK([ovstest test-hash])
AT_CLEANUP

AT_SETUP([hash map])
AT_KEYWORDS([hmap])
AT_CHECK([ovstest test-hmap], [0], [............
])
AT_CLEANUP

AT_SETUP([hash index])
AT_KEYWORDS([hindex])
AT_CHECK([ovstest test-hindex], [0], [.....................
])
AT_CLEANUP

AT_SETUP([test rcu linked lists])
AT_CHECK([ovstest test-rculist], [0], [.....
])
AT_CLEANUP

AT_SETUP([cuckoo hash])
AT_KEYWORDS([cmap])
AT_CHECK([ovstest test-cmap check 1], [0], [...
])
AT_CLEANUP

AT_SETUP([counting cuckoo hash])
AT_KEYWORDS([cmap])
AT_CHECK([ovstest test-ccmap check 1], [0], [...
])
AT_CLEANUP

AT_SETUP([atomic operations])
AT_CHECK([ovstest test-atomic])
AT_CLEANUP

AT_SETUP([test linked lists])
AT_CHECK([ovstest test-list], [0], [....
])
AT_CLEANUP

AT_SETUP([packet library])
AT_CHECK([ovstest test-packets])
AT_CLEANUP

AT_SETUP([SHA-1])
AT_KEYWORDS([sha1])
AT_CHECK([ovstest test-sha1], [0], [....................
])
AT_CLEANUP

AT_SETUP([test skiplist])
AT_KEYWORDS([skiplist])
AT_CHECK([ovstest test-skiplist], [0], [skiplist insert
skiplist delete
skiplist find
skiplist forward_to
skiplist random

])
AT_CLEANUP

AT_SETUP([type properties])
AT_CHECK([test-type-props])
AT_CLEANUP

AT_SETUP([strtok_r bug fix])
AT_CHECK([test-strtok_r], [0], [NULL NULL
])
AT_CLEANUP

AT_SETUP([byte order conversion])
AT_KEYWORDS([byte order])
AT_CHECK([ovstest test-byte-order])
AT_CLEANUP

AT_SETUP([random number generator])
AT_CHECK([ovstest test-random], [0], [dnl
average=7fa2014f

bit      0     1
  0  4946  5054
  1  4939  5061
  2  4947  5053
  3  4935  5065
  4  5004  4996
  5  4998  5002
  6  5062  4938
  7  5009  4991
  8  5001  4999
  9  5022  4978
 10  5006  4994
 11  5039  4961
 12  4940  5060
 13  5048  4952
 14  4930  5070
 15  4973  5027
 16  4954  5046
 17  5043  4957
 18  5020  4980
 19  5104  4896
 20  5051  4949
 21  5003  4997
 22  5110  4890
 23  4950  5050
 24  5016  4984
 25  5019  4981
 26  4948  5052
 27  4995  5005
 28  4995  5005
 29  4969  5031
 30  5109  4891
 31  4984  5016
(expected values are 5000)

nibble   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
     0 640 589 610 613 588 632 650 613 582 646 627 640 612 650 637 671
     1 626 642 663 620 630 609 617 602 615 638 614 644 641 597 598 644
     2 667 611 617 613 609 629 642 651 604 641 594 659 651 610 617 585
     3 621 662 594 605 618 644 616 613 613 616 611 608 614 660 653 652
     4 641 668 621 664 619 624 625 642 624 629 607 566 599 639 618 614
     5 666 629 620 621 581 615 598 620 630 651 671 622 628 603 657 588
     6 620 640 621 606 603 644 628 633 620 597 653 591 637 658 634 615
     7 636 645 679 593 598 609 612 612 623 626 638 669 603 629 606 622
(expected values are 625)
])
AT_CLEANUP

m4_foreach(
  [testname],
  [[ctz],
   [clz],
   [round_up_pow2],
   [round_down_pow2],
   [count_1bits],
   [log_2_floor],
   [bitwise_copy],
   [bitwise_zero],
   [bitwise_one],
   [bitwise_is_all_zeros],
   [bitwise_rscan],
   [ovs_scan]],
  [AT_SETUP([testname[()] function])
   AT_KEYWORDS([testname])
   AT_CHECK([ovstest test-util testname], [0], [], [])
   AT_CLEANUP])

AT_SETUP([unix socket, short pathname - C])
AT_SKIP_IF([test "$IS_WIN32" = "yes"])
AT_CHECK([ovstest test-unix-socket x])
AT_CLEANUP

dnl Unix sockets with long names are problematic because the name has to
dnl go in a fixed-length field in struct sockaddr_un.  Generally the limit
dnl is about 100 bytes.  On Linux, we work around this by indirecting through
dnl a directory fd using /proc/self/fd/<dirfd>.  We do not have a workaround
dnl for other platforms, so we skip the test there.
AT_SETUP([unix socket, long pathname - C])
AT_SKIP_IF([test "$IS_WIN32" = "yes"])
dnl Linux sockaddr_un has a 108-byte limit, so this needs to be longer.
dnl Linux "ecryptfs" has a 143-byte limit, so we use that many bytes.
longname=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012

dnl Skip the test if the directory can't be created (presumably the file
dnl system doesn't support such long names).
AT_CHECK([mkdir $longname || exit 77])

AT_CHECK([cd $longname && ovstest test-unix-socket ../$longname/socket socket])
AT_CLEANUP

AT_SETUP([unix socket, short pathname - Python3])
AT_SKIP_IF([test "$IS_WIN32" = "yes"])
AT_KEYWORDS([python unixsocket])
AT_CHECK([$PYTHON3 $srcdir/test-unix-socket.py x])
AT_CLEANUP

dnl Unix sockets with long names are problematic because the name has to
dnl go in a fixed-length field in struct sockaddr_un.  Generally the limit
dnl is about 100 bytes.  On Linux, we work around this by indirecting through
dnl a directory fd using /proc/self/fd/<dirfd>.  We do not have a workaround
dnl for other platforms, so we skip the test there.
AT_SETUP([unix socket, long pathname - Python3])
AT_SKIP_IF([test "$IS_WIN32" = "yes"])
AT_KEYWORDS([python unixsocket])
dnl Linux sockaddr_un has a 108-byte limit, so this needs to be longer.
dnl Linux "ecryptfs" has a 143-byte limit, so we use that many bytes.
longname=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012

dnl Skip the test if the directory can't be created (presumably the file
dnl system doesn't support such long names).
AT_CHECK([mkdir $longname || exit 77])
AT_CHECK([cd $longname && $PYTHON3 $abs_srcdir/test-unix-socket.py ../$longname/socket socket])
AT_CLEANUP

AT_SETUP([ovs_assert])
if test "$IS_WIN32" = "yes"; then
  exit_status=9
else
  # SIGABRT + 128
  exit_status=134
fi
AT_CHECK([ovstest test-util -voff -vfile:info '-vPATTERN:file:%c|%p|%m' --log-file assert],
  [$exit_status], [], [stderr])

AT_CHECK([sed 's/\(opened log file\) .*/\1/
s/|[[^|]]*: /|/' test-util.log], [0], [dnl
vlog|INFO|opened log file
util|EMER|assertion false failed in test_assert()
])

AT_CHECK([sed 's/.*: //
1q' stderr], [0],
  [assertion false failed in test_assert()
])

AT_CLEANUP

AT_SETUP([saturating arithmetic])
AT_KEYWORDS([sat math sat_math])
AT_CHECK([ovstest test-util sat_math])
AT_CLEANUP

AT_SETUP([snprintf])
AT_CHECK([ovstest test-util snprintf])
AT_CLEANUP

AT_SETUP([bitmap functions])
AT_CHECK([ovstest test-bitmap check], [0], [..
])
AT_CLEANUP

AT_SETUP([use of public headers])
AT_CHECK([test-lib], [0], [])
AT_CLEANUP

AT_SETUP([ofpbuf module])
AT_CHECK([ovstest test-ofpbuf], [0], [])
AT_CLEANUP

AT_SETUP([barrier module])
AT_KEYWORDS([barrier])
AT_CHECK([ovstest test-barrier], [0], [])
AT_CLEANUP

AT_SETUP([rcu])
AT_CHECK([ovstest test-rcu], [0], [])
AT_CLEANUP

AT_SETUP([stopwatch module])
AT_CHECK([ovstest test-stopwatch], [0], [......
], [ignore])
AT_CLEANUP

AT_SETUP([netlink policy])
AT_SKIP_IF([test "$IS_WIN32" = "yes"])
AT_SKIP_IF([test "$IS_BSD" = "yes"])
AT_CHECK([ovstest test-netlink-policy ll_addr], [0])
AT_CLEANUP

AT_SETUP([mpsc-queue module])
AT_CHECK([ovstest test-mpsc-queue check], [0], [....
])
AT_CLEANUP

AT_SETUP([id-fpool module])
AT_CHECK([ovstest test-id-fpool check], [0], [])
AT_CLEANUP

AT_SETUP([uuidset module])
AT_CHECK([ovstest test-uuidset], [0], [], [ignore])
AT_CLEANUP