-
Notifications
You must be signed in to change notification settings - Fork 2k
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
tests/gnrc_udp: reimplement using sys/optparse. #11400
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a generic command line parser that can be used by shell commands. This is **NOT** getopt.
- Turn macros into functions - Use DEVELHELP instead of DEBUG - Use typedefs. - Add some more comments.
The previous code wuld not accept constant argv.
LOAD_VAR renamed to LAZY_LOAD (because it loads lazily) Moved variable declarations closer to where they are used.
Unnecessary for microcontrollers, many will not even have support for it. Also saves space in the opt_rule_t structure (it was the only 8 byte member).
The handling of positional arguments was completely reworked. Also, the command line format can now be completely specified in read-only memory and initialized via static macros.
These changes produce a small but noticeable decrease in code size.
Show how optparse can be used in an existing code.
Parsers are not for validation. They are for parsing.
jcarrano
added
Area: tests
Area: tests and testing framework
Type: new feature
The issue requests / The PR implemements a new feature for RIOT
State: waiting for other PR
State: The PR requires another PR to be merged first
State: demonstrator
State: This PR (loosely) demonstrates a concept and is not necessarily meant to be merged.
labels
Apr 15, 2019
Since the dependency PR got closed, do you think this PR should also be closed? |
I think this is a yes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area: tests
Area: tests and testing framework
State: demonstrator
State: This PR (loosely) demonstrates a concept and is not necessarily meant to be merged.
State: waiting for other PR
State: The PR requires another PR to be merged first
Type: new feature
The issue requests / The PR implemements a new feature for RIOT
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contribution description
Some time ago I wrote #9538 but it was lacking an example of how it can be used. Now, inspired by #11357 , I present the "optparse version" of tests/gnrc_udp.
For more information, see #9538
Testing procedure1
The module is tested in the original PR. The goal of this is just to show how code looks like when it uses sys/optparse.
Issues/PRs references
Depends on #9538.