Skip to content

Conversation

@aescolar
Copy link
Member

@aescolar aescolar commented Dec 19, 2025

Ensure we call into the host C library open/close/read/write independently of which embedded C library the code is built with.

We do this by:
a) Using the native simulator nsi_host* trampolines when we just want to call straight into the host libC.
b) Building in the native_simulator runner context (and therefore with the host C library) two functions which we call from the embedded side.

&

tests/subsys/modem/backends/tty: Ensure it is built with proper C lib

This test itself (not the code under test) needs to be build with the host C library as it calls into its open/close/read/write APIs.
So let's ensure we build it with it, independently of what the default C library may be.

Note there is minor functional change, the code before would block during polls during 100ms and then wait 100ms until the next poll. Now it does not block during polls (it just checks and returns immediately) and then waits 100ms.

@aescolar aescolar marked this pull request as ready for review December 19, 2025 15:36
@zephyrbot zephyrbot added area: Modem area: Tests Issues related to a particular existing or missing test labels Dec 19, 2025
@aescolar aescolar requested a review from tpambor December 19, 2025 15:38
Ensure we call into the host C library open/close/read/write
independently of which embedded C library the code is built with.

We do this by:
a) Using the native simulator nsi_host* trampolines when we just want
   to call straight into the host libC.
b) Building in the native_simulator runner context (and therefore with
   the host C library) two functions which we call from the embedded
   side.

Signed-off-by: Alberto Escolar Piedras <[email protected]>
This test itself (not the code under test) needs to be build with the
host C library as it calls into its open/close/read/write APIs.
So let's ensure we build it with it, independently of what the
default C library may be.

Signed-off-by: Alberto Escolar Piedras <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 20, 2025

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@aescolar
Copy link
Member Author

The last push was just to please SonarCloud

CONFIG_MODEM_MODULES=y
CONFIG_MODEM_BACKEND_TTY=y

CONFIG_EXTERNAL_LIBC=y
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I am missing something but shouldn't this already be the default for native_sim?

default EXTERNAL_LIBC if NATIVE_BUILD && !NATIVE_LIBC_INCOMPATIBLE

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

Labels

area: Modem area: Tests Issues related to a particular existing or missing test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants