27
27
#include " unity/unity.h"
28
28
#include " greentea-client/test_env.h"
29
29
#include < string>
30
+ #include " common_defines_test.h"
30
31
31
32
#define MAX_THREADS 5
32
33
@@ -93,7 +94,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
93
94
break ;
94
95
}
95
96
ThisThread::sleep_for (1000 );
96
- printf (" [NET-%d] Connection failed. Retry %d of %d\r\n " , thread_id, tries, MAX_RETRIES);
97
+ tr_info (" [NET-%d] Connection failed. Retry %d of %d" , thread_id, tries, MAX_RETRIES);
97
98
}
98
99
TEST_ASSERT_EQUAL_INT_MESSAGE (0 , result, " failed to connect" );
99
100
@@ -111,7 +112,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
111
112
} else {
112
113
TEST_ASSERT_MESSAGE (0 , " wrong thread id" );
113
114
}
114
- printf (" [NET-%d] Registered socket callback function\r\n " , thread_id);
115
+ tr_info (" [NET-%d] Registered socket callback function" , thread_id);
115
116
event_fired[thread_id] = false ;
116
117
117
118
/* setup request */
@@ -120,7 +121,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
120
121
/* construct request */
121
122
size_t req_len = snprintf (request, REQ_BUF_SIZE - 1 , req_template, dl_path, dl_host);
122
123
request[req_len] = 0 ;
123
- printf (" [NET-%d] Request header (%u): %s\r\n " , thread_id, req_len, request);
124
+ tr_info (" [NET-%d] Request header (%u): %s" , thread_id, req_len, request);
124
125
125
126
/* send request to server */
126
127
result = tcpsocket.send (request, req_len);
@@ -130,7 +131,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
130
131
char *receive_buffer = &g_receive_buffer[thread_id * RECV_BUF_SIZE];
131
132
132
133
tcpsocket.set_blocking (false );
133
- printf (" [NET-%d] Non-blocking socket mode set\r\n " , thread_id);
134
+ tr_info (" [NET-%d] Non-blocking socket mode set" , thread_id);
134
135
135
136
size_t received_bytes = 0 ;
136
137
int body_index = -1 ;
@@ -166,7 +167,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
166
167
if (body_index < 0 ) {
167
168
continue ;
168
169
} else {
169
- printf (" [NET-%d] Found body index: %d\r\n " , thread_id, body_index);
170
+ tr_info (" [NET-%d] Found body index: %d" , thread_id, body_index);
170
171
171
172
/* remove header before comparison */
172
173
memmove (receive_buffer, &receive_buffer[body_index + 4 ], result - body_index - 4 );
@@ -186,9 +187,9 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
186
187
speed = float (received_bytes) / timer.read ();
187
188
percent = float (received_bytes) * 100 / float (data_length);
188
189
time_left = (data_length - received_bytes) / speed;
189
- printf (" [NET-%d] Received bytes: %u, (%.2f%%, %.2fKB/s, ETA: %02d:%02d:%02d)\r\n " ,
190
- thread_id, received_bytes, percent, speed / 1024 ,
191
- time_left / 3600 , (time_left / 60 ) % 60 , time_left % 60 );
190
+ tr_info (" [NET-%d] Received bytes: %u, (%.2f%%, %.2fKB/s, ETA: %02d:%02d:%02d)" ,
191
+ thread_id, received_bytes, percent, speed / 1024 ,
192
+ time_left / 3600 , (time_left / 60 ) % 60 , time_left % 60 );
192
193
}
193
194
} while ((result > 0 ) && (received_bytes < data_length));
194
195
}
@@ -197,10 +198,10 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
197
198
198
199
timer.stop ();
199
200
float f_received_bytes = float (received_bytes);
200
- printf (" [NET-%d] Downloaded: %.2fKB (%.2fKB/s, %.2f secs)\r\n " , thread_id,
201
- f_received_bytes / 1024 .,
202
- f_received_bytes / (timer.read () * 1024 .),
203
- timer.read ());
201
+ tr_info (" [NET-%d] Downloaded: %.2fKB (%.2fKB/s, %.2f secs)" , thread_id,
202
+ f_received_bytes / 1024 .,
203
+ f_received_bytes / (timer.read () * 1024 .),
204
+ timer.read ());
204
205
205
206
return received_bytes;
206
207
}
0 commit comments