532af3bd5e967121bedfe951e9f0043af24e8875
[sliver-openvswitch.git] / tests / library.at
1 AT_BANNER([library unit tests])
2
3 AT_SETUP([test flow extractor])
4 AT_CHECK([$PERL `which flowgen.pl` >/dev/null 3>flows 4>pcap])
5 AT_CHECK([test-flows <flows 3<pcap], [0], [checked 247 packets, 0 errors
6 ])
7 AT_CLEANUP
8
9 AT_SETUP([test TCP/IP checksumming])
10 AT_CHECK([test-csum], [0], [....#....#....##................................#................................#
11 ])
12 AT_CLEANUP
13
14 AT_SETUP([test hash functions])
15 AT_CHECK([test-hash])
16 AT_CLEANUP
17
18 AT_SETUP([test hash map])
19 AT_CHECK([test-hmap], [0], [.........
20 ])
21 AT_CLEANUP
22
23 AT_SETUP([test hash index])
24 AT_CHECK([test-hindex], [0], [..................
25 ])
26 AT_CLEANUP
27
28 AT_SETUP([test linked lists])
29 AT_CHECK([test-list], [0], [..
30 ])
31 AT_CLEANUP
32
33 AT_SETUP([test packet library])
34 AT_CHECK([test-packets])
35 AT_CLEANUP
36
37 AT_SETUP([test SHA-1])
38 AT_CHECK([test-sha1], [0], [.........
39 ])
40 AT_CLEANUP
41
42 AT_SETUP([test type properties])
43 AT_CHECK([test-type-props])
44 AT_CLEANUP
45
46 AT_SETUP([test strtok_r bug fix])
47 AT_CHECK([test-strtok_r], [0], [NULL NULL
48 ])
49 AT_CLEANUP
50
51 AT_SETUP([test byte order conversion])
52 AT_KEYWORDS([byte order])
53 AT_CHECK([test-byte-order])
54 AT_CLEANUP
55
56 AT_SETUP([test random number generator])
57 AT_CHECK([test-random], [0], [dnl
58 average=7fa2014f
59
60 bit      0     1
61   0  4946  5054
62   1  4939  5061
63   2  4947  5053
64   3  4935  5065
65   4  5004  4996
66   5  4998  5002
67   6  5062  4938
68   7  5009  4991
69   8  5001  4999
70   9  5022  4978
71  10  5006  4994
72  11  5039  4961
73  12  4940  5060
74  13  5048  4952
75  14  4930  5070
76  15  4973  5027
77  16  4954  5046
78  17  5043  4957
79  18  5020  4980
80  19  5104  4896
81  20  5051  4949
82  21  5003  4997
83  22  5110  4890
84  23  4950  5050
85  24  5016  4984
86  25  5019  4981
87  26  4948  5052
88  27  4995  5005
89  28  4995  5005
90  29  4969  5031
91  30  5109  4891
92  31  4984  5016
93 (expected values are 5000)
94
95 nibble   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
96      0 640 589 610 613 588 632 650 613 582 646 627 640 612 650 637 671
97      1 626 642 663 620 630 609 617 602 615 638 614 644 641 597 598 644
98      2 667 611 617 613 609 629 642 651 604 641 594 659 651 610 617 585
99      3 621 662 594 605 618 644 616 613 613 616 611 608 614 660 653 652
100      4 641 668 621 664 619 624 625 642 624 629 607 566 599 639 618 614
101      5 666 629 620 621 581 615 598 620 630 651 671 622 628 603 657 588
102      6 620 640 621 606 603 644 628 633 620 597 653 591 637 658 634 615
103      7 636 645 679 593 598 609 612 612 623 626 638 669 603 629 606 622
104 (expected values are 625)
105 ])
106 AT_CLEANUP
107
108 m4_foreach(
109   [testname],
110   [[ctz],
111    [popcount],
112    [log_2_floor],
113    [bitwise_copy],
114    [bitwise_zero],
115    [bitwise_one],
116    [bitwise_is_all_zeros]],
117   [AT_SETUP([testname[()] function])
118    AT_KEYWORDS([testname])
119    AT_CHECK([test-util testname], [0], [], [])
120    AT_CLEANUP])
121
122 AT_SETUP([test unix socket, short pathname - C])
123 AT_CHECK([test-unix-socket x])
124 AT_CLEANUP
125
126 dnl Unix sockets with long names are problematic because the name has to
127 dnl go in a fixed-length field in struct sockaddr_un.  Generally the limit
128 dnl is about 100 bytes.  On Linux, we work around this by indirecting through
129 dnl a directory fd using /proc/self/fd/<dirfd>.  We do not have a workaround
130 dnl for other platforms, so we skip the test there.
131 AT_SETUP([test unix socket, long pathname - C])
132 AT_SKIP_IF([test ! -d /proc/self/fd])
133 dnl Linux has a 108 byte limit; this is 150 bytes long.
134 longname=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
135 mkdir $longname
136 cd $longname
137 AT_CHECK([test-unix-socket ../$longname/socket socket])
138 AT_CLEANUP
139
140 AT_SETUP([test unix socket, short pathname - Python])
141 AT_SKIP_IF([test $HAVE_PYTHON = no])
142 AT_CHECK([$PYTHON $srcdir/test-unix-socket.py x])
143 AT_CLEANUP
144
145 dnl Unix sockets with long names are problematic because the name has to
146 dnl go in a fixed-length field in struct sockaddr_un.  Generally the limit
147 dnl is about 100 bytes.  On Linux, we work around this by indirecting through
148 dnl a directory fd using /proc/self/fd/<dirfd>.  We do not have a workaround
149 dnl for other platforms, so we skip the test there.
150 AT_SETUP([test unix socket, long pathname - Python])
151 AT_SKIP_IF([test $HAVE_PYTHON = no])
152 AT_SKIP_IF([test ! -d /proc/self/fd])
153 dnl Linux has a 108 byte limit; this is 150 bytes long.
154 longname=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
155 mkdir $longname
156 cd $longname
157 AT_CHECK([$PYTHON $abs_srcdir/test-unix-socket.py ../$longname/socket socket])
158 AT_CLEANUP
159
160 AT_SETUP([ovs_assert])
161 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
162 AT_CHECK([test-util -voff -vfile:info '-vPATTERN:file:%c|%p|%m' --log-file assert || kill -l $?],
163   [0], [ABRT
164 ], [stderr])
165
166 AT_CHECK([sed 's/\(opened log file\) .*/\1/
167 s/|[[^|]]*: /|/' test-util.log], [0], [dnl
168 vlog|INFO|opened log file
169 util|EMER|assertion false failed in test_assert()
170 ])
171
172 AT_CHECK([sed 's/.*: //
173 1q' stderr], [0],
174   [assertion false failed in test_assert()
175 ])
176
177 AT_CLEANUP