-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add TLSSocket greentea tests. #9283
Add TLSSocket greentea tests. #9283
Conversation
@michalpasztamobica, thank you for your changes. |
da9eb01
to
fdec0de
Compare
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 good.
fdec0de
to
3b654aa
Compare
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.
Just a minor changes proposed.
Otherwise looks good.
} | ||
|
||
if (bt_left != 0) { | ||
drop_bad_packets(*sock, 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.
This can only happen if recv()
returns error and if it does, we should not try to read again.
I prefer this drop_bad_packets()
to be removed. Just mark the test failed (with error message, if possible).
TESTS/netsocket/tls/main.cpp
Outdated
{ | ||
SocketAddress tls_addr; | ||
|
||
get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tls_addr); |
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.
Probably a minor thing, but now that we use NetworkInterface::get_default_instance()
can we refactor all these get_interface()
call to NetworkInterface::get_default_instance()->
I feel like get_interface()
is also a residue from time when default network interface did not exist
TESTS/netsocket/tls/main.cpp
Outdated
if (err != NSAPI_ERROR_OK) { | ||
printf("Error from sock.connect: %d\n", err); | ||
return err; | ||
} |
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.
This function is copy&paste from previous, only change is the port address.
Can the port address be a parameter to this and just use the same function?
TESTS/netsocket/tls/main.cpp
Outdated
Case("TLSSOCKET_OPEN_TWICE", TLSSOCKET_OPEN_TWICE), | ||
Case("TLSSOCKET_OPEN_LIMIT", TLSSOCKET_OPEN_LIMIT), | ||
Case("TLSSOCKET_OPEN_DESTRUCT", TLSSOCKET_OPEN_DESTRUCT), | ||
// Case("TLSSOCKET_HTTPS_GET", TLSSOCKET_HTTPS_GET), // Fails! |
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.
// Fails!
does not sound very good on public example.
Maybe "work-in-progress, unstable" or something like that.
tls_global::TLS_OS_STACK_SIZE, | ||
stack_mem, | ||
"receiver"); | ||
TEST_ASSERT_EQUAL(osOK, thread->start(callback(tlssocket_echotest_nonblock_receiver, &pkt_s))); |
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.
New thread per packet?
Sounds a bit overkill...
We could push event to global event loop every time we receive sigio(), and that event could the read until WOULD_BLOCK is received.. but if all data is received, it could set some global event flag to indicate that all data is read.
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.
Just to make sure we have a common understanding of what is going on in this test...
Indeed, a thread is created for every new packet size. But there is always just one receiver thread running at a time (tx_sem.wait will block the main thread's for loop until receiver thread exits). The receiver thread already contains a loop, which is controller with SIGIO (as per the previous comment :) ) and returns once all data is received.
So the only change would be to trigger the receiver's loop using a global event loop instead of triggering it using thread creation - is that right? Or is there some further optimisation which I failed to notice?
TESTS/netsocket/README.md
Outdated
|
||
$ sudo nmap -sT -p7,9,13,37 echo.mbedcloudtesting.com | ||
$ sudo nmap -sT -p7,9,13,37,2007,2009,2013 echo.mbedcloudtesting.com |
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 can see that there was a error on previous documentation.
This was supposed to do UDP scan, and therefore required sudo
Can you change it to do
sudo nmap -sU
instead?
* limitations under the License. | ||
*/ | ||
|
||
#include "tls_tests.h"" |
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.
Douple "" at the end of line
|
||
TLSSocket *sock = new TLSSocket; | ||
if (!sock) { | ||
TEST_FAIL(); |
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_FAIL won't abort execution so adding return-statement would be good here.
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 point, but I removed the bind tests entirely.
However, these same comments apply also to tcp tests.
{ | ||
TLSSocket sock; | ||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface())); | ||
TEST_ASSERT_EQUAL(NSAPI_ERROR_AUTH_FAILURE, sock.connect(MBED_CONF_APP_ECHO_SERVER_ADDR, 2007)); |
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 good to take the port number from app config json-file as this is non-standard port
3b654aa
to
cdfc21d
Compare
cdfc21d
to
8bd443d
Compare
@ARMmbed/mbed-os-maintainers @ARMmbed/mbed-os-core Hi guys, do you know that is there any way we could force main stack size to be raised to 8 kB just for these TLSSocket tests? Currently that is roughly the amount of stack that TLS handshake requires. Therefore we need to resolve the stack issue before merging? For example, can I manually create a thread that has 8kB of stack, and launch Greentea from there? |
@michalpasztamobica Can you try for example following:
If that works, we could perhaps use that to force bigger stack for TLS thread. |
8bd443d
to
0a0026e
Compare
@SeppoTakalo , your idea worked. Thanks! |
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.
Now looks OK
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 good
@SeppoTakalo , @VeijoPesonen , I updated the README.md file with the TLSSocket test documentation and also amended some mistakes I spotted. I did not open a new PR, as the changes were actually relevant to this PR and it still wasn't merged. |
3a1d276
to
419ee1d
Compare
Fixed the missing whitespace which Travis pointed out. |
419ee1d
to
5b829a2
Compare
TLSSocket tests based on existing TCPSocket greentea tests and TLSSocket icetea tests.
5b829a2
to
c2aafcd
Compare
Travis was giving some odd errors, so I rebased to latest master to check I am missing some CI fix... |
CI started |
Test run: FAILEDSummary: 2 of 11 test jobs failed Failed test jobs:
|
@michalpasztamobica test failures are related |
The reason is a known issue in IAR: #8306 @SeppoTakalo , in icetea we left the test failing in order not to hide the bug, but I think for greentea we have to exclude the test, otherwise we will break the public CI. Do you agree? I wrapped the TLSSOCKET_SIMULTANEOUS test with a preprocessor guard:
I checked that it doesn't hurt other compilers and IAR simply runs one test less. |
The whole README.md had to be updated to match the internal Confluence documentation, which can now be locked. In the process I also updated any spotted mistakes in tests documentation, removed the obsolete TCPServer tests documentation and added a test which was missing from UDPSocket's main.
c2aafcd
to
af65522
Compare
@0xc0170 , can we give this another try? Seppo approved my solution and it worked fine locally. |
Ci started |
Test run: FAILEDSummary: 1 of 12 test jobs failed Failed test jobs:
|
jenkins-ci/greentea-test restarted |
Description
TLSSocket tests based on existing TCPSocket greentea tests and TLSSocket icetea tests.
The tests are only passing with
"rtos.main-thread-stack-size": 8192
(6144 if we take out the SIMULTANEOUS test).HTTPS_GET test is commented as it fails, perhaps due to connectivity reasons - I don't want to break the CI.
Pull request type
Reviewers
@SeppoTakalo
@KariHaapalehto
@VeijoPesonen
@mtomczykmobica