29
29
30
30
using namespace utest ::v1;
31
31
32
+ #ifndef MBED_CONF_APP_HTTP_SERVER_NAME
33
+ #define MBED_CONF_APP_HTTP_SERVER_NAME " os.mbed.com"
34
+ #define MBED_CONF_APP_HTTP_SERVER_FILE_PATH " /media/uploads/mbed_official/hello.txt"
35
+ #endif
32
36
33
37
namespace {
34
38
// Test connection information
35
- const char *HTTP_SERVER_NAME = " os.mbed.com" ;
36
- const char *HTTP_SERVER_FILE_PATH = " /media/uploads/mbed_official/hello.txt" ;
37
39
const int HTTP_SERVER_PORT = 80 ;
38
40
#if defined(TARGET_VK_RZ_A1H)
39
41
const int RECV_BUFFER_SIZE = 300 ;
@@ -97,12 +99,14 @@ void prep_buffer() {
97
99
// We are constructing GET command like this:
98
100
// GET http://developer.mbed.org/media/uploads/mbed_official/hello.txt HTTP/1.0\n\n
99
101
strcpy (buffer, " GET http://" );
100
- strcat (buffer, HTTP_SERVER_NAME );
101
- strcat (buffer, HTTP_SERVER_FILE_PATH );
102
+ strcat (buffer, MBED_CONF_APP_HTTP_SERVER_NAME );
103
+ strcat (buffer, MBED_CONF_APP_HTTP_SERVER_FILE_PATH );
102
104
strcat (buffer, " HTTP/1.0\n\n " );
103
105
}
104
106
105
107
void test_socket_attach () {
108
+ bool result = false ;
109
+
106
110
// Dispatch event queue
107
111
Thread eventThread;
108
112
EventQueue queue (4 *EVENTS_EVENT_SIZE);
@@ -111,8 +115,8 @@ void test_socket_attach() {
111
115
printf (" TCP client IP Address is %s\r\n " , net->get_ip_address ());
112
116
113
117
TCPSocket sock (net);
114
- printf (" HTTP: Connection to %s:%d\r\n " , HTTP_SERVER_NAME , HTTP_SERVER_PORT);
115
- if (sock.connect (HTTP_SERVER_NAME , HTTP_SERVER_PORT) == 0 ) {
118
+ printf (" HTTP: Connection to %s:%d\r\n " , MBED_CONF_APP_HTTP_SERVER_NAME , HTTP_SERVER_PORT);
119
+ if (sock.connect (MBED_CONF_APP_HTTP_SERVER_NAME , HTTP_SERVER_PORT) == 0 ) {
116
120
printf (" HTTP: OK\r\n " );
117
121
118
122
prep_buffer ();
@@ -122,10 +126,13 @@ void test_socket_attach() {
122
126
sock.send (buffer, strlen (buffer));
123
127
// wait for recv data
124
128
recvd.wait ();
129
+
130
+ result = true ;
125
131
} else {
126
132
printf (" HTTP: ERROR\r\n " );
127
133
}
128
134
sock.close ();
135
+ TEST_ASSERT_EQUAL (true , result);
129
136
}
130
137
131
138
void cb_fail () {
@@ -145,8 +152,8 @@ void test_socket_detach() {
145
152
printf (" TCP client IP Address is %s\r\n " , net->get_ip_address ());
146
153
147
154
TCPSocket sock (net);
148
- printf (" HTTP: Connection to %s:%d\r\n " , HTTP_SERVER_NAME , HTTP_SERVER_PORT);
149
- if (sock.connect (HTTP_SERVER_NAME , HTTP_SERVER_PORT) == 0 ) {
155
+ printf (" HTTP: Connection to %s:%d\r\n " , MBED_CONF_APP_HTTP_SERVER_NAME , HTTP_SERVER_PORT);
156
+ if (sock.connect (MBED_CONF_APP_HTTP_SERVER_NAME , HTTP_SERVER_PORT) == 0 ) {
150
157
printf (" HTTP: OK\r\n " );
151
158
152
159
prep_buffer ();
@@ -172,8 +179,8 @@ void test_socket_reattach() {
172
179
printf (" TCP client IP Address is %s\r\n " , net->get_ip_address ());
173
180
174
181
TCPSocket sock (net);
175
- printf (" HTTP: Connection to %s:%d\r\n " , HTTP_SERVER_NAME , HTTP_SERVER_PORT);
176
- if (sock.connect (HTTP_SERVER_NAME , HTTP_SERVER_PORT) == 0 ) {
182
+ printf (" HTTP: Connection to %s:%d\r\n " , MBED_CONF_APP_HTTP_SERVER_NAME , HTTP_SERVER_PORT);
183
+ if (sock.connect (MBED_CONF_APP_HTTP_SERVER_NAME , HTTP_SERVER_PORT) == 0 ) {
177
184
printf (" HTTP: OK\r\n " );
178
185
179
186
prep_buffer ();
0 commit comments