-
Notifications
You must be signed in to change notification settings - Fork 3k
FEATURE_IPV4/TESTS: result status could be wrong #2744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,15 +35,16 @@ bool find_substring(const char *first, const char *last, const char *s_first, co | |
int main() { | ||
GREENTEA_SETUP(20, "default_auto"); | ||
|
||
bool result = true; | ||
bool result = false; | ||
EthernetInterface eth; | ||
//eth.init(); //Use DHCP | ||
eth.connect(); | ||
printf("TCP client IP Address is %s\r\n", eth.get_ip_address()); | ||
|
||
TCPSocket sock(ð); | ||
printf("HTTP: Connection to %s:%d\r\n", HTTP_SERVER_NAME, HTTP_SERVER_PORT); | ||
if (sock.connect(HTTP_SERVER_NAME, HTTP_SERVER_PORT) == 0) { | ||
printf("HTTP: Connected to %s:%d\r\n", HTTP_SERVER_NAME, HTTP_SERVER_PORT); | ||
printf("HTTP: OK\r\n"); | ||
|
||
// We are constructing GET command like this: | ||
// GET http://developer.mbed.org/media/uploads/mbed_official/hello.txt HTTP/1.0\n\n | ||
|
@@ -66,17 +67,21 @@ int main() { | |
TEST_ASSERT_TRUE(found_200_ok); | ||
TEST_ASSERT_TRUE(found_hello); | ||
|
||
result = true; | ||
if (!found_200_ok) result = false; | ||
if (!found_hello) result = false; | ||
|
||
printf("HTTP: Received %d chars from server\r\n", ret); | ||
printf("HTTP: Received 200 OK status ... %s\r\n", found_200_ok ? "[OK]" : "[FAIL]"); | ||
printf("HTTP: Received '%s' status ... %s\r\n", HTTP_HELLO_STR, found_hello ? "[OK]" : "[FAIL]"); | ||
printf("HTTP: Received massage:\r\n\r\n"); | ||
printf("HTTP: Received message:\r\n"); | ||
printf("%s", buffer); | ||
sock.close(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could fix the indent here? |
||
} | ||
else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Last little nit pick: could you put the above two lines on the same line? According to our committer guide, we follow the K&R style: https://github.com/ARMmbed/mbed-os/blob/master/docs/COMMITTERS.md#rules So:
becomes:
|
||
printf("HTTP: ERROR\r\n"); | ||
} | ||
|
||
sock.close(); | ||
eth.disconnect(); | ||
GREENTEA_TESTSUITE_RESULT(result); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ int main() { | |
|
||
greentea_send_kv("target_ip", eth.get_ip_address()); | ||
|
||
bool result = true; | ||
bool result = false; | ||
|
||
char recv_key[] = "host_port"; | ||
char ipbuf[60] = {0}; | ||
|
@@ -66,6 +66,8 @@ int main() { | |
result = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're assuming false by default, can we remove this line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jeromecoutant Oops, not sure how I missed that, thanks for pointing that out. You're right, this line should stay in then. |
||
break; | ||
} | ||
|
||
result = true; | ||
} | ||
|
||
sock.close(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change the above three lines to: