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