2727#include " unity/unity.h"
2828#include " greentea-client/test_env.h"
2929#include < string>
30+ #include " common_defines_test.h"
3031
3132#define MAX_THREADS 5
3233
@@ -93,7 +94,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
9394 break ;
9495 }
9596 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);
9798 }
9899 TEST_ASSERT_EQUAL_INT_MESSAGE (0 , result, " failed to connect" );
99100
@@ -111,7 +112,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
111112 } else {
112113 TEST_ASSERT_MESSAGE (0 , " wrong thread id" );
113114 }
114- printf (" [NET-%d] Registered socket callback function\r\n " , thread_id);
115+ tr_info (" [NET-%d] Registered socket callback function" , thread_id);
115116 event_fired[thread_id] = false ;
116117
117118 /* setup request */
@@ -120,7 +121,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
120121 /* construct request */
121122 size_t req_len = snprintf (request, REQ_BUF_SIZE - 1 , req_template, dl_path, dl_host);
122123 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);
124125
125126 /* send request to server */
126127 result = tcpsocket.send (request, req_len);
@@ -130,7 +131,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
130131 char *receive_buffer = &g_receive_buffer[thread_id * RECV_BUF_SIZE];
131132
132133 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);
134135
135136 size_t received_bytes = 0 ;
136137 int body_index = -1 ;
@@ -166,7 +167,7 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
166167 if (body_index < 0 ) {
167168 continue ;
168169 } 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);
170171
171172 /* remove header before comparison */
172173 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
186187 speed = float (received_bytes) / timer.read ();
187188 percent = float (received_bytes) * 100 / float (data_length);
188189 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 );
192193 }
193194 } while ((result > 0 ) && (received_bytes < data_length));
194195 }
@@ -197,10 +198,10 @@ size_t download_test(NetworkInterface *interface, const unsigned char *data, siz
197198
198199 timer.stop ();
199200 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 ());
204205
205206 return received_bytes;
206207}
0 commit comments