-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.cpp
209 lines (179 loc) · 7.92 KB
/
main.cpp
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Copyright Edgeware AB 2020, Agile Content 2021-2022
#include "unitTests/UnitTest1.h"
#include "unitTests/UnitTest2.h"
#include "unitTests/UnitTest3.h"
#include "unitTests/UnitTest4.h"
#include "unitTests/UnitTest5.h"
#include "unitTests/UnitTest6.h"
#include "unitTests/UnitTest7.h"
#include "unitTests/UnitTest8.h"
#include "unitTests/UnitTest9.h"
#include "unitTests/UnitTest10.h"
#include "unitTests/UnitTest11.h"
#include "unitTests/UnitTest12.h"
#include "unitTests/UnitTest13.h"
#include "unitTests/UnitTest14.h"
#include "unitTests/UnitTest15.h"
#include "unitTests/UnitTest16.h"
#include "unitTests/UnitTest17.h"
#include "unitTests/UnitTest18.h"
#include "unitTests/UnitTest19.h"
#include "unitTests/UnitTest20.h"
#include "unitTests/UnitTest21.h"
#include "unitTests/UnitTest22.h"
#include "unitTests/PerformanceLab.h"
#include <iostream>
int main() {
//PerformanceLab sends/receives a endless stream of packets (Used when profiling the code)
//PerformanceLab myPerformanceLab;
//myPerformanceLab.startUnitTest();
//code will never get to here
int returnCode = EXIT_SUCCESS;
//Test sending a packet less than MTU + header - > Expected result is one type2 frame only sent
UnitTest1 unitTest1;
if (!unitTest1.startUnitTest()) {
std::cout << "Unit test 1 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending a packet less than MTU + header - > Expected result is one type2 frame only sent and only one recieved
UnitTest2 unitTest2;
if (!unitTest2.startUnitTest()) {
std::cout << "Unit test 2 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending 1 byte packet of value 0xaa and recieving it in the other end
UnitTest3 unitTest3;
if (!unitTest3.startUnitTest()) {
std::cout << "Unit test 3 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending a packet of MTU-headertyp1+1 > result should be one frame type1 and a frame type 2, MTU+1 at the receiver
UnitTest4 unitTest4;
if (!unitTest4.startUnitTest()) {
std::cout << "Unit test 4 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending a packet of MTU*5+MTU/2 containing a linear vector -> the result should be a packet with that size containing a linear vector.
UnitTest5 unitTest5;
if (!unitTest5.startUnitTest()) {
std::cout << "Unit test 5 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending a packet of MTU*5+MTU/2 containing a linear vector drop the first packet -> the result should be a packet with a hole of MTU-headertype1
//then a linear vector of data starting with the number (MTU-headertyp1) % 256. also check for broken flag is set.
UnitTest6 unitTest6;
if (!unitTest6.startUnitTest()) {
std::cout << "Unit test 6 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending packets, 5 type 1 + 1 type 2.. Reorder type1 packet 3 and 2 so the delivery order is 1 3 2 4 5 6
//then check for correct length and correct vector in the payload
UnitTest7 unitTest7;
if (!unitTest7.startUnitTest()) {
std::cout << "Unit test 7 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending packets, 5 type 1 + 1 type 2.. Send the type2 packet first to the unpacker and send the type1 packets out of order
UnitTest8 unitTest8;
if (!unitTest8.startUnitTest()) {
std::cout << "Unit test 8 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending packets, 5 type 1 + 1 type 2.. Drop the type 2 packet.
//broken should be set, the PTS and code should be set to the illegal value and the vector should be linear for 5 times MTU - myEFPPacker.geType1Size()
UnitTest9 unitTest9;
if (!unitTest9.startUnitTest()) {
std::cout << "Unit test 9 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//send two type 2 packets out of order and recieve them in order.
UnitTest10 unitTest10;
if (!unitTest10.startUnitTest()) {
std::cout << "Unit test 10 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending 5 packets, 5 type 1 + 1 type 2..
//Reverse the packets to the unpacker and drop the middle packet (packet 3)
//This is testing the out of order head of line blocking mechanism
//The result should be deliver packet 1,2,4,5 even though we gave the unpacker them in order 5,4,2,1.
UnitTest11 unitTest11;
if (!unitTest11.startUnitTest()) {
std::cout << "Unit test 11 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending 5 packets, 5 type 1 + 1 type 2..
//Reverse the packets to the unpacker and drop the middle packet (packet 3) also deliver the fragments reversed meaning packet 5 last fragment first..
//This is testing the out of order head of line blocking mechanism
//The result should be deliver packer 1,2,4,5 even though we gave the unpacker them in order 5,4,2,1.
UnitTest12 unitTest12;
if (!unitTest12.startUnitTest()) {
std::cout << "Unit test 12 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test sending 100 000 superframes
//Check PTS and DTS values sent are also received
UnitTest13 unitTest13;
if (!unitTest13.startUnitTest()) {
std::cout << "Unit test 13 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Send 15 packets with embeddedPrivateData. odd packet numbers will have two embedded private data fields. Also check for not broken and correct fourcc code.
//the reminder of the packet is a vector. Check it's integrity
UnitTest14 unitTest14;
if (!unitTest14.startUnitTest()) {
std::cout << "Unit test 14 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//This is the crazy-monkey test1. We randomize the size for 1000 packets. We store the size in a private struct and embedd it.
//when we receive the packet we check the size saved in the embedded data and also the linear vector in the payload.
//This test triggers the type3 fragment
UnitTest15 unitTest15;
if (!unitTest15.startUnitTest()) {
std::cout << "Unit test 15 failed" << std::endl;
returnCode = EXIT_FAILURE;
//UnitTest16 unitTest16; //WIP
//if (!unitTest16.startUnitTest()) {
// std::cout << "Unit test 16 failed" << std::endl;
// returnCode=EXIT_FAILURE;
//}
}
//Send 100 frames... Stop the sender. Delete the sender. delete the receiver
//start a new sender and force the superframe counter to != 0 start the receiver
UnitTest17 unitTest17;
if (!unitTest17.startUnitTest()) {
std::cout << "Unit test 17 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Using the optional lambda in the pack and send method
UnitTest18 unitTest18;
if (!unitTest18.startUnitTest()) {
std::cout << "Unit test 18 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Testing the optional context that can be used in the callbacks
UnitTest19 unitTest19;
if (!unitTest19.startUnitTest()) {
std::cout << "Unit test 19 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Test basic run to completion
//Test sending a packet of MTU-headertyp1+1 > result should be one frame type1 and a frame type 2, MTU+1 at the receiver
UnitTest20 unitTest20;
if (!unitTest20.startUnitTest()) {
std::cout << "Unit test 20 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Zero copy (destroys original data)
UnitTest21 unitTest21;
if (!unitTest21.startUnitTest()) {
std::cout << "Unit test 21 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
//Send fragments unordered and lost testing HOL and broken flags
UnitTest22 unitTest22;
if (!unitTest22.startUnitTest()) {
std::cout << "Unit test 22 failed" << std::endl;
returnCode = EXIT_FAILURE;
}
return returnCode;
}