-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
twister: Add support for required snippets #61111
Conversation
@JordanYates Is this sort of what you were asking for? I don't see much use for it with the |
@JordanYates ping |
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.
Generally it looks good. What do you mean by failing instantly on cdc-acm-console
?
We would probably also need an additional twister arg to add snippet roots as well.
It emits a build warning when USB CDC is enabled and logging is also enabled from https://github.com/zephyrproject-rtos/zephyr/blob/main/subsys/usb/device/class/cdc_acm.c#L63 and this will fail by default in twister |
d9dc6c8
to
a273402
Compare
56da98d
to
fb24b48
Compare
a688bc8
to
8992224
Compare
8992224
to
a692c8f
Compare
@@ -160,6 +160,10 @@ Build system and infrastructure | |||
|
|||
* Added support for CodeChecker | |||
|
|||
* Twister now supports ``required_snippets`` in testsuite .yml files, this can | |||
be used to include a snippet when a test is ran (and exclude any boards from |
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.
... when a test is run
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.
Do we have someone using this feature in the tree? Would be great to have some tests using this.
Not in tree other than the twister test cases no, the problem is that the only snippet in tree is the USB CDC console one which emits a build warning for a lot of boards because it reduces the USB log level, and when ran in twister that fails the build immediately |
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.
A minor request for logging level. The other comment is a general question, as I'd like to understand the logic there. When I added cdc-acm-console to hello_world sample it seemed to work as I got extra OUTPUT: uart connected to pseudotty: /dev/pts/4
in the output.
if len(found_snippets[this_snippet].appends) > 0: | ||
continue |
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 you explain these lines? I think I don't follow. While debugging I see that cdc-acm-console
has len(found_snippets[this_snippet].appends)
= 2 hence continuing, i.e. ignoring the rest of the logic, where it is decided if a matching board was found
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.
This checks if it is a global snippet i.e. applies to all boards, or if it only applies to some boards, see https://docs.zephyrproject.org/latest/build/snippets/writing.html#by-name for an example
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.
Looks like a good feature and no objections to the idea. One minor naming suggestion, nonblocking.
scripts/snippets.py
Outdated
@@ -238,6 +238,22 @@ def process_snippets(args: argparse.Namespace) -> Snippets: | |||
|
|||
return snippets | |||
|
|||
def process_snippets_inter(requested_snippets, snippet_roots) -> Snippets: |
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 this would be better named find_snippets_in_roots
or something like that. I had a hard time guessing what process_snippets_inter
meant when I first saw it earlier in the patch.
ok, who is using this feature then and how? I am trying to understand the usecase here and this and it would help if we have a user in-tree beside the unit test. |
It was a feature requested by @JordanYates from the original implementation PR. Currently there cannot be an in-tree usage of this because there is only one in tree snippet, but as time passes and more snippets are added, then it would be a good fit for having usage by tests/samples in tree. |
I realized you forgot to add "required_snippets" to the schema for a common section. Adding this entry in common causes
|
maybe it is time to add more snippets, software only, i.e. something that can be used as an example without dependency on hardware, I just added commit 3f3374bbb96a2a84984905e7f934385400801bd4 (HEAD -> twistersnippets)
Author: Anas Nashif <anas.nashif@intel.com>
Date: Tue Aug 29 12:03:29 2023 +0000
debug snippet
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
diff --git a/snippets/debug/debug.conf b/snippets/debug/debug.conf
new file mode 100644
index 0000000000..53c5adaac3
--- /dev/null
+++ b/snippets/debug/debug.conf
@@ -0,0 +1,5 @@
+CONFIG_DEBUG=y
+CONFIG_THREAD_NAME=y
+CONFIG_THREAD_ANALYZER=y
+CONFIG_THREAD_ANALYZER_AUTO=y
+CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
diff --git a/snippets/debug/snippet.yml b/snippets/debug/snippet.yml
new file mode 100644
index 0000000000..9c6d9e78a0
--- /dev/null
+++ b/snippets/debug/snippet.yml
@@ -0,0 +1,3 @@
+name: debug
+append:
+ EXTRA_CONF_FILE: debug.conf and used this with you PR, and it works fine. |
a692c8f
to
e788e7b
Compare
Adds support for twister to require using snippets on tests Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds 2 tests which check required_snippet functionality works. Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds a note that twister now supports applying snippets Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds information on the new required_snippets feature Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
e788e7b
to
933d26b
Compare
@@ -145,6 +145,11 @@ mapping: | |||
matching: "all" | |||
sequence: | |||
- type: str | |||
"required_snippets": |
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.
might it be just snippets
? or are there other types of snippets possible e.g. 'optional'. If so, then shouldn't it be snippets_required
to follow the naming convention here ?
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 "required" part is to make it clear that the test will only run with them. I don't envisage having support for optional snippets, they will either be required and applied or not available and test will not run
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.
still do not see of example usage in zephyr, but thats fine, I can add this as a followup.
Adds support for twister to require using snippets on tests