Skip to content
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

Merged
merged 1 commit into from
Aug 30, 2019

Conversation

pfalcon
Copy link
Contributor

@pfalcon pfalcon commented Aug 28, 2019

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

@pfalcon
Copy link
Contributor Author

pfalcon commented Aug 28, 2019

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.

Copy link
Member

@jukkar jukkar left a 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
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

and here

@pfalcon pfalcon force-pushed the samples-sockets-posix branch from c6e2f19 to a74d533 Compare August 28, 2019 12:16
tests:
sample.net.sockets.http_get:
harness: net
sample.net.sockets.http_get.posix:
filter: TOOLCHAIN_HAS_NEWLIB == 1
harness: net
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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.)

@jukkar jukkar closed this Aug 29, 2019
@jukkar jukkar reopened this Aug 29, 2019
@ioannisg
Copy link
Member

@pfalcon could you please fix the CI failures here?

@pfalcon
Copy link
Contributor Author

pfalcon commented Aug 29, 2019

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>
Copy link
Member

@ioannisg ioannisg left a 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?

@pfalcon
Copy link
Contributor Author

pfalcon commented Aug 29, 2019

@pfalcon this looks ok to me.

Thanks.

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?

Please see #18770. In short, as of now it's required, but hopefully we'll fix that.

@ioannisg ioannisg merged commit 5eb974d into zephyrproject-rtos:master Aug 30, 2019
vanti added a commit to vanti/zephyr that referenced this pull request Aug 30, 2019
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>
pfalcon pushed a commit to pfalcon/zephyr that referenced this pull request Sep 3, 2019
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>
vanti added a commit to vanti/zephyr that referenced this pull request Sep 9, 2019
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>
jukkar pushed a commit that referenced this pull request Sep 10, 2019
Build errors were introduced by the merge of #18736. Until PR #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>
pfalcon pushed a commit to pfalcon/zephyr that referenced this pull request Sep 11, 2019
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>
galak pushed a commit that referenced this pull request Sep 26, 2019
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuring with POSIX_API disables NET_SOCKETS_POSIX_NAMES
4 participants