-
Notifications
You must be signed in to change notification settings - Fork 59
TinyAlsa: Add support for testing using tinycap and tinyplay. #1260
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
TinyAlsa: Add support for testing using tinycap and tinyplay. #1260
Conversation
f96d4e2 to
9029069
Compare
marc-hb
left a comment
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 is not scalable at all. It's adding support in only 2 tests and there's already a lot of copy/paste/diverge.
The non-duplicated way is to make aplay_opts into a smarter function that implements all the logic in only one place.
9029069 to
85a2007
Compare
8c7f825 to
1f8a70b
Compare
|
Avoid "spamming" the PR with force-pushes as this brings down limited hardware resources. |
also, shellcheck can be run locally, before push to PR. |
|
Don't forget the If you forget which option it is, just look in either the CI logs or in (there can also be drawbacks having everything in the same git repo, I digress) |
1f8a70b to
c36f283
Compare
|
@marc-hb @golowanow I've changed the approach according to your suggestions. Now, only the |
093579d to
19705a9
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.
Just a few minor issues left, otherwise looks good to me. Thanks for your persistence!
case-lib/lib.sh
Outdated
| pcm=$(func_pipeline_parse_value "$idx" pcm) | ||
| # shellcheck disable=SC2034 | ||
| type=$(func_pipeline_parse_value "$idx" type) | ||
| # shellcheck disable=SC2034 |
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 don't get this warning, are you sure?
If you are sure:
- add it only once right before the function and it will apply to whole function. No need to duplicate.
- Explain very briefly why it's disabled briefly before it. No one knows what SC2034 is by heart.
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.
SC2034 (warning): variable appears unused. Verify use (or export if used externally).
3a4e037 to
72aa384
Compare
6cee092 to
e122226
Compare
I still don't get it sorry. Anywhere you write: You can write instead: ... and the effect is the same - but with fewer indirections and complexity. (The environment variable can also be used in other ways that the wrapper can't do) |
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 still don't get it sorry.
Thanks @golowanow for the private discussion and explanation. Trying to summarize it here:
sof-test has always been invoked by an internal, higher level, Intel test framework that manages test plans and test runs. This framework has some shortcomings, probably the most important (and somewhat relevant here) being sof-framework/issues/602.
That framework does NOT allow environment variables when defining test plans. The interface only lets the user input a test script and script arguments. So, this wrapper script is a way to disguise and shoehorn an environment variable as a test script, sneaking the real test script as a parameter.
Considering this situation, I cannot think of any better to achieve what this wrapper does. BUT, I think the actual purpose of this script should be much clearer. So interactive users and better test frameworks do NOT start using it when they do not need to.
- The wrapper should not be called
check-tinyalsa.shwhich sounds like something good. It should be called something liketinyalsa-wrapper.sh. - The comments at the top of the wrapper should clearly state something like "This is a wrapper that allows to define SOF_ALSA_TOOL in frameworks that cannot define environment variables. Do not use this script if you can just define SOF_ALSA_TOOL.
- The "checking bits" are useful and a very different feature! They should be in a separate "check-tinyalsa.sh` script that performs ONLY the checks and that everyone can use. The former script can call the latter script.
e122226 to
b228706
Compare
I've moved this part to env-check script. |
0da0218 to
83aae71
Compare
|
@marc-hb Please take a look. |
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 keep finding issues sorry. I don't know which it is:
- I didn't see them before
- The code has changed
- I reported them before but my comments got "lost"
Nothing major.
case-lib/lib.sh
Outdated
| # While using TinyALSA (tinycap -b) we need to convert PCM sample fomrat to bits. | ||
| extract_format_number() { | ||
| # (e.g., extracting '16' from 'S16_LE') | ||
| format=$(printf '%s' "$1" | grep '[0-9]\+' -o) |
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.
format is a very common name for a global variable.
This function returns a single value so it could just print it instead and avoid a global?
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.
Fixed.
| dev=$(func_pipeline_parse_value "$idx" dev) | ||
| pcm=$(func_pipeline_parse_value "$idx" pcm) | ||
| type=$(func_pipeline_parse_value "$idx" type) | ||
| snd=$(func_pipeline_parse_value "$idx" snd) |
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.
That's a lot of global variables with very short names...
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 know, but I only moved this section from:
https://github.com/thesofproject/sof-test/pull/1260/files#diff-ac523ac7afa0a9a96eb0ee6c918c10f317d1b201b7124bf10bcf98b611b7324dL78
https://github.com/thesofproject/sof-test/pull/1260/files#diff-4c371b42f9f03814333bc7e33dce34faf542f27087fcf0b5702029f55f630edbL71
to an additional function in lib.sh file.
case-lib/lib.sh
Outdated
| aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS "$@" | ||
| if [[ "$SOF_ALSA_TOOL" = "tinyalsa" ]]; then | ||
| # shellcheck disable=SC2154 | ||
| if ! sox -n -r "$rate" -c "$channel" noise.wav synth "$duration" white; then |
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.
Indentation? Did you use tabs? I think Github does not like them (I don't either)
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.
True, Fixed.
case-lib/lib.sh
Outdated
| # shellcheck disable=SC2086 | ||
| aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS "$@" | ||
| else | ||
| printf '%s' "Unknown alsa tool: $SOF_ALSA_TOOL " |
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 should be fatal, using die or similar.
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.
Done.
case-lib/lib.sh
Outdated
| if [[ "$SOF_ALSA_TOOL" = "tinyalsa" ]]; then | ||
| # shellcheck disable=SC2154 | ||
| if ! sox -n -r "$rate" -c "$channel" noise.wav synth "$duration" white; then | ||
| printf '%s' "Error: sox command failed." >&2 |
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.
| printf '%s' "Error: sox command failed." >&2 | |
| printf 'Error: sox command failed.\n' >&2 |
or
| printf '%s' "Error: sox command failed." >&2 | |
| dloge 'Error: sox command failed." |
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.
Fixed.
case-lib/lib.sh
Outdated
|
|
||
| if [[ "$SOF_ALSA_TOOL" = "tinyalsa" ]]; then | ||
| # shellcheck disable=SC2154 | ||
| extract_format_number "$fmt_elem" |
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.
Could you add a comment explaining where $fmt_elem comes from? Shellcheck seems to make a good point here....
More global variables :-(
case-lib/lib.sh
Outdated
| # shellcheck disable=SC2086 | ||
| arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS "$@" | ||
| else | ||
| printf '%s' "Unknown alsa tool: $SOF_ALSA_TOOL " |
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.
Should be fatal using die or similar.
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.
Fixed.
| fi | ||
| done | ||
| elif [[ "$SOF_ALSA_TOOL" = "tinyalsa" ]]; then | ||
| tinymix -D0 controls | sed -e "s/^.*'\(.*\)'.*/\1/" |grep -E 'PGA|gain' | |
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.
Nit: later, it would be nice to de-duplicate the sed+grep bit with a function. No need to do it now.
83aae71 to
646120c
Compare
Add support for tinyALSA and update env-check and README file. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
Refactor Check-capture and Check-playback tests. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
Add tinyalsa-wrapper used to run any test with tinyAlsa testsets. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
646120c to
8c585a3
Compare
Added option
SOF_ALSA_TOOLto specify whether to use theTinyASLAorALSAtesting tool. For now, it is only for capturing and playback.The default tool is ALSA.
This PR introduces also a generic wrapper
tinyalsa-wrapper.shto defineSOF_ALSA_TOOLin environments where setting environment variables directly is not possible. This is useful for frameworks or systems with limited configuration capabilities.