Skip to content

Conversation

VeijoPesonen
Copy link
Contributor

@VeijoPesonen VeijoPesonen commented Apr 18, 2018

Description

Improving Greentea netsocket test case coverage

Pull request type

[X] Test case
[ ] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

@VeijoPesonen
Copy link
Contributor Author

VeijoPesonen commented Apr 18, 2018

@kjbracey-arm would you please add DO NOT MERGE-label. There are more test cases to come. @SeppoTakalo, @jarlamsa, @juhaylinen, you can start reviewing if you want but it's not expected. At this stage I just want to make the stuff visible so you can see how things are proceeding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implementation provided by @SeppoTakalo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This won't work. Only IP address is accepted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Where this limitation is?
Socket API is perfectly capable of accepting domain names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to figure it out.

Copy link
Contributor

Choose a reason for hiding this comment

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

SocketAddress does not resolve names. It is just a placeholder for IP addresses.
Use NetworkInterface::gethostbyname() or feed the string to Socket which translates its string through the gethostbyname()

Copy link
Contributor

Choose a reason for hiding this comment

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

So for example TCPSocket::connect(const char *host, uint16_t port) does the translation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I just need to remember to make the same change to all netsocket test cases.

@VeijoPesonen
Copy link
Contributor Author

VeijoPesonen commented May 11, 2018

TCPSOCKET_RECV_100K_NONBLOCK and TCPSOCKET_RECV_100K are still unstable but people can start to review the other tests.

Wrong lwIP configuration (#define TCP_QUEUE_OOSEQ 0) was causing the issue

kjbracey
kjbracey previously approved these changes May 11, 2018
Copy link
Contributor

@SeppoTakalo SeppoTakalo left a comment

Choose a reason for hiding this comment

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

Add error handling.

There are multiple cases where you call socket functions without testing the return code.
For example:

get_interface()->gethostbyname(...);
sock->open(...);
sock->connect(...);
sock->close();

Every socket call should be tested and compared against acceptable return values. Not only those that transfer the data, but also ones than translate names or create connection.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does the TEST_ASSERT() propagation work in greentea_setup()?
Are we able to see whether device did not join the network and therefore tests failed to run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we are able to see if the problem arises from the handler. But there is still need to check the logs.

PS C:\ws\mbed-os> mbedhtrun -f .\BUILD\tests\K64F\ARM\TESTS\netsocket\udp\udp.bin -d D: -p COM14:9600
[1526317024.03][HTST][INF] host test executor ver. 1.2.0
[1526317024.03][HTST][INF] copy image onto target...
        1 file(s) copied.
[1526317032.47][MBED][WRN] Target ID not found: Skipping flash check and retry
[1526317032.47][HTST][INF] starting host test process...
[1526317033.09][CONN][INF] starting connection process...
[1526317033.09][CONN][INF] notify event queue about extra 60 sec timeout for serial port pooling
[1526317033.09][CONN][INF] initializing serial port listener...
[1526317033.09][SERI][INF] serial(port=COM14, baudrate=9600, read_timeout=0.01, write_timeout=5)
[1526317033.09][SERI][INF] reset device using 'default' plugin...
[1526317033.11][HTST][INF] setting timeout to: 60 sec
[1526317033.36][SERI][INF] waiting 1.00 sec after reset
[1526317034.36][SERI][INF] wait for it...
[1526317034.36][SERI][TXD] mbedmbedmbedmbedmbedmbedmbedmbedmbedmbed
[1526317034.36][CONN][INF] sending up to 2 __sync packets (specified with --sync=2)
[1526317034.36][CONN][INF] sending preamble '0ea1005b-0e2c-4dec-a15f-c947b6556639'
[1526317034.36][SERI][TXD] {{__sync;0ea1005b-0e2c-4dec-a15f-c947b6556639}}
[1526317034.49][CONN][RXD] mbedmbedmbedmbedmbedmbedmbedmbed
[1526317034.54][CONN][INF] found SYNC in stream: {{__sync;0ea1005b-0e2c-4dec-a15f-c947b6556639}} it is #0 sent, queued...
[1526317034.56][HTST][INF] sync KV found, uuid=0ea1005b-0e2c-4dec-a15f-c947b6556639, timestamp=1526317034.540000
[1526317034.57][CONN][INF] found KV pair in stream: {{__version;1.3.0}}, queued...
[[1526317034.59][HTST][INF] DUT greentea-client version: 1.3.0
1526317034.59][CONN][INF] found KV pair in stream: {{__timeout;120}}, queued...
[1526317034.59][HTST][INF] setting timeout to: 120 sec
[1526317034.62][CONN][INF] found KV pair in stream: {{__host_test_name;default_auto}}, queued...
[1526317034.62][HTST][INF] host test class: '<class 'mbed_host_tests.host_tests.default_auto.DefaultAuto'>'
[1526317034.62][HTST][INF] host test setup() call...
[1526317034.62][HTST][INF] CALLBACKs updated
[1526317034.62][HTST][INF] host test detected: default_auto
[1526317078.79][CONN][RXD] :46::FAIL: Expected 0 Was -3004
[1526317078.86][CONN][RXD] >>> failure with reason 'Assertion Failed' during 'Test Setup Handler'
[1526317078.90][CONN][INF] found KV pair in stream: {{max_heap_usage;0}}, queued...
[[1526317078.91][CONN][INF] found KV pair in stream: {{reserved_heap;0}}, queued...
1526317078.91][HTST][ERR] orphan event in main phase: {{max_heap_usage;0}}, timestamp=1526317078.897000
[1526317078.91][HTST][ERR] orphan event in main phase: {{reserved_heap;0}}, timestamp=1526317078.913000
[1526317078.93][CONN][INF] found KV pair in stream: {{end;failure}}, queued...
[1526317078.94][CONN][INF] found KV pair in stream: {{__exit;0}}, queued...
[1526317078.95][HTST][INF] __exit(0)
[1526317078.95][HTST][INF] __notify_complete(False)
[1526317078.95][HTST][INF] __exit_event_queue received
[1526317078.95][HTST][INF] test suite run finished after 44.36 sec...
[1526317078.96][CONN][INF] received special even '__host_test_finished' value='True', finishing
[1526317078.98][HTST][INF] CONN exited with code: 0
[1526317078.98][HTST][INF] Some events in queue
[1526317078.98][HTST][INF] stopped consuming events
[1526317078.98][HTST][INF] host test result() call skipped, received: False
[1526317078.98][HTST][INF] calling blocking teardown()
[1526317078.98][HTST][INF] teardown() finished
[1526317078.98][HTST][INF] {{result;failure}}

Copy link
Contributor Author

@VeijoPesonen VeijoPesonen May 14, 2018

Choose a reason for hiding this comment

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

I'll add the required return value checks. I wouldn't prefer not to because it will just add clutter on the test cases and assertions would reveal problems arising during setups. Part of the test is to check that the desired behavior is the result of correct setup.

Copy link
Contributor

@SeppoTakalo SeppoTakalo May 14, 2018

Choose a reason for hiding this comment

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

Are you ignoring the sendto() failures?

Copy link
Contributor Author

@VeijoPesonen VeijoPesonen May 14, 2018

Choose a reason for hiding this comment

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

Yes, I am because buffer comparison will reveal if data was not transmitted and received - retries are allowed. Checking for errors wouldn't make any difference.

@cmonr
Copy link
Contributor

cmonr commented May 14, 2018

@VeijoPesonen Was there a particular reason why this PR was give a new category?

@SeppoTakalo @kjbracey-arm Is the intention to get this in for 5.9?

@VeijoPesonen
Copy link
Contributor Author

VeijoPesonen commented May 14, 2018

@cmonr My changes are not fixes, refactoring of existing code, breaking change to existing code, new features and do not consider new targets. I decided to add a new category to evoke this discussion. I would say there is need to have its own category for test cases. Unless new test case is to be treated like a new feature.

@VeijoPesonen
Copy link
Contributor Author

Please let me know when it's fine to squash those fixup commits.

@SeppoTakalo
Copy link
Contributor

It is OK to squash when ever you feel so. And please rebase on top of master.
Start checking of the build failures.

For example:

Build failures:

  * K64F::ARM::TESTS-NETWORK-WIFI

        Building project wifi (K64F, ARM)

        Scan: ARM

        Scan: wifi

        Scan: FEATURE_STORAGE

        Scan: FEATURE_LWIP

        Compile [  5.3%]: get_interface.cpp

        [Error] get_interface.cpp@34,0:  #513: a value of type "EthernetInterface *" cannot be assigned to an entity of type "WiFiInterface *"

Once build failures are fixed, ask Kevin to start morph testing for this PR. We need to see which boards start failing.

@SeppoTakalo
Copy link
Contributor

Please remove also following tests from the tree:

  • netsocket/ip_parsing <- This is unittesting the SocketAddress class. Not useful for testing HW.
  • netsocket/socket_sigio <- This one is obsoleted by non-blocking test-cases
  • netsocket/tcp_hello_world <- This is obsoleted by other TCP tests

@SeppoTakalo
Copy link
Contributor

Can we also refactor testcases to follow naming from the test plan?

So instead of:

void test_udpsocket_echotest();
...
Case cases[] = {
        Case("Echo", test_udpsocket_echotest),

We would use:

void UDPSOCKET_ECHOTEST();
...
Case cases[] = {
        Case("UDPSOCKET_ECHOTEST", UDPSOCKET_ECHOTEST),

That would allow us to publish the test plan without modifications.

@VeijoPesonen
Copy link
Contributor Author

VeijoPesonen commented May 16, 2018

I'll switch the naming convention. I don't see a reason to suppress compiler error for TESTS-NETWORK-WIFI test cases when Ethernet is in use. Maybe it would make more sense to use preprocessor directive explicitly to report an error, or not...

@SeppoTakalo
Copy link
Contributor

@VeijoPesonen Also, you need to do the separation of testcase.

Currently in both TCP and UDP you have

#ifndef MBED_EXTENDED_TESTS
#error [NOT_SUPPORTED] Pressure tests are not supported by default
#endif

Which is not what we are aiming for. So remove those.
If device is able to provide network interface, it should be able to run at least some of the testcases.

So do the splitting in the Case case[] table.
For example in tcp/main.cpp

    Case("Echo", test_tcpsocket_echotest),
    Case("Echo non-block", test_tcpsocket_echotest_nonblock),
    Case("Reuse a socket", test_tcpsocket_open_close_repeat),
    Case("Open at least 4 sockets", test_tcpsocket_open_limit),
    Case("Parallel socket thread safety", test_tcpsocket_thread_per_socket_safety),
    Case("Send repeatedly", test_tcpsocket_send_repeat),
#ifdef MBED_EXTENDED_TESTS
    Case("Echo burst", test_tcpsocket_echotest_burst),
    Case("Echo burst non-block", test_tcpsocket_echotest_burst_nonblock),
    Case("Invalid endpoint rejected", test_tcpsocket_connect_invalid),
    Case("Receive 100k from CHARGEN service", test_tcpsocket_recv_100k),
    Case("Receive 100k from CHARGEN service non-block", test_tcpsocket_recv_100k_nonblock),
    Case("Receive in given time", test_tcpsocket_recv_timeout),
    Case("Sending shall not take too long", test_tcpsocket_send_timeout),
    Case("Endpoint initiated close", test_tcpsocket_endpoint_close),
#endif
};

Modify the splitting so that in PR we would run only fast smoke tests that current boards are able to pass. Then later on, in nightly test those extented tests are also enable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Use same packet ranges as our python tests.
1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000,1100,1200

So from 1 to 10. Then 10 to 100 in steps of 10. Then from 100 to 1200 in steps of 100.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, to be fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

NSAPI_ERROR_WOULD_BLOCK should not be treated differently in blocking case. All value less than zero are errors in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, have to take a look

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion, you already have generate_RFC_864_pattern() that can be used for this purpose.

Copy link
Contributor Author

@VeijoPesonen VeijoPesonen May 16, 2018

Choose a reason for hiding this comment

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

Good idea and to be taken into use

Copy link
Contributor

Choose a reason for hiding this comment

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

To be sure, clear the rx_buffer, so if we re-send same sized packet with same data, it will be shown.
`memset(rx_buffer, 0, BUFF_SIZE);

Copy link
Contributor

Choose a reason for hiding this comment

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

As in TCP case, use same ranges.
(Perhaps update the testplan as well)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is weird way of saying "More than 100, but less than 200"
Why not TEST_ASSERT_INT_WITHIN(50, 150, ...)

@SeppoTakalo
Copy link
Contributor

Any ideas why WIFI tests now fail to build?
Did we somehow enable the build with K64F?

@SeppoTakalo
Copy link
Contributor

@VeijoPesonen
Ah.. looks like in master it does not fail, so you have cherry-picked some changes from Juha.

We cannot merge those in yet, selectively building WiFi tests should be resolved somewhere else.

@SeppoTakalo
Copy link
Contributor

@kjbracey-arm @0xc0170
Can you guys help, how can I tell from pre-compilation phase that

#if <some magic here>
#error [NOT_SUPPORTED] This is not a WiFi device
#endif

Other than that, test configuration now picks up interfaces by

interface = MBED_CONF_APP_OBJECT_CONSTRUCTION;

@kjbracey
Copy link
Contributor

Prior to "default network interface" stuff, you have to assume it's not a WiFi device, unless someone has specifically told you how to find a WiFi interface. Which would be the 'MBED_CONF_APP_OBJECT_CONSTRUCTION' etc the tests use?

After default network interface, I'm afraid there's still no compile-time method, but WiFiInterface::get_default_instance() would return NULL or not at run-time.

For Ethernet, DEVICE_EMAC basically does the job.

@SeppoTakalo
Copy link
Contributor

@VeijoPesonen You need then drop the changes to WiFi tests get_interface() function. That is not universal, and is breaking the build.

@SeppoTakalo
Copy link
Contributor

Other than those that I have now commented, all looks good.
So after those are changed, I'm OK with these changes.

Veijo Pesonen and others added 11 commits May 25, 2018 09:39
	udpsocket_sendto_invalid
	tcpsocket_send_repeat
        udpsocket_sendto_repeat
	udpsocket_echotest
	udpsocket_echotest_nonblock
	udpsocket_echotest.cpp
	udpsocket_echotest_burst.cpp
From lowercase to uppercase and drops 'test_'-prefix. Test case
descriptions do also match to TC names now.

Additionally all the TCs are not behing MBED_EXTENDED_TESTS
anymore.
@SeppoTakalo SeppoTakalo dismissed stale reviews from kjbracey and themself via 491a7ea May 25, 2018 07:20
@SeppoTakalo
Copy link
Contributor

Rebased on top of master.

Emac is now in "needs Preceeding PR" label should be removed.

@0xc0170 or @kjbracey-arm please start tests for this.

@kjbracey
Copy link
Contributor

It would be nice if this could go to 5.9.0, but I think CI load may prevent it. Labelling as 5.9.1 for now.

@cmonr
Copy link
Contributor

cmonr commented May 25, 2018

Going to attempt to squeeze this in.

/morph build

@mbed-ci
Copy link

mbed-ci commented May 25, 2018

Build : SUCCESS

Build number : 2153
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6665/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented May 25, 2018

@mbed-ci
Copy link

mbed-ci commented May 25, 2018

@cmonr cmonr merged commit 45dc00d into ARMmbed:master May 25, 2018
@VeijoPesonen VeijoPesonen deleted the greentea_netsocket_more_tests branch May 26, 2018 17:46
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.

8 participants