+24
-5
lines changedFilter options
+24
-5
lines changed Original file line number Diff line number Diff line change
@@ -45,17 +45,35 @@ TEST(Transmission, FileUpload)
45
45
sa_lsn.sin_addr.s_addr = INADDR_ANY;
46
46
sa_lsn.sin_port = htons(5555);
47
47
48
+
// Find unused a port not used by any other service.
49
+
// Otherwise srt_connect may actually connect.
50
+
int bind_res = -1;
51
+
for (int port = 5000; port <= 5555; ++port)
52
+
{
53
+
sa_lsn.sin_port = htons(port);
54
+
bind_res = srt_bind(sock_lsn, (sockaddr*)&sa_lsn, sizeof sa_lsn);
55
+
if (bind_res == 0)
56
+
{
57
+
std::cout << "Running test on port " << port << "\n";
58
+
break;
59
+
}
60
+
61
+
ASSERT_TRUE(bind_res == SRT_EINVOP) << "Bind failed not due to an occupied port. Result " << bind_res;
62
+
}
63
+
64
+
ASSERT_GE(bind_res, 0);
65
+
48
66
srt_bind(sock_lsn, (sockaddr*)&sa_lsn, sizeof sa_lsn);
49
67
50
68
int optval = 0;
51
69
int optlen = sizeof optval;
52
70
ASSERT_EQ(srt_getsockflag(sock_lsn, SRTO_SNDBUF, &optval, &optlen), 0);
53
-
size_t filesize = 7 * optval;
71
+
const size_t filesize = 7 * optval;
54
72
55
73
{
56
74
std::cout << "WILL CREATE source file with size=" << filesize << " (= 7 * " << optval << "[sndbuf])\n";
57
75
std::ofstream outfile("file.source", std::ios::out | std::ios::binary);
58
-
ASSERT_EQ(!!outfile, true);
76
+
ASSERT_EQ(!!outfile, true) << srt_getlasterror_str();
59
77
60
78
srand(time(0));
61
79
@@ -96,6 +114,7 @@ TEST(Transmission, FileUpload)
96
114
ASSERT_NE(n, SRT_ERROR);
97
115
if (n == 0)
98
116
{
117
+
std::cerr << "Received 0 bytes, breaking.\n";
99
118
break;
100
119
}
101
120
@@ -110,7 +129,7 @@ TEST(Transmission, FileUpload)
110
129
111
130
sockaddr_in sa = sockaddr_in();
112
131
sa.sin_family = AF_INET;
113
-
sa.sin_port = htons(5555);
132
+
sa.sin_port = sa_lsn.sin_port;
114
133
ASSERT_EQ(inet_pton(AF_INET, "127.0.0.1", &sa.sin_addr), 1);
115
134
116
135
srt_connect(sock_clr, (sockaddr*)&sa, sizeof(sa));
@@ -126,8 +145,8 @@ TEST(Transmission, FileUpload)
126
145
size_t shift = 0;
127
146
while (n > 0)
128
147
{
129
-
int st = srt_send(sock_clr, buf.data()+shift, n);
130
-
ASSERT_GT(st, 0);
148
+
const int st = srt_send(sock_clr, buf.data()+shift, n);
149
+
ASSERT_GT(st, 0) << srt_getlasterror_str();
131
150
132
151
n -= st;
133
152
shift += st;
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4