Skip to content

TCP/TLS Socket tests will skip if TCP is not supported #10037

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

Merged
merged 1 commit into from
Mar 29, 2019

Conversation

michalpasztamobica
Copy link
Contributor

Description

I generally avoid using macros, but I couldn't come up with a better way in this case.
Two reasons why macros are used to wrap the open calls:

  1. I wanted to minimise the "boilerplate" which gets copied and pasted into every test.
  2. The SKIP_TEST_MESSAGE macro contains a "return;" which is intended to return from a current test code. Therefore we cannot use it inside any wrapper function, as then it would merely return from that function, not from the test as such.

The architectures which could make use of this (for example UBLOX_C030_N211) are not available in any RAAS server, but I agreed with @AriParkkila that he will make sure this executes correctly.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[x] Test update
[ ] Breaking change

Reviewers

@SeppoTakalo
@KariHaapalehto
@VeijoPesonen
@mtomczykmobica
@tymoteuszblochmobica
@AriParkkila

@michalpasztamobica michalpasztamobica force-pushed the tcp_skip_if_unsupported branch 2 times, most recently from ae110a7 to a206df9 Compare March 11, 2019 15:53
@SeppoTakalo
Copy link
Contributor

Uh.. You completely lost me with those macros..

I was hoping a way more simpler solution, like:

bool is_tcp_supported() {
    static bool supported;
    static bool tested = false;
    if (!tested) {
        TCPSocket socket;
        supported = socket.open(NetworkInterface::get_default_instance()) == NSAPI_ERROR_OK;
    }
    return supported;
}

void TCPSOCKET_ECHOTEST()
{
    if (!is_tcp_supported()) {
        TEST_SKIP_MESSAGE("TCP not supported");
    }
    ...
}

Add extra 3 lines per TCP test case.. should not be too much.

@ciarmcom
Copy link
Member

@michalpasztamobica, thank you for your changes.
@tymoteuszblochmobica @AriParkkila @VeijoPesonen @SeppoTakalo @KariHaapalehto @mtomczykmobica @ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-test @ARMmbed/mbed-os-maintainers please review.

@michalpasztamobica
Copy link
Contributor Author

I did not consider this option to avoid influencing test results by creating, opening and closing an extra socket before every (or at least one) test routine.
I was trying to code it in situ .
But if you don't mind the one extra socket operation, we can go ahead with your solution.

In this case however, I would put it on top of #9959 and add it to the test case setup function, rather than copy it into the code of every test function...

@0xc0170
Copy link
Contributor

0xc0170 commented Mar 13, 2019

Review astyle travis failing job

@michalpasztamobica
Copy link
Contributor Author

@0xc0170 I plan to rewrite the whole code, according to Seppo's suggestion, but I need to get #9959 merged, so I can use the greentea test case setup function...

@michalpasztamobica
Copy link
Contributor Author

@SeppoTakalo , unfortunately I could not put the SKIP macro inside the testcase's setup function, because the macro returns void and the wrapper needs to return a value.

But I did the second best thing possible - I added the function as you suggested and wrapped it with a simple macro, which got added to every test case.

To test the changes I locally broke LWIP::socket_open() function to return NSAPI_ERROR_UNSUPPORTED when TCP protocol is in use. All TCP and TLS tests printed the SKIP message and showed up as passing in the summary.

Reviewers, please review :)

@cmonr
Copy link
Contributor

cmonr commented Mar 26, 2019

@michalpasztamobica Could you check the astyle job results?

@cmonr
Copy link
Contributor

cmonr commented Mar 26, 2019

Also, it looks like the preceeding PR has been merged.

@michalpasztamobica
Copy link
Contributor Author

astyle fixed and the preceding PR is indeed merged (although it turned out I cannot make use of it in the end).
@SeppoTakalo , I'll be grateful for your approval.

@cmonr
Copy link
Contributor

cmonr commented Mar 26, 2019

CI started

cmonr pushed a commit to cmonr/mbed-os that referenced this pull request Mar 26, 2019
…unsupported

TCP/TLS Socket tests will skip if TCP is not supported
@mbed-ci
Copy link

mbed-ci commented Mar 26, 2019

Test run: SUCCESS

Summary: 6 of 6 test jobs passed
Build number : 1
Build artifacts

@cmonr
Copy link
Contributor

cmonr commented Mar 27, 2019

@SeppoTakalo @michalpasztamobica Should we wait on others to chime in?

Copy link

@mtomczykmobica mtomczykmobica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looka good.

@michalpasztamobica
Copy link
Contributor Author

@cmonr , I think there was enough time, I'd suggest to merge in.

Copy link
Contributor

@cmonr cmonr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@cmonr
Copy link
Contributor

cmonr commented Mar 28, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Mar 29, 2019

Test run: SUCCESS

Summary: 6 of 6 test jobs passed
Build number : 2
Build artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants