-
Notifications
You must be signed in to change notification settings - Fork 59
add User space test cases #363
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
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.
To save a lot of review time, please run shellcheck -x locally before submitting and start all scripts with set -e (see #312)
xiulipan
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.
Please remove the install code part and update other checks.
@xiulipan @marc-hb Thanks for raise this discussion. When I developed the check-userspace-packages test case at first, I did put it in sof-sh repo. From logic view, this should be put in sof-sh repo. However, I met some issues when I was trying to install the packages in sof-sh.
|
|
@libinyang Please split set up test device and test scripts.
Please try to set up a sync up meeting for this at any time you prefer |
|
|
It seems 2 vs 1 to prefer to put it into the sof-sh. OK. I will move it into sof-sh.
No, pulseaudio will conflict with other driver test cases. So I setup 2 CI DUT dedicated for user space test.
Build machine is different from the DUT. So we won't test the dependencies when building the packages on DUT. I use the debian code to build the alsa lib based on your suggestion.
Based on Mengdong's requirement, this is used to test the upstreamed code. We will use this to make sure the latest alsa lib, pulseaudio and UCM won't break our Intel platform.
Yes, this is why we add the user space test case. Actually, the kernel change may cause UCM error, which will cause user space totally not work. I met such issue before. The user space test cases are not finished. I will submit another 2 test cases today of paplay and parecord. |
Is this closed source location where the code to build the packages is right now? In thesofproject/linux#2211 I shared a (pretty small), open-source prototype that anyone can use to rebuild alsa-lib packages.
I spent some more time trying the
Both systems should be Ubuntu 20.04 configured similarly so I don't understand which dependencies could be different, can you share an example? SOF developers shouldn't have to use more than one system. They can but they shouldn't have too. thesofproject/linux#2402 (comment)
Please write down and submit for review these test cycle and release requirements before submitting the corresponding code. I understand we don't want to wait for official ALSA releases but don't think we want to test every single ALSA commit either, do we? |
It is closed source location, in sof-sh repo. Not sure to attach the code address here is OK?
I didn't mean the conflict of using
I don't have example here. But no example doesn't mean there will never be dependency issues, right? With the pulseaudio updated, it may require the related application's upgrade. If you try to install the latest pulseaudio on ubuntu 18.04, I believe you will meet such issue. However, we don't need to take too much effort on it now, this should not be our priority task. And if we really meet such issue, I think we can manually update the system.
My plan is to test the user space package once every week. Do you think this test frequency is OK? Xiuli talked to me before that we can change to test every single commit. |
0e67009 to
e8bdc53
Compare
|
update:
|
Hopefully not when disabled with
So a separate build system is solving a problem we don't know we have and that we haven't tried to solve yet...
That seems reasonable to me but it should be discussed with more people. To keep that particular discussion focused it shouldn't be diluted in this PR or in 2211. Instead it should be submitted as focused, documentation PR. You could also start a new topic at https://github.com/orgs/thesofproject/teams/sof-developers |
|
a separate patch to deploy the user space packages patch has been submitted in sof-sh repo as Marc and Xiuli's feedback. |
I checked the sof-sh. Currently we will remove pulseaudio. So it will not impact on our other DUTs in CI. |
plbossart
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.
let's be careful about licenses please?
|
patch updated:
|
xiulipan
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.
Could we merge the playback and capture test later? I think we only need some parameter to split playback and catpure.
Sure. We can talk about it in detail. |
case-lib/lib.sh
Outdated
| return 1 | ||
| fi | ||
|
|
||
| return 0 |
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.
If something goes wrong&>/dev/null will hide it. This is test code, never, ever redirect stderr and hide errors. Redirecting stdout to a log file is useful when it's big. This is not big.
The fewer negations and the more readable. Negations with ! are especially annoying because they cannot be copied to the interactive shell.
pactl stat || {
dloge ...
return 1
}return 0 is useless most of the time. It is useless here, remove it.
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.
In the test cases, why do we care the interactive shell?
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.
In my new patch, I will use :
pactl stat &>dev/null || {
dloge ...
return 1
}
I still use "&>dev/null" because error message pactl stat doesn't show explicit information that pactl stat fails. It doesn't help for developer to identity which fails quickly. Instead, I will use dloge to export the useful information for sof-test developer.
|
|
||
| # check pulseaudio runs properly or not | ||
| if ! func_lib_check_pa; then | ||
| die "Please check whether pulseaudio runs correctly or not" |
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.
See above, no need for a negation.
| ## Expect result: | ||
| ## There is at least one available card for test | ||
| ## | ||
|
|
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.
Use set -e in every new test (old tests are being converted too)
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.
grep will fail if set -e.
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.
try grep ABC || true
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.
See detailed set -e guidelines in #312
| OLDIFS=$IFS | ||
| dlogc "pactl list cards short" | ||
| cardlist=$(pactl list cards short) | ||
| ((available_card=0)) |
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 bashism not compatible with set -e. Change to the POSIX standard
: $((available_card=0))https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04
| dlogi "found card: $(echo "$card" | awk '{print $2}')" | ||
| usbcard=$(echo "$card" |grep "[Uu][Ss][Bb]") | ||
| if [ -z "$usbcard" ]; then | ||
| ((available_card++)) |
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.
See above
test-case/check-userspace-paplay.sh
Outdated
| rate=${OPT_VALUE_lst['R']} | ||
| channel=${OPT_VALUE_lst['C']} | ||
|
|
||
| if [[ ! -e $file ]]; 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.
Avoid negations
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.
| if [[ ! -e $file ]]; then | |
| [[ -e $file ]] || (dlogw "$file does not exist, use /dev/zero as dummy playback source" && file=/dev/zero ) |
test-case/check-userspace-paplay.sh
Outdated
| sinkkeys=$(pactlinfo.py --showsinks) | ||
| for round in $(seq 1 $round_cnt); do | ||
| for i in $sinkkeys; do | ||
| if ! sinkcard=$(pactlinfo.py --getsinkcardname "$i"); 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.
negation
| ## 1. run pactl to get the cards info | ||
| ## 2. check the card name | ||
| ## Expect result: | ||
| ## There is at least one available card for test |
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 see what this test achieves. Other tests also check that pulseaudio is functional and they should also fail if zero card is found so I think this test can be removed.
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.
there are several cards and we only care sof cards. Other user space test cases won't check it and return correctly.
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.
Other user space test cases won't check it and return correctly.
This is wrong, all tests that need an sof card to test should either FAIL or SKIP (exit 2) when there is no SOF card. A test should never return PASS after testing nothing.
xiulipan
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.
Please apply some suggestion from marc and run spellcheck for advice.
PS: we may take tare about scripts from other repo
If it is just some string handler and conversion, maybe write a version by our self is better.
test-case/check-userspace-paplay.sh
Outdated
| rate=${OPT_VALUE_lst['R']} | ||
| channel=${OPT_VALUE_lst['C']} | ||
|
|
||
| if [[ ! -e $file ]]; 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.
| if [[ ! -e $file ]]; then | |
| [[ -e $file ]] || (dlogw "$file does not exist, use /dev/zero as dummy playback source" && file=/dev/zero ) |
|
patch updated:
|
| ## Expect result: | ||
| ## There is at least one available card for test | ||
| ## | ||
|
|
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.
try grep ABC || true
| # pactl list cards short format should be like: | ||
| # 0 alsa_card.pci-0000_00_1f.3-platform-sof_sdw module-alsa-card.c | ||
| dlogi "found card: $(echo "$card" | awk '{print $2}')" | ||
| echo "$card" |grep "[Uu][Ss][Bb]" &>/dev/null || ((available_card++)) |
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.
| echo "$card" |grep "[Uu][Ss][Bb]" &>/dev/null || ((available_card++)) | |
| echo "$card" |grep -i usb &>/dev/null || ((available_card++)) |
So we will ignore the USB card 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.
yes. USB is not our scope
| dlogc "pactl list cards short" | ||
| cardlist=$(pactl list cards short) | ||
| ((available_card=0)) | ||
| IFS=$'\n' |
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.
https://unix.stackexchange.com/questions/275794/iterating-over-multiple-line-string-stored-in-variable
echo "$variable" | while IFS= read -r line ; do echo $line; done
| rate=${OPT_VALUE_lst['R']} | ||
| channel=${OPT_VALUE_lst['C']} | ||
|
|
||
| [[ -e $file ]] || { dlogw "$file does not exist, use /dev/zero as dummy playback source" && file=/dev/zero; } |
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.
capture should use dev/null as dummy file to write into.
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.
good catch. Thanks. Fixed in the latest update
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.
https://unix.stackexchange.com/questions/275794/iterating-over-multiple-line-string-stored-in-variable
echo "$variable" | while IFS= read -r line ; do echo $line; done
I don't why: if I use this such while xxx, the 'available_card' seems to be changed locally and it will remain to 0 out of the loop. So I still keep the original code.
| } | ||
|
|
||
| # Let's skip testing on USB card | ||
| if echo "$sourcecard" |grep "[Uu][Ss][Bb]" &>/dev/null; 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.
grep -i usb is enough
PS: do we need a ignore list or filter list? Three will also be legacy HDA card and other graphic HDMI card.
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 added a "TODO" for the filter list. Currently we don't meet such platform. How about we implement it when we meet such platforms?
Add the helper function to check whether pulseaudio runs properly or not. Signed-off-by: Libin Yang <libin.yang@intel.com>
|
patch updated to add |
Check the pulseaudio card info to make sure the card is ready. Signed-off-by: Libin Yang <libin.yang@intel.com>
Add the tool pactlinfo.py to parse the pactl list information Signed-off-by: Libin Yang <libin.yang@intel.com>
This test case will go through all the sinks on the tested cards, and try to paplay it if the active port is not "not available" Signed-off-by: Libin Yang <libin.yang@intel.com>
This test case will go through all the sources on the tested cards, and try to parecord it if the active port is not "not available" Signed-off-by: Libin Yang <libin.yang@intel.com>
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.
In the test cases, why do we care the interactive shell?
It's often useful to copy/paste to the shell for interactive testing. Anyway that is not the main point: it's just good practice to avoid negations because they require a little bit more reading/review effort. Avoid negations as a good practice also tends to avoid double negations (e.g: if ! nocodec_cmode ) which require even more reading effort for no value. I don't think I would not approve a PR just because of negations (see what I just did?)
I don't why: if I use this such while xxx, the 'available_card' seems to be changed locally and it will remain to 0 out of the loop. So I still keep the original code.
Please try to debug this, "I don't why it does not work" is not acceptable. If you can isolate and reproduce in a small function then share that function and I will debug it.
| ## Expect result: | ||
| ## There is at least one available card for test | ||
| ## | ||
|
|
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.
See detailed set -e guidelines in #312
| ## 1. run pactl to get the cards info | ||
| ## 2. check the card name | ||
| ## Expect result: | ||
| ## There is at least one available card for test |
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.
Other user space test cases won't check it and return correctly.
This is wrong, all tests that need an sof card to test should either FAIL or SKIP (exit 2) when there is no SOF card. A test should never return PASS after testing nothing.
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.
I still use "&>dev/null" because error message pactl stat doesn't show explicit information that pactl stat fails. It doesn't help for developer to identity which fails quickly. Instead, I will use dloge to export the useful information for sof-test developer.
-
pactl error messages can be googled. So even when they're really really bad (which I suspect is rare), they are still useful because the reader can very quickly see what command failed: a pactl command.
-
If you think some pactl error message is really bad then feel free to ADD your own message but keep the original pact message too.
-
Last but not least: how can you even know in advance all the possible error messages that this pactl command will produce? Did you read the entire pactl source code? People look at test logs only when something unexpected happened, do you have a complete list of all the unexpected things that can happen?
Never, ever discard stderr, period.
Don't discard stdout either before it has become an actual annoyance. Even in that case it's best to redirect it to a file.
This is test code here, we're not trying to build slick iPhone interfaces. No one looks at test logs unless the tests fail. When tests fail people need and want as much original and googlable information as possible, they absolutely do not want alternative error messages hiding the original messages. No one care about "beautiful" test logs.
|
Can you please start a new PR? This one is overloaded with many comments that don't apply any more. Please also run We don't have a defined policy for formatting python code but I recommend |
Answer from Google shows: When you pipe into a while loop in Bash, it creates a subshell. |
Do we need to understand entire source code when we use the tool? Sorry, I'm surprised to know that. What I think is that we and the user don't need to debug the pactl, pulseaudio tools. So I don't export all the error message to users. When I hide the error message, I don't say the error message is useless. The error message is useful to root cause why |
Sure, I will create a new PR later.
Good suggestion. I will try this tool.
Sorry, I don't understand |
Just find |
|
open a new thread #479 and close this one |
There are a number of ways to solve this: https://mywiki.wooledge.org/BashFAQ/024 See process substitution example in
apt-get install black
No, that page does not "recommend" this format because that page is about
https://github.com/koalaman/shellcheck/wiki/SC2164 https://mywiki.wooledge.org/BashPitfalls#cd_.2Ffoo.3B_bar Code reviews include both required changed and not required changes, "avoid" negations is not required change, it's general advice to make your submissions easier and faster to review.
I added detailed guidelines and some tips in #312. If that's not enough for some reason please ask me for help. I think this is very important so I will prioritize it. |
Only if you discard stderr. Don't discard stderr if you don't want to have to understand the whole
You've seen ONE error message in one situation and you're wrongly assuming pactl has no other error message. The entire purpose of test code is to find as many errors as possible in as many places and situations as possible so considering only "the" one error message you've seen so far makes no sense.
This PR was named "add user space test cases" yet you would do not want to observe and try to understand some unexpected pactl failure?!
Especially for test code yes: it is a "good idea" to never discard stderr except in some extremely rare (and well justified) cases. In fact it's absolutely critical for test code. The user interface of test code is the exact opposite of the user interface of an iPhone: it has to be 100% transparent so users can totally and immediately see through absolutely everything it does. Users look at test logs ONLY when something unexpected happened and then they want to minimize guessing time as much as possible. Such complete transparency is even more important when running in CI because it's often difficult to reproduce issues in different environment with no ability to interact directly. |
Only one day later here's one example why sof-test should be as close as possible to interactive commands : #495 (comment) |
This patches add the test cases for user space.
It includes: