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

native: add option to turn RIOT into a Linux CLI tool #20656

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented May 7, 2024

Contribution description

To better integrate RIOT into some automated tests, it can be useful to run commands in a one-shot fashion.
This allows to use RIOT shell commands like Linux applications and integrate them into other tooling so e.g. Linux servers that interact with RIOT can be tested using a fixed RIOT binary.

Testing procedure

First create a TAP bridge with an (optional) uplink:

sudo dist/tools/tapsetup/tapsetup -u enxf4a80d90ba50

We can ping a host from RIOT

bin/native/nanocoap_tool.elf tap0 ping riot-os.org
12 bytes from 2a01:4f9:1a:9508::1: icmp_seq=0 ttl=57 time=58.149 ms
12 bytes from 2a01:4f9:1a:9508::1: icmp_seq=1 ttl=57 time=58.647 ms
12 bytes from 2a01:4f9:1a:9508::1: icmp_seq=2 ttl=57 time=58.381 ms

--- riot-os.org PING statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 58.149/58.392/58.647 ms

We can also access CoAP servers

bin/native/nanocoap_tool.elf tap0 ncget coap://coap.me/
/test
/validate
/hello
/blåbærsyltetøy
/sink
/separate
/large
/secret
/broken
/weird33
/weird44
/weird55
/weird333
/weird3333
/weird33333
/123412341234123412341234
/location-query
/create1
/large-update
/large-create
/query
/seg1
/path
/location1
/multi-format
/3
/4
/5

Issues/PRs references

@benpicco benpicco requested a review from kaspar030 as a code owner May 7, 2024 17:45
@github-actions github-actions bot added Platform: native Platform: This PR/issue effects the native platform Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: sys Area: System Area: examples Area: Example Applications labels May 7, 2024
@benpicco benpicco changed the title Native tool native: allow to run RIOT shell commands like native Linux commands May 7, 2024
@benpicco benpicco changed the title native: allow to run RIOT shell commands like native Linux commands native: add option to turn RIOT into a Linux CLI tool May 7, 2024
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 7, 2024
@riot-ci
Copy link

riot-ci commented May 7, 2024

Murdock results

✔️ PASSED

51a6a84 examples/nanocoap_tool: add RIOT as a CLI tool

Success Failures Total Runtime
10109 0 10109 14m:42s

Artifacts

@Teufelchen1
Copy link
Contributor

Cool idea! How about making it behave like busybox? ./ncget == ./nanocoap_tool.elf ncget?

I dislike that there is a new example that does not really have value as it - add the very least add a README! I am also surprised it is nanocoap specific? While coap is a good example use case, the example itself is more "riot as cli tool" and should be presented as such.

@benpicco
Copy link
Contributor Author

benpicco commented May 8, 2024

I agree that the example needs to be more fleshed out, this is a bit specific to the 'send arbitrary CoAP payloads as a RIOT node would' use case, but not sure what else I should include.

@github-actions github-actions bot added Platform: MSP Platform: This PR/issue effects MSP-based platforms Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: network Area: Networking Area: doc Area: Documentation Area: tests Area: tests and testing framework labels May 15, 2024
@github-actions github-actions bot added Area: build system Area: Build system Area: pkg Area: External package ports Area: drivers Area: Device drivers Platform: ESP Platform: This PR/issue effects ESP-based platforms Area: CoAP Area: Constrained Application Protocol implementations Area: Kconfig Area: Kconfig integration labels May 15, 2024
@github-actions github-actions bot removed Platform: MSP Platform: This PR/issue effects MSP-based platforms Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: network Area: Networking Area: doc Area: Documentation Area: tests Area: tests and testing framework Area: build system Area: Build system Area: pkg Area: External package ports Area: drivers Area: Device drivers Platform: ESP Platform: This PR/issue effects ESP-based platforms Area: CoAP Area: Constrained Application Protocol implementations Area: Kconfig Area: Kconfig integration labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: cpu Area: CPU/MCU ports Area: examples Area: Example Applications Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: native Platform: This PR/issue effects the native platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants