-
Notifications
You must be signed in to change notification settings - Fork 3k
Networking test fixes #4240
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
Networking test fixes #4240
Conversation
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputBuild failed! |
3893d9e
to
11f4ee0
Compare
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
/morph test-nightly |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
@geky I think we need to take a look at the |
/morph test-nightly |
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.
Good update 👍
8e31a49
to
457b1c1
Compare
} | ||
|
||
i++; |
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.
You should keep this i
here. It is keeping track of the total number of loops, not the number of successes.
The dtls test already has the ability to retry upon a UDP failure. However the sockets are currently configured to be blocking and to wait forever. I added a timeout of 1.5 seconds in order the test to correctly timeout.
This adds some extra logs to the test for debugging purposes. Also allows the test to fail immediately if it fails to obtain an IP address.
The Greentea UUID can be used as a source of entropy/randomness during the test. This is useful for uniquely identifying a test run.
Before, the UDP test was very strict on the number of packets it would try to match before failing. Now it will keep trying for the whole test to get enough passing packets. It also includes the test's UUID so you can validate which packets are being received.
Making the test more forgiven for minor networking issues. Also adding more debug prints to make it easier to see which packets are coming from where.
…et device as Locally Administrated and Unicast
This matches the timeout used in linux: https://linux.die.net/man/5/dhclient.conf This resolves several issues noticed during testing when we have a very large number of devices that try to get an IP address around the same time.
Avoids getting stuck in loop where the device always picks up the previous test's packets
Avoids accidentally using a part of the uuid that isn't very unique. ie, the mac address component of type 1 uuids.
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.
Looks ok , when you rebase can you also do it on top of master? I think a (you are too quick for me!)targets.json
has crept in here for some reason.
} | ||
|
||
Case cases[] = { | ||
Case("Testing TCP echo", test_tcp_echo), |
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.
Nit: seems a bit redundant to put "Testing" in the title of a test case.
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.
Haha, a quick grep shows it's traditional :P
TESTS/mbedmicro-rtos-mbed/threads/main.cpp: Case("Testing parallel threads with murder", test_parallel_threads<3, increment_with_murder>),
TESTS/mbedmicro-rtos-mbed/threads/main.cpp: Case("Testing serial threads with murder", test_serial_threads<10, increment_with_murder>),
TESTS/mbedmicro-rtos-mbed/threads/main.cpp: Case("Testing thread self terminate", test_self_terminate),
TESTS/mbedmicro-rtos-mbed/mutex/main.cpp: Case("Test single thread lock", test_single_thread_lock),
TESTS/mbedmicro-rtos-mbed/mutex/main.cpp: Case("Test single thread trylock", test_single_thread_trylock),
TESTS/mbedmicro-rtos-mbed/mutex/main.cpp: Case("Test single thread lock recursive", test_single_thread_lock_recursive),
TESTS/network/wifi/main.cpp: Case("Scan test", wifi_scan, greentea_failure_handler),
TESTS/network/wifi/main.cpp: Case("Connect test", wifi_connect, greentea_failure_handler),
TESTS/network/wifi/main.cpp: Case("Scan while connected test", wifi_connect_scan, greentea_failure_handler),
TESTS/network/wifi/main.cpp: Case("HTTP test", wifi_http, greentea_failure_handler),
but I can update
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.
Ah woops haha. Nevermind then!
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.
Too late, is updated : P
0a65f88
to
071b79b
Compare
071b79b
to
56ba283
Compare
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputBuild failed! |
This is a workaround for IAR's lack of flexibility with memory regions. Otherwise these tests would use very little heap and be mostly global allocations.
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
/morph test-nightly |
@adbridge and/or @mazimkhan, could you take a look at the Greentea client changes I've made? Everything seems to be ok, but doesn't hurt to have a few extra eyes on this. |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
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.
There are a lot of instances of magic numbers, where a macro should be used.
General lack of commenting of the changes.
Multiple instances of the same comments ( so please check through all changes for duplicates where I haven't marked them all individually...
* This function is blocking. | ||
*/ | ||
void GREENTEA_SETUP(const int timeout, const char *host_test_name) { | ||
|
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.
No header for this function ??
char _key[8] = {0}; | ||
|
||
while (1) { | ||
greentea_parse_kv(_key, buffer, sizeof(_key), size); | ||
greentea_write_string("mbedmbedmbedmbedmbedmbedmbedmbed\r\n"); | ||
if (strcmp(_key, GREENTEA_TEST_ENV_SYNC) == 0) { | ||
// Found correct __sunc message |
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.
_sync
* After host test name is received master will invoke host test script | ||
* and add hos test's callback handlers to main event loop | ||
* This function is blocking. | ||
*/ |
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.
Should describe how this differs from standard GREENTEA_SETUP
|
||
tx_buffer[i++] = ' '; | ||
|
||
for (; i<tx_size; ++i) { | ||
tx_buffer[i] = (rand() % 10) + '0'; |
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.
Would be nice to have a comment saying what this is actually doing and why
tx_buffer[i] = (rand() % 10) + '0'; | ||
} | ||
} | ||
|
||
int main() { | ||
GREENTEA_SETUP(60, "udp_echo"); | ||
|
||
char uuid[48] = {0}; |
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.
Why 48 characters ? Shouldn't this be a #define ?
for (int i = 0; i < sizeof(uuid); i++) { | ||
mac += uuid[i]; | ||
} | ||
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1); |
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.
comment in function
|
||
// Test setup | ||
utest::v1::status_t test_setup(const size_t number_of_cases) { | ||
char uuid[48] = {0}; |
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.
magic number
for (int i = 0; i < sizeof(uuid); i++) { | ||
mac += uuid[i]; | ||
} | ||
mbed_set_mac_address((const char*)mac, /*coerce control bits*/ 1); |
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.
comment inside function
@@ -90,5 +84,32 @@ int main() { | |||
} | |||
|
|||
eth.disconnect(); | |||
GREENTEA_TESTSUITE_RESULT(result); | |||
TEST_ASSERT_EQUAL(true, result); |
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.
Should be TEST_ASSERT_TRUE(result)
@@ -204,6 +194,32 @@ int main() { | |||
} | |||
|
|||
net.disconnect(); | |||
GREENTEA_TESTSUITE_RESULT(result); | |||
TEST_ASSERT_EQUAL(true, result); |
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.
TEST_ASSERT_TRUE
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.
I have general design comment:
For getting a random mac address do we really need to change greentea API? It can be done by generating the mac address in the host test script and sending a key,value pair to the target. That will delegate following repeated code to the host side where the UUID is coming from:
+ char uuid[48] = {0};
+ GREENTEA_SETUP_UUID(120, "default_auto", uuid, 48);
+
+ // create mac address based on uuid
+ uint64_t mac = 0;
+ for (int i = 0; i < sizeof(uuid); i++) {
+ mac += uuid[i];
+ }
Also above adding UUID bytes can compromise the uniqueness and randomness of UUID. For instance if there are two different sequences like 05 04 06
and 06 05 04
they will produce same sum. Hence the position of the bytes is just as important as their value.
In my opinion host side can produce more strong random and unique mac address that can be given to the target test to use.
Thanks for all of the feedback, especially @adbridge and @mazimkhan. After doing more examination, the method we went about for overriding the mbed mac address doesn't actually work since most vendors that have LWIP implementations already override the I'm closing this PR in favor of the updated (and reduced scope) #4369. Let's continue the discussion there, thanks! |
Also, added the issue #4370 to help track some of the outstanding issues (including what we have already tried to solve them). |
Description
This PR attempts to fix a number of issues that have cropped up with the networking tests lately. This pr is still in development.
Status
IN DEVELOPMENT
Migrations
If this PR changes any APIs or behaviors, give a short description of what API users should do when this PR is merged.
NO
Todos
TEST_ASSERT
statements to utest-style tests