summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-06-23 12:32:41 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-06-24 20:17:53 +0000
commit29b2dd6315ffe29cd212c4d5a846479f56b33d52 (patch)
tree881ba80e88fc461a688c0416abb10956fe14e247 /auto_tests
parent5c2600d87bd000b32b2a37c5a74275912ddd5328 (diff)
Use clang-format for C++ code.
`clang-format -style='{BasedOnStyle: Google, ColumnLimit: 100}'`
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/helpers.h2
-rw-r--r--auto_tests/monolith_test.cc260
-rw-r--r--auto_tests/monolith_test.cpp293
3 files changed, 262 insertions, 293 deletions
diff --git a/auto_tests/helpers.h b/auto_tests/helpers.h
index b953e29a..7af127f5 100644
--- a/auto_tests/helpers.h
+++ b/auto_tests/helpers.h
@@ -9,6 +9,7 @@
9#include <stdio.h> 9#include <stdio.h>
10#include <string.h> 10#include <string.h>
11 11
12#ifndef c_sleep
12#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 13#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
13#include <windows.h> 14#include <windows.h>
14#define c_sleep(x) Sleep(x) 15#define c_sleep(x) Sleep(x)
@@ -16,6 +17,7 @@
16#include <unistd.h> 17#include <unistd.h>
17#define c_sleep(x) usleep(1000 * (x)) 18#define c_sleep(x) usleep(1000 * (x))
18#endif 19#endif
20#endif
19 21
20#define ITERATION_INTERVAL 200 22#define ITERATION_INTERVAL 200
21 23
diff --git a/auto_tests/monolith_test.cc b/auto_tests/monolith_test.cc
new file mode 100644
index 00000000..9fa7ee26
--- /dev/null
+++ b/auto_tests/monolith_test.cc
@@ -0,0 +1,260 @@
1/* Nop-test, just to make sure our code compiles as C++.
2 */
3
4#ifdef __FreeBSD__
5// Include this here, because _XOPEN_SOURCE hides symbols we need.
6//
7// https://lists.freebsd.org/pipermail/freebsd-standards/2004-March/000474.html.
8#include <net/if.h>
9#endif
10
11#ifdef __APPLE__
12#define _DARWIN_C_SOURCE
13#endif
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include "../other/monolith.h"
20#define DHT_C_INCLUDED
21
22#include "../testing/misc_tools.c"
23#include "check_compat.h"
24#include "helpers.h"
25
26#include <ctype.h>
27
28namespace TCP_test {
29int main(void);
30#include "TCP_test.c"
31} // namespace TCP_test
32namespace bootstrap_test {
33int main(void);
34#include "bootstrap_test.c"
35} // namespace bootstrap_test
36namespace conference_test {
37int main(void);
38#include "conference_test.c"
39} // namespace conference_test
40namespace crypto_test {
41int main(void);
42#include "crypto_test.c"
43} // namespace crypto_test
44namespace dht_test {
45int main(void);
46#include "dht_test.c"
47} // namespace dht_test
48namespace encryptsave_test {
49int main(void);
50#include "encryptsave_test.c"
51} // namespace encryptsave_test
52namespace file_saving_test {
53int main(void);
54#include "file_saving_test.c"
55} // namespace file_saving_test
56namespace friend_request_test {
57int main(void);
58#include "friend_request_test.c"
59} // namespace friend_request_test
60namespace lan_discovery_test {
61int main(void);
62#include "lan_discovery_test.c"
63} // namespace lan_discovery_test
64namespace lossless_packet_test {
65int main(void);
66#include "lossless_packet_test.c"
67} // namespace lossless_packet_test
68namespace lossy_packet_test {
69int main(void);
70#include "lossy_packet_test.c"
71} // namespace lossy_packet_test
72namespace messenger_test {
73int main(void);
74#include "messenger_test.c"
75} // namespace messenger_test
76namespace network_test {
77int main(void);
78#include "network_test.c"
79} // namespace network_test
80namespace onion_test {
81int main(void);
82#include "onion_test.c"
83} // namespace onion_test
84namespace save_friend_test {
85int main(void);
86#include "save_friend_test.c"
87} // namespace save_friend_test
88namespace save_load_test {
89int main(void);
90#include "save_load_test.c"
91} // namespace save_load_test
92namespace selfname_change_conference_test {
93int main(void);
94#include "selfname_change_conference_test.c"
95} // namespace selfname_change_conference_test
96namespace self_conference_title_change_test {
97int main(void);
98#include "self_conference_title_change_test.c"
99} // namespace self_conference_title_change_test
100namespace send_message_test {
101int main(void);
102#include "send_message_test.c"
103} // namespace send_message_test
104namespace set_name_test {
105int main(void);
106#include "set_name_test.c"
107} // namespace set_name_test
108namespace set_status_message_test {
109int main(void);
110#include "set_status_message_test.c"
111} // namespace set_status_message_test
112namespace simple_conference_test {
113int main(void);
114#include "simple_conference_test.c"
115} // namespace simple_conference_test
116namespace skeleton_test {
117int main(void);
118#include "skeleton_test.c"
119} // namespace skeleton_test
120namespace toxav_basic_test {
121int main(void);
122#include "toxav_basic_test.c"
123} // namespace toxav_basic_test
124namespace toxav_many_test {
125int main(void);
126#include "toxav_many_test.c"
127} // namespace toxav_many_test
128namespace tox_many_tcp_test {
129int main(void);
130#include "tox_many_tcp_test.c"
131} // namespace tox_many_tcp_test
132namespace tox_many_test {
133int main(void);
134#include "tox_many_test.c"
135} // namespace tox_many_test
136namespace tox_one_test {
137int main(void);
138#include "tox_one_test.c"
139} // namespace tox_one_test
140namespace tox_strncasecmp_test {
141int main(void);
142#include "tox_strncasecmp_test.c"
143} // namespace tox_strncasecmp_test
144namespace typing_test {
145int main(void);
146#include "typing_test.c"
147} // namespace typing_test
148namespace version_test {
149int main(void);
150#include "version_test.c"
151} // namespace version_test
152
153#define PRINT_SIZE 0
154
155template <typename T, size_t Expected, size_t Actual = sizeof(T)>
156void check_size(char const *type) {
157#if PRINT_SIZE
158 printf("CHECK_SIZE(%s, %zu);\n", type, Actual);
159#else
160 static_assert(Actual == Expected, "Bad sizeof - see template expansion errors for details");
161#endif
162}
163
164#define CHECK_SIZE(TYPE, SIZE) check_size<TYPE, SIZE>(#TYPE)
165
166/**
167 * The main function static-asserts that we are aware of all the sizes of all
168 * the structs it toxcore. If you find this failing after you make a change,
169 * switch on the PRINT_SIZE above and copy the number into this function.
170 */
171int main(int argc, char *argv[]) {
172#if defined(__x86_64__) && defined(__LP64__)
173 // toxcore/DHT
174 CHECK_SIZE(Client_data, 496);
175 CHECK_SIZE(Cryptopacket_Handles, 16);
176 CHECK_SIZE(DHT, 676528);
177 CHECK_SIZE(DHT_Friend, 5104);
178 CHECK_SIZE(Hardening, 144);
179 CHECK_SIZE(IPPTs, 40);
180 CHECK_SIZE(IPPTsPng, 232);
181 CHECK_SIZE(NAT, 48);
182 CHECK_SIZE(Node_format, 64);
183 CHECK_SIZE(Shared_Key, 80);
184 CHECK_SIZE(Shared_Keys, 81920);
185 // toxcore/friend_connection
186 CHECK_SIZE(Friend_Conn, 1784);
187 CHECK_SIZE(Friend_Connections, 72);
188 // toxcore/friend_requests
189 CHECK_SIZE(Friend_Requests, 1080);
190 // toxcore/group
191 CHECK_SIZE(Group_c, 728);
192 CHECK_SIZE(Group_Chats, 2120);
193 CHECK_SIZE(Group_Peer, 480);
194 // toxcore/list
195 CHECK_SIZE(BS_LIST, 32);
196 // toxcore/logger
197 CHECK_SIZE(Logger, 24);
198 // toxcore/Messenger
199 CHECK_SIZE(File_Transfers, 72);
200 CHECK_SIZE(Friend, 39264);
201 CHECK_SIZE(Messenger, 2008);
202 CHECK_SIZE(Messenger_Options, 72);
203 CHECK_SIZE(Receipts, 16);
204 // toxcore/net_crypto
205#ifdef __linux__
206 CHECK_SIZE(Crypto_Connection, 525392);
207 CHECK_SIZE(Net_Crypto, 272);
208#endif
209 CHECK_SIZE(New_Connection, 168);
210 CHECK_SIZE(Packet_Data, 1384);
211 CHECK_SIZE(Packets_Array, 262152);
212 // toxcore/network
213 CHECK_SIZE(IP, 24);
214 CHECK_SIZE(IP4, 4);
215#if USE_IPV6
216 CHECK_SIZE(IP6, 16);
217#endif
218 CHECK_SIZE(IP_Port, 32);
219 CHECK_SIZE(Networking_Core, 4112);
220 CHECK_SIZE(Packet_Handler, 16);
221 // toxcore/onion_announce
222 CHECK_SIZE(Cmp_data, 296);
223 CHECK_SIZE(Onion_Announce, 128048);
224 CHECK_SIZE(Onion_Announce_Entry, 288);
225 // toxcore/onion_client
226 CHECK_SIZE(Last_Pinged, 40);
227 CHECK_SIZE(Onion_Client, 15816);
228 CHECK_SIZE(Onion_Client_Cmp_data, 176);
229 CHECK_SIZE(Onion_Client_Paths, 2520);
230 CHECK_SIZE(Onion_Friend, 1936);
231 CHECK_SIZE(Onion_Friend, 1936);
232 CHECK_SIZE(Onion_Node, 168);
233 // toxcore/onion
234 CHECK_SIZE(Onion, 245832);
235 CHECK_SIZE(Onion_Path, 392);
236 // toxcore/ping_array
237 CHECK_SIZE(Ping_Array, 24);
238 CHECK_SIZE(Ping_Array_Entry, 32);
239 // toxcore/ping
240 CHECK_SIZE(Ping, 2072);
241 // toxcore/TCP_client
242 CHECK_SIZE(TCP_Client_Connection, 12064);
243 CHECK_SIZE(TCP_Proxy_Info, 40);
244 // toxcore/TCP_connection
245 CHECK_SIZE(TCP_con, 112);
246 CHECK_SIZE(TCP_Connections, 200);
247 CHECK_SIZE(TCP_Connection_to, 112);
248 // toxcore/TCP_server
249 CHECK_SIZE(TCP_Priority_List, 16);
250 CHECK_SIZE(TCP_Secure_Connection, 11816);
251#ifdef TCP_SERVER_USE_EPOLL
252 CHECK_SIZE(TCP_Server, 6049968); // 6MB!
253#else
254 CHECK_SIZE(TCP_Server, 6049952); // 6MB!
255#endif
256 // toxcore/tox
257 CHECK_SIZE(Tox_Options, 64);
258#endif
259 return 0;
260}
diff --git a/auto_tests/monolith_test.cpp b/auto_tests/monolith_test.cpp
deleted file mode 100644
index 44a5b16b..00000000
--- a/auto_tests/monolith_test.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
1/* Nop-test, just to make sure our code compiles as C++.
2 */
3
4#ifdef __FreeBSD__
5// Include this here, because _XOPEN_SOURCE hides symbols we need.
6//
7// https://lists.freebsd.org/pipermail/freebsd-standards/2004-March/000474.html.
8#include <net/if.h>
9#endif
10
11#ifdef __APPLE__
12#define _DARWIN_C_SOURCE
13#endif
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include "../other/monolith.h"
20#define DHT_C_INCLUDED
21
22#include "check_compat.h"
23#include "helpers.h"
24#include "../testing/misc_tools.c"
25
26#include <ctype.h>
27
28namespace TCP_test
29{
30int main(void);
31#include "TCP_test.c"
32}
33namespace bootstrap_test
34{
35int main(void);
36#include "bootstrap_test.c"
37}
38namespace conference_test
39{
40int main(void);
41#include "conference_test.c"
42}
43namespace crypto_test
44{
45int main(void);
46#include "crypto_test.c"
47}
48namespace dht_test
49{
50int main(void);
51#include "dht_test.c"
52}
53namespace encryptsave_test
54{
55int main(void);
56#include "encryptsave_test.c"
57}
58namespace file_saving_test
59{
60int main(void);
61#include "file_saving_test.c"
62}
63namespace friend_request_test
64{
65int main(void);
66#include "friend_request_test.c"
67}
68namespace lan_discovery_test
69{
70int main(void);
71#include "lan_discovery_test.c"
72}
73namespace lossless_packet_test
74{
75int main(void);
76#include "lossless_packet_test.c"
77}
78namespace lossy_packet_test
79{
80int main(void);
81#include "lossy_packet_test.c"
82}
83namespace messenger_test
84{
85int main(void);
86#include "messenger_test.c"
87}
88namespace network_test
89{
90int main(void);
91#include "network_test.c"
92}
93namespace onion_test
94{
95int main(void);
96#include "onion_test.c"
97}
98namespace save_friend_test
99{
100int main(void);
101#include "save_friend_test.c"
102}
103namespace save_load_test
104{
105int main(void);
106#include "save_load_test.c"
107}
108namespace selfname_change_conference_test
109{
110int main(void);
111#include "selfname_change_conference_test.c"
112}
113namespace self_conference_title_change_test
114{
115int main(void);
116#include "self_conference_title_change_test.c"
117}
118namespace send_message_test
119{
120int main(void);
121#include "send_message_test.c"
122}
123namespace set_name_test
124{
125int main(void);
126#include "set_name_test.c"
127}
128namespace set_status_message_test
129{
130int main(void);
131#include "set_status_message_test.c"
132}
133namespace simple_conference_test
134{
135int main(void);
136#include "simple_conference_test.c"
137}
138namespace skeleton_test
139{
140int main(void);
141#include "skeleton_test.c"
142}
143namespace toxav_basic_test
144{
145int main(void);
146#include "toxav_basic_test.c"
147}
148namespace toxav_many_test
149{
150int main(void);
151#include "toxav_many_test.c"
152}
153namespace tox_many_tcp_test
154{
155int main(void);
156#include "tox_many_tcp_test.c"
157}
158namespace tox_many_test
159{
160int main(void);
161#include "tox_many_test.c"
162}
163namespace tox_one_test
164{
165int main(void);
166#include "tox_one_test.c"
167}
168namespace tox_strncasecmp_test
169{
170int main(void);
171#include "tox_strncasecmp_test.c"
172}
173namespace typing_test
174{
175int main(void);
176#include "typing_test.c"
177}
178namespace version_test
179{
180int main(void);
181#include "version_test.c"
182}
183
184#define PRINT_SIZE 0
185
186template<typename T, size_t Expected, size_t Actual = sizeof(T)>
187void check_size(char const *type)
188{
189#if PRINT_SIZE
190 printf("CHECK_SIZE(%s, %zu);\n", type, Actual);
191#else
192 static_assert(Actual == Expected, "Bad sizeof - see template expansion errors for details");
193#endif
194}
195
196#define CHECK_SIZE(TYPE, SIZE) check_size<TYPE, SIZE>(#TYPE)
197
198/**
199 * The main function static-asserts that we are aware of all the sizes of all
200 * the structs it toxcore. If you find this failing after you make a change,
201 * switch on the PRINT_SIZE above and copy the number into this function.
202 */
203int main(int argc, char *argv[])
204{
205#if defined(__x86_64__) && defined(__LP64__)
206 // toxcore/DHT
207 CHECK_SIZE(Client_data, 496);
208 CHECK_SIZE(Cryptopacket_Handles, 16);
209 CHECK_SIZE(DHT, 676528);
210 CHECK_SIZE(DHT_Friend, 5104);
211 CHECK_SIZE(Hardening, 144);
212 CHECK_SIZE(IPPTs, 40);
213 CHECK_SIZE(IPPTsPng, 232);
214 CHECK_SIZE(NAT, 48);
215 CHECK_SIZE(Node_format, 64);
216 CHECK_SIZE(Shared_Key, 80);
217 CHECK_SIZE(Shared_Keys, 81920);
218 // toxcore/friend_connection
219 CHECK_SIZE(Friend_Conn, 1784);
220 CHECK_SIZE(Friend_Connections, 72);
221 // toxcore/friend_requests
222 CHECK_SIZE(Friend_Requests, 1080);
223 // toxcore/group
224 CHECK_SIZE(Group_c, 728);
225 CHECK_SIZE(Group_Chats, 2120);
226 CHECK_SIZE(Group_Peer, 480);
227 // toxcore/list
228 CHECK_SIZE(BS_LIST, 32);
229 // toxcore/logger
230 CHECK_SIZE(Logger, 24);
231 // toxcore/Messenger
232 CHECK_SIZE(File_Transfers, 72);
233 CHECK_SIZE(Friend, 39264);
234 CHECK_SIZE(Messenger, 2008);
235 CHECK_SIZE(Messenger_Options, 72);
236 CHECK_SIZE(Receipts, 16);
237 // toxcore/net_crypto
238#ifdef __linux__
239 CHECK_SIZE(Crypto_Connection, 525392);
240 CHECK_SIZE(Net_Crypto, 272);
241#endif
242 CHECK_SIZE(New_Connection, 168);
243 CHECK_SIZE(Packet_Data, 1384);
244 CHECK_SIZE(Packets_Array, 262152);
245 // toxcore/network
246 CHECK_SIZE(IP, 24);
247 CHECK_SIZE(IP4, 4);
248#if USE_IPV6
249 CHECK_SIZE(IP6, 16);
250#endif
251 CHECK_SIZE(IP_Port, 32);
252 CHECK_SIZE(Networking_Core, 4112);
253 CHECK_SIZE(Packet_Handler, 16);
254 // toxcore/onion_announce
255 CHECK_SIZE(Cmp_data, 296);
256 CHECK_SIZE(Onion_Announce, 128048);
257 CHECK_SIZE(Onion_Announce_Entry, 288);
258 // toxcore/onion_client
259 CHECK_SIZE(Last_Pinged, 40);
260 CHECK_SIZE(Onion_Client, 15816);
261 CHECK_SIZE(Onion_Client_Cmp_data, 176);
262 CHECK_SIZE(Onion_Client_Paths, 2520);
263 CHECK_SIZE(Onion_Friend, 1936);
264 CHECK_SIZE(Onion_Friend, 1936);
265 CHECK_SIZE(Onion_Node, 168);
266 // toxcore/onion
267 CHECK_SIZE(Onion, 245832);
268 CHECK_SIZE(Onion_Path, 392);
269 // toxcore/ping_array
270 CHECK_SIZE(Ping_Array, 24);
271 CHECK_SIZE(Ping_Array_Entry, 32);
272 // toxcore/ping
273 CHECK_SIZE(Ping, 2072);
274 // toxcore/TCP_client
275 CHECK_SIZE(TCP_Client_Connection, 12064);
276 CHECK_SIZE(TCP_Proxy_Info, 40);
277 // toxcore/TCP_connection
278 CHECK_SIZE(TCP_con, 112);
279 CHECK_SIZE(TCP_Connections, 200);
280 CHECK_SIZE(TCP_Connection_to, 112);
281 // toxcore/TCP_server
282 CHECK_SIZE(TCP_Priority_List, 16);
283 CHECK_SIZE(TCP_Secure_Connection, 11816);
284#ifdef TCP_SERVER_USE_EPOLL
285 CHECK_SIZE(TCP_Server, 6049968); // 6MB!
286#else
287 CHECK_SIZE(TCP_Server, 6049952); // 6MB!
288#endif
289 // toxcore/tox
290 CHECK_SIZE(Tox_Options, 64);
291#endif
292 return 0;
293}