forked from paullouisageneau/libjuice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
146 lines (126 loc) · 3.69 KB
/
main.c
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
/**
* Copyright (c) 2020 Paul-Louis Ageneau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include "juice/juice.h"
#include <stdio.h>
int test_crc32(void);
int test_base64(void);
int test_stun(void);
int test_connectivity(void);
int test_thread(void);
int test_mux(void);
int test_notrickle(void);
int test_gathering(void);
int test_turn(void);
int test_conflict(void);
int test_bind(void);
int test_ufrag(void);
int test_stun_unhandled(void);
int test_stun_unhandled_multiple(void);
int test_stun_unhandled_no_host(void);
int test_stun_unhandled_unhandle(void);
#ifndef NO_SERVER
int test_server(void);
#endif
int main(int argc, char **argv) {
juice_set_log_level(JUICE_LOG_LEVEL_WARN);
printf("\nRunning CRC32 implementation test...\n");
if (test_crc32()) {
fprintf(stderr, "CRC32 implementation test failed\n");
return -2;
}
printf("\nRunning base64 implementation test...\n");
if (test_base64()) {
fprintf(stderr, "base64 implementation test failed\n");
return -2;
}
printf("\nRunning STUN parsing implementation test...\n");
if (test_stun()) {
fprintf(stderr, "STUN parsing implementation test failed\n");
return -3;
}
printf("\nRunning candidates gathering test...\n");
if (test_gathering()) {
fprintf(stderr, "Candidates gathering test failed\n");
return -1;
}
printf("\nRunning connectivity test...\n");
if (test_connectivity()) {
fprintf(stderr, "Connectivity test failed\n");
return -1;
}
// Disabled as the Open Relay TURN server is unreliable
/*
printf("\nRunning TURN connectivity test...\n");
if (test_turn()) {
fprintf(stderr, "TURN connectivity test failed\n");
return -1;
}
*/
printf("\nRunning thread-mode connectivity test...\n");
if (test_thread()) {
fprintf(stderr, "Thread-mode connectivity test failed\n");
return -1;
}
printf("\nRunning mux-mode connectivity test...\n");
if (test_mux()) {
fprintf(stderr, "Mux-mode connectivity test failed\n");
return -1;
}
printf("\nRunning non-trickled connectivity test...\n");
if (test_notrickle()) {
fprintf(stderr, "Non-trickled connectivity test failed\n");
return -1;
}
printf("\nRunning connectivity test with role conflict...\n");
if (test_conflict()) {
fprintf(stderr, "Connectivity test with role conflict failed\n");
return -1;
}
printf("\nRunning connectivity test with bind address...\n");
if (test_bind()) {
fprintf(stderr, "Connectivity test with bind address failed\n");
return -1;
}
printf("\nRunning ufrag test...\n");
if (test_ufrag()) {
fprintf(stderr, "Ufrag test failed\n");
return -1;
}
#ifndef _WIN32
// windows fails to read STUN message from listen socket:
// udp.c:196: Ignoring ECONNRESET returned by recvfrom
printf("\nRunning unhandled STUN message test...\n");
if (test_stun_unhandled()) {
fprintf(stderr, "Unhandled STUN message test failed\n");
return -1;
}
printf("\nRunning mutiple handler unhandled STUN message test...\n");
if (test_stun_unhandled_multiple()) {
fprintf(stderr, "Mutiple handler unhandled STUN message test failed\n");
return -1;
}
printf("\nRunning unhandled, unhandled STUN message test...\n");
if (test_stun_unhandled_unhandle()) {
fprintf(stderr, "Unhandled, unhandled STUN message test failed\n");
return -1;
}
printf("\nRunning no host unhandled STUN message test...\n");
if (test_stun_unhandled_no_host()) {
fprintf(stderr, "Mutiple no host unhandled STUN message test failed\n");
return -1;
}
#endif
#ifndef NO_SERVER
printf("\nRunning server test...\n");
if (test_server()) {
fprintf(stderr, "Server test failed\n");
return -1;
}
#endif
return 0;
}