-
Notifications
You must be signed in to change notification settings - Fork 2.1k
doc/rdm: RDM on a common api for testing #10624
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
Conversation
e3732fd
to
477d0c1
Compare
This is the initial commit of Guidelines for Write Firmware to Expose RIOT APIs RDM. It attempts to standardize some semantics for firmware written in tests.
477d0c1
to
f03a630
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.
Some comments regarding the output format.
information | ||
- [data] should be optional | ||
- [data] if used, may be provided several times | ||
- [data] should be actionable and adhere to pythons |
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.
Why not use something compatible with JSON?
a. There is code to generate that already
b. You don't tie the receiving end to python.
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.
I like the idea, if I use standard json do I need to know the full frame? I would worry more about the coordination the messages need.
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 I'm assuming you are going to put a single [data] element per line. If that is not the case, it is not a problem either, because json can be parsed from a stream (meaning you could pretty format the [data] into multiple lines.)
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.
Ok, can we say a either json compatible line or generic string which defaults to the [msg] form? I will update the examples.
- [msg] should be optional | ||
- [msg] if used, may be provided several times | ||
- [msg] should not be actionable and only contain debug/log | ||
information |
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.
I think that "[msg] should not start with {" and data should. That way it is unambiguous.
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 reason for this is a mechanism to catch anything that shouldn't be formatted. This way not data can be missed.
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.
Ok, but how do you differentiate between data and message. Another option is to say that anything that cannot be successfully parsed as data is a message.
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.
Agreed that's what I will do!
- [data] if used, may be provided several times | ||
- [data] should be actionable and adhere to pythons | ||
ast.literal_eval formatting | ||
- [result] should only be provided once for each command |
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.
"At most once" or "exacly once"?
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.
Exactly, I will update! It is used to end the message so we don't have to wait for timeouts.
- [cmd] should only be provided once for each command | ||
- [cmd] should allow the user to reproduce the step, this may be the | ||
API/function call with the variables or a descriptive name for a set of calls | ||
- [msg] should be optional |
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.
Instead of writing so much text, you could roughly specify the grammar of the response:
response := message* data* result
message := MESSAGE_CONTENTS EOL
data := <json> EOL
result := "{" "'result'" ":" RESULT_VALUE "}" EOL
EOL := '\n'
MESSAGE_CONTENTS := ([^{].+)?
RESULT_VALUE := (SUCCESS) | (ERROR)
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.
Can I have both? I will add that in.
Thanks @jcarrano, that is a very useful review! |
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.
Thanks a lot for addressing this! I don't have much to say for now because IMO agreeing on any structured format would already be an improvement. Minor things I noticed below.
- Tests should have a `get_metadata` command | ||
- The `get_metadata` command should contain at least board name, and | ||
application name | ||
- Tests should have a `echo <random 8 hex digits>` command |
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 commands get_metadata
and echo
should probably just be implemented once and then be included in all tests that provide the interface specified by this RDM
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.
Yup, I will try to implement something, I suppose it would be like the ps/reboot/ect. where you can just include it so there will be no code duplication.
## Abstract | ||
|
||
In order to improve the testing and interface tools for RIOT a standard way of | ||
exposing API calls to a higher level should be defined. This document describes |
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.
exposing API calls to a higher level
Can this be rephrased to directly state that this is talking about a shell interface that gives access to a RIOT firmware? A higher level is somewhat ambiguous in this sentence and IMO it is worth to mention that this is talking about tools that are running outside of an RIOT instance.
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.
YES: It will be really helpful to make the context and subject of consideration crisply clear so that the reader understands right away what to expect from this memo.
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.
Ditto, NB that "exposing API calls" generally refers to a module exposing functions for use outside itself in a software program - it wouldn't really imply "allowing a human to use those functions through a user interface"
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.
OK, I will try to rephrase it in a clearer way.
My initial thoughts are that the way these rules are specified would make applying them quite onerous for developers: they would have to go through all bullet points one by one. Perhaps a format such as a commented template (or maybe condensing and structuring them somewhat) would make it easier for people to use (and more likely for it to get used therefore). |
Also, is there any scope for this document to take into account other aspects of testing? For example, when things should be unit tested using embunit or have CLI tests written using testrunner, and the kind of test coverage that's expected? Or outlining what our eventual/ideal CI strategy would be? The testing in general is very varied seemingly without strong common logic in what is tested and how, not just in the area of how tests are exposed through CLI output |
Can you show me what you mean, maybe give an example? |
The idea is it provides some standard to write to, it should only provide answers to the question of, for example, how should I format my data. It is not meant to cover all test cases only provide a standard for those tests that fit the criteria. Embunit seems like it is more for c unit tests not really requiring this and test runner could use this since it should make the parsing easier.
That is too large a scope for the document (that was how it started but was suggested to reduce the scope). This is useful regardless of the CI strategy but yes, it is intended to help with the CI development.
Yup, I want to only bite off what I can chew... It will be easier to get a consensus if we keep things simple and obviously beneficial. Other standardization/guidelines/templates can also come later. |
Maybe presenting the details of [msg data result] etc would look better in a table. On second look the spec is probably too generic to provide a single template although the code examples help. In general some other way of presenting than a long list of bullet points would be good. Potentially breaking up the points into subsections, or enumerating them, or using tables might help break it up/give it some high level structure to make the points more easy to understand/digest/contextualise |
ok, understood |
printf("Getting several values for the api command\n") | ||
for (i = 0; i < amount_of_api_calls; i++) { | ||
data = get_data_api_command(i); | ||
prqintf("{\"data\": 0x%X}\n", data); |
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.
oops...
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
I am currently working on implementation of this. It will require an update but I don't think it will be forgotten! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
I think this is out of date and somehow a part of the turo + riotctrl. |
Contribution description
This is the initial commit of Guidelines for Write Firmware to Expose RIOT APIs RDM.
It attempts to standardize some semantics for firmware written in tests. This should allow easier parsing, sorting and filtering of useful information for tests and experiments. without negatively effecting other parts of RIOT. It's aim is to provide answers to simple questions of something like, what should I expect at the end of a test, "success", "Success", "SUCCESS", "PASS", "FAIL", "ERROR", "-1", "0". Something we can all agree upon and, if we adhere to it utilize the standardization for other things.