summaryrefslogtreecommitdiff
path: root/auto_tests/monolith_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'auto_tests/monolith_test.cc')
-rw-r--r--auto_tests/monolith_test.cc260
1 files changed, 260 insertions, 0 deletions
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}