-
Notifications
You must be signed in to change notification settings - Fork 7k
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
samples: net: sockets: Allow to build and test with POSIX subsys #18736
samples: net: sockets: Allow to build and test with POSIX subsys #18736
Conversation
This patch is kinda culmination of efforts in #16621, #16626, #18548. Those patches enable to build existing 3rd-party POSIX software for Zephyr with much less changes than before (with the aim to have zero changes). This patch demoes that magic in-tree, using existing socket samples (which were always written to be POSIX-compatible). So, now exact same source file (down to the includes used) which works on e.g. Linux, can be built on Zephyr without any lowy patching. (Here, the effect is somewhat diluted, as the sample continue to contain adhoc Zephyr includes to build for a case when CONFIG_POSIX_API is not defined. I'm a bit shy to remove it right away, because story of POSIX subsys and socket offloading is not clear.) And to remind, the idea of #17706 is to continue (incremental) work in that direction, requiring asymptotically less patching to build real-world POSIX projects for Zephyr. |
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, minor tweaks needed.
@@ -8,3 +8,12 @@ tests: | |||
min_ram: 32 | |||
min_flash: 128 | |||
tags: net socket | |||
sample.net.sockets.big_http_download.posix: | |||
filter: TOOLCHAIN_HAS_NEWLIB == 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.
Please move the common values between sample.net.sockets.big_http_download
and sample.net.sockets.big_http_download.posix
to common block.
So something like this:
common:
harness: net
tags: net socket
min_ram: 32
min_flash: 128
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.
Please move the common values between
Fixed.
@@ -8,3 +8,12 @@ tests: | |||
min_ram: 32 | |||
min_flash: 96 | |||
tags: net socket | |||
sample.net.sockets.dumb_http_server.posix: | |||
filter: TOOLCHAIN_HAS_NEWLIB == 1 | |||
harness: net |
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.
same here
@@ -7,3 +7,10 @@ tests: | |||
harness: net | |||
platform_whitelist: qemu_x86 | |||
tags: net socket | |||
sample.net.sockets.echo_async.posix: | |||
harness: net |
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.
here too
@@ -8,3 +8,12 @@ tests: | |||
min_ram: 32 | |||
min_flash: 80 | |||
tags: net socket | |||
sample.net.sockets.http_get.posix: | |||
filter: TOOLCHAIN_HAS_NEWLIB == 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.
and here
c6e2f19
to
a74d533
Compare
tests: | ||
sample.net.sockets.http_get: | ||
harness: net | ||
sample.net.sockets.http_get.posix: | ||
filter: TOOLCHAIN_HAS_NEWLIB == 1 | ||
harness: net |
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.
Most of the settings in sample.net.sockets.http_get.posix
could be removed as they are now in common: block
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.
Ack, overlooked it, fixed.
tests: | ||
sample.net.sockets.big_http_download: | ||
filter: TOOLCHAIN_HAS_NEWLIB == 1 | ||
harness: net |
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.
The individual test section cannot be left empty so I was just wondering if we could set here for example some config option so that the harness setting could be removed.
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.
The individual test section cannot be left empty
Yes. I looked into that, pykwalify (following limitation of upstream kwalify scheme doesn't allow that, e.g. Grokzen/pykwalify#149).
The normal YAML syntax then would be: sample.net.sockets.big_http_download: {}
, but I considered that too magic for not YAML lawyers among us, and used
sample.net.sockets.big_http_download:
harness: net
as a placeholder.
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.
What about adding
extra_configs:
- CONFIG_POSIX_API=n
which is a "dummy" setting in this case, instead of the harness:net
?
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.
which is a "dummy" setting in this case, instead of the harness:net
I can do that, but are you sure it will be improvement? (I'd use CONFIG_NET_SOCKETS_POSIX_NAMES=y
then however, to show what we test with, not what without.)
a74d533
to
28d9268
Compare
68d2240
to
66ed8b3
Compare
@pfalcon could you please fix the CI failures here? |
I'm trying, I'm trying. @vanti, there's a problem with http_get sample and cc3220sf_launchxl. One of cc3220sf_launchxl components forcibly defines CONFIG_POSIX_API, which should never happen, as it's app-level option. If you need just one of POSIX subsystems, like Pthreads, then please vote up #12965 and help implement it. Here, trying to define CONFIG_POSIX_API behind the app's back leads to array of issues: it's incompatible with CONFIG_NET_SOCKETS_POSIX_NAMES=y which the app already selects, any socket offloading implementation is incompatible with POSIX subsystem, because of technical debt in socket offloading subsystem (it should utilize fdtable sub-subsys to be baseline-compatible with POSIX subsys). So, let's discuss way forward with this (please include @rlubos and @mike-scott who are other stakeholder in offloading). In the meantime, I see no other choice as to blacklist cc3220sf_launchxl from this sample. |
With CONFIG_POSIX_API enabled, these samples now build under Zephyr with exactly the same source as e.g. Linux (or in general, other POSIX systems). However, building without CONFIG_POSIX_API (i.e. with CONFIG_NET_SOCKETS_POSIX_NAMES aux option) is retained for now. Add testcase definitions to build these samples with CONFIG_POSIX_API in CI. Fixes: zephyrproject-rtos#17353 Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
66ed8b3
to
7b52e12
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.
@pfalcon this looks ok to me.
I noticed, in some sample .yaml files you have applied a filter expression starting with "and not" - I think you could skip the initial "and", right?
PR zephyrproject-rtos#18780 introduces a way to decouple pthread support from the general CONFIG_POSIX_API global switch. This commit modifies the build of SimpleLink components to take advantage of it, since SimpleLink libraries only require pthread (and sem) support, not entire POSIX. This fixes the build errors in the http_get sample introduced by the merge of zephyrproject-rtos#18736. Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
PR zephyrproject-rtos#18780 introduces a way to decouple pthread support from the general CONFIG_POSIX_API global switch. This commit modifies the build of SimpleLink components to take advantage of it, since SimpleLink libraries only require pthread, sem, clock, and sleep support, not entire POSIX API. This fixes the build errors in the http_get sample introduced by the merge of zephyrproject-rtos#18736. As such, this patch also removes cc3220sf_launchxl exclude from sample.yaml of that sample. Signed-off-by: Vincent Wan <vincent.wan@linaro.org> Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Build errors were introduced by the merge of zephyrproject-rtos#18736. Until PR zephyrproject-rtos#18780 is approved to allow the SimpleLink libraries to build without CONFIG_POSIX_API, this patch excludes cc3235sf_launchxl from the test build. Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
PR zephyrproject-rtos#18780 introduces a way to decouple pthread support from the general CONFIG_POSIX_API global switch. This commit modifies the build of SimpleLink components to take advantage of it, since SimpleLink libraries only require pthread, sem, clock, and sleep support, not entire POSIX API. This fixes the build errors in the http_get sample introduced by the merge of zephyrproject-rtos#18736. As such, this patch also removes cc3220sf_launchxl exclude from sample.yaml of that sample. Signed-off-by: Vincent Wan <vincent.wan@linaro.org> Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
PR #18780 introduces a way to decouple pthread support from the general CONFIG_POSIX_API global switch. This commit modifies the build of SimpleLink components to take advantage of it, since SimpleLink libraries only require pthread, sem, clock, and sleep support, not entire POSIX API. This fixes the build errors in the http_get sample introduced by the merge of #18736. As such, this patch also removes cc3220sf_launchxl exclude from sample.yaml of that sample. Signed-off-by: Vincent Wan <vincent.wan@linaro.org> Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
With CONFIG_POSIX_API enabled, these samples now build under Zephyr
with exactly the same source as e.g. Linux (or in general, other POSIX
systems). However, building without CONFIG_POSIX_API (i.e. with
CONFIG_NET_SOCKETS_POSIX_NAMES aux option) is retained for now.
Add testcase definitions to build these samples with CONFIG_POSIX_API
in CI.
Fixes: #17353
Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org