Skip to content

tests: port tests/lwip to sock#6372

Merged
miri64 merged 3 commits intoRIOT-OS:masterfrom
miri64:tests/enh/port-lwip-test-to-sock
Apr 26, 2017
Merged

tests: port tests/lwip to sock#6372
miri64 merged 3 commits intoRIOT-OS:masterfrom
miri64:tests/enh/port-lwip-test-to-sock

Conversation

@miri64
Copy link
Copy Markdown
Member

@miri64 miri64 commented Jan 15, 2017

This ports tests/lwip to sock.

Depends on #5936, #5937, and #5938. Will only rebase once all of these are merged.

@miri64 miri64 added Area: network Area: Networking Area: tests Area: tests and testing framework State: waiting for other PR State: The PR requires another PR to be merged first labels Jan 15, 2017
@miri64 miri64 added this to the Release 2017.01 milestone Jan 15, 2017
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jan 15, 2017

Will only rebase once all of these are merged.

(because merging those three is pretty tricky due to their similarities)

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jan 15, 2017

Also needs #6373 to build successfully for msba2.

PSEUDOMODULES += sock
PSEUDOMODULES += sock_ip
PSEUDOMODULES += sock_tcp
PSEUDOMODULES += sock_udp
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Already provided in lines 59-62?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oops.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jan 20, 2017

Rebased to current master and current versions of #5937 and #5938.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jan 20, 2017

Made the output a little bit more specific.

@PeterKietzmann
Copy link
Copy Markdown
Member

RIOT/tests/lwip/tcp.c:79:13: error: 'client_port' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             printf("Received TCP data from client [%s]:%u:\n",

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jan 24, 2017

Fixed

@PeterKietzmann PeterKietzmann modified the milestones: Release 2017.04, Release 2017.01 Jan 26, 2017
@miri64 miri64 mentioned this pull request Jan 29, 2017
17 tasks
@PeterKietzmann
Copy link
Copy Markdown
Member

@miri64 please rebase. @kYc0o as you approved #5937, please test this one. I added you as assignee.

@kYc0o
Copy link
Copy Markdown
Contributor

kYc0o commented Feb 8, 2017

OK no problem ;-)

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 8, 2017

Remember that this also needs #5938 ;-)

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 8, 2017

Rebased to current master and #5938.

@miri64 miri64 force-pushed the tests/enh/port-lwip-test-to-sock branch from 6e70e85 to 329b176 Compare February 8, 2017 09:15
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 8, 2017

From #5937 (comment):

On a phytec board I don't get an IPv6 address. ps() crashes the node but this is probably an issue of #6372.

The phytec board issue is due it not being included in lwIP's auto-init routine yet (which was not possible due it not being netdev2 before #6453 was merged). This is more about fixing #4672 (or, as a workaround, writing a custom initialization routine for that device in lwip_bootstrap()) than about this specific application. Might be that the crashing of ps() is related to that, but I don't have a PhyTec board at hand to test.

@PeterKietzmann
Copy link
Copy Markdown
Member

Runnung on the phytecs was one issue. Crashing was an other which can also be seen on atmel boards

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 8, 2017

Crashing was an other which can also be seen on atmel boards

Okay, will look into that.

@PeterKietzmann
Copy link
Copy Markdown
Member

I didn't follow your discussion completely but yes I prefer an application+Makefile that demonstrates sock->lwip->netdev->air. And most likely it is more an "example" than a "test". Without such an application it is always a hassle to research all dependencies and stuff instead of just taking this app as a basis, when someone actually wants to make use of this port. In my opinion a general sock example would be best which switches between stacks (lwip, emb6, gnrc) via make flag or so.
I assume @smlng was referring to code duplication in the single tests tests/lwip_sock_* and not in the "demonstrator" application?

@smlng
Copy link
Copy Markdown
Member

smlng commented Feb 16, 2017

I assume @smlng was referring to code duplication in the single tests tests/lwip_sock_* and not in the "demonstrator" application?

Mostly, but tests/lwip basically includes all 3 other tests, but without auto-test ability. For the latter, I suggested its more an example -- a good one btw. and sure helpful for someone willing to use RIOT+lwip.

To summarize: I don't see the benefit of having a) 3 separated tests for lwip ip, udp, and tcp (which should be merged to avoid code duplication, and to simplify the code enhancing its readability); and b) a single test (which is more an example) that integrates all 3 but cannot be run automatically -> for instance in a future CI with nightly build + test-everything.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 16, 2017

To summarize: I don't see the benefit of having a) 3 separated tests for lwip ip, udp, and tcp (which should be merged to avoid code duplication, and to simplify the code enhancing its readability); and b) a single test (which is more an example) that integrates all 3 but cannot be run automatically -> for instance in a future CI with nightly build + test-everything.

I'd argue this application doesn't even do that. It provides shell commands that can automatically be run. I re-add the test script and extend it.

@miri64 miri64 force-pushed the tests/enh/port-lwip-test-to-sock branch from 916669f to 40fd399 Compare February 28, 2017 20:07
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 28, 2017

Rebased.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Feb 28, 2017

(and adapted the test script @smlng).

@kaspar030 kaspar030 modified the milestone: Release 2017.04 Apr 21, 2017
@miri64 miri64 added the Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties label Apr 25, 2017
@miri64 miri64 force-pushed the tests/enh/port-lwip-test-to-sock branch from f96ef1a to 76cdab9 Compare April 25, 2017 08:16
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Apr 25, 2017

Rebased.

# including lwip_ipv6_mld would currently break this test on at86rf2xx radios
USEMODULE += lwip lwip_ipv6_autoconfig lwip_conn_ip lwip_netdev
USEMODULE += lwip_udp lwip_conn_udp
USEMODULE += lwip lwip_ipv6_autoconfig lwip_sock_ip lwip_netdev
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the dependencies seem a little much. At least lwip_* should depend on lwip, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and lwip should depend on lwip_netdev, which should depend on netdev_default?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Please read the title of this PR. This PR is about porting the tests, not fixing dependencies for lwIP ;-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well, don't we have a convention that once a mess has been identified, we fix it instead of adding on top?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Primarily we want to have topical PRs so they don't grow out of hand (and the review doesn't take an eternity). Let's fix this in a separate PR after this one is merged. Please!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok!

USEMODULE += lwip lwip_ipv6_autoconfig lwip_sock_ip lwip_netdev
USEMODULE += lwip_udp lwip_sock_udp
USEMODULE += lwip_tcp lwip_sock_tcp
USEMODULE += ipv6_addr
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also this dependency should be implicit (through sock?).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

tests/lwip/tcp.c Outdated

#ifdef MODULE_SOCK_TCP
static char sock_inbuf[SOCK_INBUF_SIZE];
static bool server_running, client_running = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

only client running will be set to false, which is probably not what you intended. Anyhow, if declared like this, the default is zero (false) anyways.

tests/lwip/tcp.c Outdated

msg_init_queue(server_msg_queue, SERVER_MSG_QUEUE_SIZE);
/* parse port */
server_addr.port = (uint16_t)atoi((char *)args);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

both casts seem unnecessary

tests/lwip/tcp.c Outdated

static int tcp_send(char *data, unsigned int num, unsigned int delay)
{
uint8_t byte_data[strlen(data) / 2];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dynamic array?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

How else should I do it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(and where did we forbid dynamic arrays, especially in shell context where we know the maximum length this doesn't seem necessary)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

well, for one, the shell commands might be used elsewhere (shudder). Then the problem with dynamic arrays is the dynamic stack usage. Breaks the stack depending on usage. If the maximum shell line length is allowed, allocate that much memory.

tests/lwip/tcp.c Outdated
return 1;
}
if (argc > 3) {
num = (uint32_t)atoi(argv[3]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cast needed?

tests/lwip/tcp.c Outdated
num = (uint32_t)atoi(argv[3]);
}
if (argc > 4) {
delay = (uint32_t)atoi(argv[4]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same

@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does this run with python3?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Now that I replaced all occurrences of pexpect.spawn() with pexpect.spawnu() it does

tests/lwip/udp.c Outdated
ipv6_addr_t src = IPV6_ADDR_UNSPECIFIED, dst;
uint16_t port;
sock_udp_ep_t dst = SOCK_IPV6_EP_ANY;
uint8_t byte_data[strlen(data) / 2];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dynamic array

tests/lwip/udp.c Outdated
}
/* parse port */
port = (uint16_t)atoi(port_str);
dst.port = (uint16_t)atoi(port_str);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cast

@emmanuelsearch
Copy link
Copy Markdown
Member

+1 for trying to merge this at H&A. Would achieve fully harmonized API (sock).

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Apr 25, 2017

+1 for trying to merge this at H&A. Would achieve fully harmonized API (sock).

If #6012 gets merged, too.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Apr 25, 2017

Addressed comments.

Copy link
Copy Markdown
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

almost there

tests/lwip/tcp.c Outdated
@@ -0,0 +1,224 @@
/*
* Copyright (C) 2015 Freie Universität Berlin
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

two years old ;)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well the PR feels like being open for so long :o) (will fix though ;))

tests/lwip/tcp.c Outdated
}
else if (strcmp(argv[1], "send") == 0) {
uint32_t num = 1;
uint32_t delay = 1000000;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please ad "LU" for our beloved 16bitters

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Apr 25, 2017

Addressed

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Apr 25, 2017

Added nucleo-l053 and nucleo32-l031 to the boards with insufficient memory.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Apr 25, 2017

May I squash, @kaspar030?

@miri64 miri64 force-pushed the tests/enh/port-lwip-test-to-sock branch from 9f3b5cd to b84f3cc Compare April 25, 2017 16:19
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Apr 25, 2017

Squashed (asked @kaspar030 if this is alright)

Copy link
Copy Markdown
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

ACK.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Apr 26, 2017

The errors in arduino_hello-world on nucleo-f070 don't seem to be related.

@miri64 miri64 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 26, 2017
@miri64 miri64 merged commit 4df288f into RIOT-OS:master Apr 26, 2017
@miri64 miri64 deleted the tests/enh/port-lwip-test-to-sock branch April 26, 2017 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants