Skip to content
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

[SKIP CI] Enable check-pause-release-suspend-resume.sh to automatically test all PCMs #760

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[SKIP CI] Enable check-pause-release-suspend-resume.sh to automatically test all PCMs #760

wants to merge 3 commits into from

Conversation

1994lwz
Copy link

@1994lwz 1994lwz commented Sep 2, 2021

This PR allows user to specify an input tplg file. Then the test case will call func_pipeline_parse_value to automatically obtain pipeline parameters from the tplg file, and triggers aplay/arecord for all pipelines by default, user can also use the option -S to specify only one PCM to test.

User no longer needs to use parameter to specify each pipeline parameters.

The purpose is to allow this case to automatically test all PCMs, which is more suitable for the automated operation of CI.

Signed-off-by: Wanzhuo.Li wanzhuox.li@intel.com

@1994lwz 1994lwz requested a review from a team as a code owner September 2, 2021 01:50
Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message body is empty and the subject line is too long.

Please follow:
https://wiki.openstack.org/wiki/GitCommitMessages#Summary_of_Git_commit_message_structure
... and most other advice on that page.

test-case/check-pause-release-suspend-resume.sh Outdated Show resolved Hide resolved
rate=$(func_pipeline_parse_value "$idx" rate)
fmt=$(func_pipeline_parse_value "$idx" fmt)
dev=$(func_pipeline_parse_value "$idx" dev)
snd=$(func_pipeline_parse_value "$idx" snd)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the user could pass these on the command line. Not anymore, isn't that also removing a feature? Please explain in the commit message.

Copy link
Author

@1994lwz 1994lwz Sep 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remove a feature, now all these parameters can be parsed from the specified or default tplg file automatically. I explained in the commit message "This patch allows user to specify an input tplg file. Then the test case will call func_pipeline_parse_value to automatically obtain pipeline parameters from the tplg file.

User no longer needs to use parameter to specify each pipeline parameters."

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK the user can edit the topology file if needed, I did not consider that. Thanks for the explanation.

test-case/check-pause-release-suspend-resume.sh Outdated Show resolved Hide resolved
test-case/check-pause-release-suspend-resume.sh Outdated Show resolved Hide resolved
@1994lwz 1994lwz requested a review from marc-hb September 7, 2021 01:25
@1994lwz 1994lwz changed the title Add a new feature: let the case can automatic testing of all PCMs Add loop: check-pause-release-suspend-resume.sh automatically test all PCMs and optimize the code logic Sep 7, 2021
@1994lwz 1994lwz changed the title Add loop: check-pause-release-suspend-resume.sh automatically test all PCMs and optimize the code logic Enable check-pause-release-suspend-resume.sh to automatically test all PCMs Sep 7, 2021
Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The split into 3 commits is good, much more readable and maintainable, thanks!

One one hand you're removing the need to specify compatible parameters which looks good. On the other hand you're also removing the flexibility to choose any parameter in a supported range. I guess this is probably OK for this test but removing a feature should be at least mentioned in the commit messages.

The test case description in the help also needs to be updated to match the changes.

rate=$(func_pipeline_parse_value "$idx" rate)
fmt=$(func_pipeline_parse_value "$idx" fmt)
dev=$(func_pipeline_parse_value "$idx" dev)
snd=$(func_pipeline_parse_value "$idx" snd)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks strange; how is it possible to have shell script code inside the TCL script?

How did you test this part?

OPT_NAME['p']='pcm' OPT_DESC['p']='run test case on specified pipelines'
OPT_HAS_ARG['p']=1 OPT_VAL['p']='id:any'
OPT_NAME['S']='pcm' OPT_DESC['S']='run test case on specified pipelines'
OPT_HAS_ARG['S']=1 OPT_VAL['S']='id:any'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot keep the same help message for a new option that works very differently! Maybe: "run test case on pipelines matching the filter argument"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can refer to check-pause-resume.sh to keep your options consistent with it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marc-hb The -S is used to specify the same PCM ID parameter as -p, so I copy the the help info. I change the option from -p to -S to align with case check-pause-resume.sh that uses -S to specify PCM ID.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since 'S' is an abbreviation, I think 'filter_string' is a better full name.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I got confused because:

  • a first commit changes the option behavior, from aplay argument to topology parser argument without changing its name
  • then a second commit changes its name from -p to -S without changing its help message.

Please change the feature, option name and help message all in the same git commit.

@@ -51,22 +52,14 @@ set -e
## * No unexpected errors should be present in dmesg during or after test
## completion.

source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh
CASEDIR=$(dirname "${BASH_SOURCE[0]}")
source $CASEDIR/../case-lib/lib.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the quoting issues reported by shellcheck. Not all the issues in this script but at least all the ones in new or modified code. Don't add new shellcheck warnings.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# shellcheck source=...

See how other scripts do it.

mengdonglin
mengdonglin previously approved these changes Sep 9, 2021
@mengdonglin
Copy link
Contributor

Reviewed the commit messages

OPT_NAME['p']='pcm' OPT_DESC['p']='run test case on specified pipelines'
OPT_HAS_ARG['p']=1 OPT_VAL['p']='id:any'
OPT_NAME['S']='pcm' OPT_DESC['S']='run test case on specified pipelines'
OPT_HAS_ARG['S']=1 OPT_VAL['S']='id:any'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since 'S' is an abbreviation, I think 'filter_string' is a better full name.

@@ -75,21 +70,21 @@ OPT_NAME['l']='loop' OPT_DESC['l']='loop count'
OPT_HAS_ARG['l']=1 OPT_VAL['l']=5

OPT_NAME['i']='sleep-period' OPT_DESC['i']='sleep period of aplay, unit is ms'
OPT_HAS_ARG['i']=1 OPT_VAL['i']='100'
OPT_HAS_ARG['i']=1 OPT_VAL['i']='200'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just tested this in my TGLU_SKU0A32_SDCA device and found that 200ms seems still too short for my device while 300ms will work fine. Maybe we need more investigation to determine a proper period, or just left it unchanged and specify a proper period for each device in our CI?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something much longer but still quick like 1s?

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be painful to transfer code from one commit to another but sorry, each commit must be standalone, usable and run better than all the previous ones; no regression. You also shouldn't add code with warnings in one commit and then fix the warnings in a later commit. Amend the earlier commit and never have warnings in any commit.

Looking at intermediate commit 2b9ab9e right now I see new shell script code in the middle of TCL code which almost certainly shows that it does not work without a later commit that fixes it. That sort of git history is not acceptable, sorry.

To fix git history make sure you're very familiar with interactive rebase
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
https://www.thinktecture.com/en/tools/git-interactive-rebase/
https://stackoverflow.com/questions/15213814/how-should-i-move-changes-from-one-commit-to-another
(first guides I found, there are probably better ones).
I know there are github projects that don't care about git history and not require any interactive rebase/rewrite skill, we do require in this project that every commit works and is better than the previous ones for many maintenance reasons: bisecting, branching, cherry-picking, reverting etc. This is also required by many other projects so this is a very useful skill to have.

Also make sure you use the git plugin in your editor, many editors have git plugins that make git much faster to use (fugitive, magit, etc.). If your editor does not have a good git plugin you should consider a different editor

OPT_NAME['p']='pcm' OPT_DESC['p']='run test case on specified pipelines'
OPT_HAS_ARG['p']=1 OPT_VAL['p']='id:any'
OPT_NAME['S']='pcm' OPT_DESC['S']='run test case on specified pipelines'
OPT_HAS_ARG['S']=1 OPT_VAL['S']='id:any'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I got confused because:

  • a first commit changes the option behavior, from aplay argument to topology parser argument without changing its name
  • then a second commit changes its name from -p to -S without changing its help message.

Please change the feature, option name and help message all in the same git commit.

rate=$(func_pipeline_parse_value "$idx" rate)
fmt=$(func_pipeline_parse_value "$idx" fmt)
dev=$(func_pipeline_parse_value "$idx" dev)
snd=$(func_pipeline_parse_value "$idx" snd)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK the user can edit the topology file if needed, I did not consider that. Thanks for the explanation.

@@ -75,21 +70,21 @@ OPT_NAME['l']='loop' OPT_DESC['l']='loop count'
OPT_HAS_ARG['l']=1 OPT_VAL['l']=5

OPT_NAME['i']='sleep-period' OPT_DESC['i']='sleep period of aplay, unit is ms'
OPT_HAS_ARG['i']=1 OPT_VAL['i']='100'
OPT_HAS_ARG['i']=1 OPT_VAL['i']='200'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something much longer but still quick like 1s?

@marc-hb
Copy link
Collaborator

marc-hb commented Sep 9, 2021

It can be painful to transfer code from one commit to another

Another thing to make life easier is to expedite small, unrelated fixes easier to review in a different, parallel Pull Request to get them merged faster and quickly out of the way. For this and other reasons I rarely submit HEAD into a pull request, almost always HEAD~n.

On some platforms, 100ms is not enough to detect
whether the audio thread has entered the pause state.
This patch extends the sleep time to 500ms after pause

Signed-off-by: Wanzhuo.Li <wanzhuox.li@intel.com>
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that we have to force the suspend/resume type for the GLK platform. For check-suspend-resume.sh, it is controlled by -T option, so you should add the same option and forward its value to check-suspend-resume.sh.

OPT_NAME['T']='type' OPT_DESC['T']="suspend/resume type from /sys/power/mem_sleep"
OPT_HAS_ARG['T']=1 OPT_VAL['T']=""

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You really misunderstand my words. I mean we should add an option and forward it instead of a hard-coded, unreliable workaround for GLK. Here I give an example in my review comments.

test-case/check-pause-release-suspend-resume.sh Outdated Show resolved Hide resolved
test-case/check-pause-release-suspend-resume.sh Outdated Show resolved Hide resolved
@ghost ghost changed the title Enable check-pause-release-suspend-resume.sh to automatically test all PCMs [SKIP CI] Enable check-pause-release-suspend-resume.sh to automatically test all PCMs Sep 13, 2021
ghost
ghost previously approved these changes Sep 13, 2021
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just triggered a test (6539) for this on all models in the daily test, and all results are green.

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final code changes look mostly OK but the intermediate commits are still not working. Commit c4e5cc6c1875a67 still has shell script in the middle of the TCL expect code, so it is broken (that's fixed by next commit d1628af60b32)

Same thing for the shellcheck warnings: don't fix them in another commit; instead don't add any new warnings at all in the first place.

You must do an interactive rebase and make sure the test can run at each commit. It does not have to PASS on every platform at every commit but it must be able to run (and run better than the previous commit). To make conflict solving easier, perform one complete interactive rebase for each piece of code to move, I mean fix a single problem each time and perform as many interactive rebases as needed.

repeat_count=${OPT_VAL['l']}
sleep_period=${OPT_VAL['i']}
test_mode=${OPT_VAL['m']}
file_name=${OPT_VAL['F']}
tplg=${OPT_VAL['t']}

if [ "${OPT_VAL['T']}" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [ "${OPT_VAL['T']}" ]; then
if [ -n "${OPT_VAL['T']}" ]; then

otherwise an incorrect "${OPT_VAL['T']}" could generate very confusing behaviors.

if [ "${OPT_VAL['T']}" ]; then
opt="-l 1 -T ${OPT_VAL['T']}"
else
opt="-l 1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change opt to something longer and clearer like for instance suspend_opts

@@ -178,8 +180,7 @@ AUDIO
#flush the output
echo
if [ $ret -ne 0 ]; then
sof-process-kill.sh
[[ $? -ne 0 ]] && dlogw "Kill process catch error"
sof-process-kill.sh || dlogw "Kill process catch error"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sof-process-kill.sh || dlogw "sof-process-kill.sh failed"

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for updating this script, see comments/suggestions below.

@@ -75,7 +75,7 @@ OPT_NAME['l']='loop' OPT_DESC['l']='loop count'
OPT_HAS_ARG['l']=1 OPT_VAL['l']=5

OPT_NAME['i']='sleep-period' OPT_DESC['i']='sleep period of aplay, unit is ms'
OPT_HAS_ARG['i']=1 OPT_VAL['i']='100'
OPT_HAS_ARG['i']=1 OPT_VAL['i']='500'
Copy link
Member

@plbossart plbossart Sep 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I ask what platforms? This is a 5x increase, but the intervals between pause_release and pause_push are rather small.

I also don't get why this is different from the regular pause-resume test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YongAnLu00 Yongan test the script on his TGLU_SKU0A32_SDCA device and found that 200ms seems still too short, and Marc suggest change the sleep time much longer but still quick like 1se

@@ -13,6 +13,8 @@ set -e
## have system enter suspend state for 5 secs
## resume from suspend state
## release audio stream from paused state
## repeat to all pipelines
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test description is not clear

line 15: is the stream always paused prior to suspend? Or can this be random/variable?
line 16: can we have multiple streams in parallel? This will be required for our tests, in fact if you see thesofproject/linux#3151 I am precisely having issues with suspend-resume with 2 paused streams.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR, we will first implement a single pipeline test of pause-release-suspend-resume, and then we will re-prove a PR to implement multiple pipeline tests.

@@ -74,7 +76,7 @@ OPT_HAS_ARG['i']=1 OPT_VAL['i']='500'
OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data will store at $LOG_ROOT"
OPT_HAS_ARG['s']=0 OPT_VAL['s']=1

OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file, default value is env TPLG: $TPLG'
OPT_NAME['t']='tplg' OPT_DESC['t']='tplg path, default is environment variable: TPLG'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TPLG is the path+filename, not just the path. This doesn't seem like a valid correction.

Copy link
Collaborator

@marc-hb marc-hb Sep 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover this is a correction of a previous commit in this same PR. The git history is still a mess, don't waste your time reviewing each commit. In addition to having commits that can't run, history that does not bisect, reverts or cherry-picks and confused reviewers, this is also confusing github: so you can't answer some threads unless you select the right commit.

EDIT: as of Sep. 21st (or earlier) the commit history is now clean, thanks!

Back to the description: "path" is ambiguous, for some people path the dirname but for many others like https://docs.python.org/3/library/pathlib.html path = dirname + filename.

"file" is vague but at least every knows it's vague, so no one makes wrong assumptions about it. So I agree "file" is better.

TPLG supports both complete paths and filenames.

OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"

OPT_NAME['T']='type' OPT_DESC['T']="suspend/resume type from /sys/power/mem_sleep"
OPT_HAS_ARG['T']=1 OPT_VAL['T']=""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not able to understand what the option means. the 'from' part threw me off, did you mean instead that it would set the suspend/resume type by writing to sysfs?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option is merely passed passed-through to test-case/check-suspend-resume.sh and the description is merely copied from there (which does not mean it cannot be improved)

OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"

OPT_NAME['T']='type' OPT_DESC['T']="suspend/resume type from /sys/power/mem_sleep"
OPT_HAS_ARG['T']=1 OPT_VAL['T']=""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option is merely passed passed-through to test-case/check-suspend-resume.sh and the description is merely copied from there (which does not mean it cannot be improved)

@@ -74,7 +76,7 @@ OPT_HAS_ARG['i']=1 OPT_VAL['i']='500'
OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data will store at $LOG_ROOT"
OPT_HAS_ARG['s']=0 OPT_VAL['s']=1

OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file, default value is env TPLG: $TPLG'
OPT_NAME['t']='tplg' OPT_DESC['t']='tplg path, default is environment variable: TPLG'
Copy link
Collaborator

@marc-hb marc-hb Sep 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover this is a correction of a previous commit in this same PR. The git history is still a mess, don't waste your time reviewing each commit. In addition to having commits that can't run, history that does not bisect, reverts or cherry-picks and confused reviewers, this is also confusing github: so you can't answer some threads unless you select the right commit.

EDIT: as of Sep. 21st (or earlier) the commit history is now clean, thanks!

Back to the description: "path" is ambiguous, for some people path the dirname but for many others like https://docs.python.org/3/library/pathlib.html path = dirname + filename.

"file" is vague but at least every knows it's vague, so no one makes wrong assumptions about it. So I agree "file" is better.

TPLG supports both complete paths and filenames.

Wanzhuo.Li added 2 commits September 15, 2021 12:05
…h pipeline

This patch allows user to specify an input tplg file. Then the
test case will call func_pipeline_parse_value to automatically
obtain pipeline parameters from the tplg file.

User no longer needs to use parameter to specify each pipeline
parameters.

change the option from -p to -S to align with case
check-pause-resume.sh that uses -S to specify PCM ID.

This case will test all PCMs by default.

Signed-off-by: Wanzhuo.Li <wanzhuox.li@intel.com>
Add the -T parameter to specify the execution state of suspend-resume

Signed-off-by: Wanzhuo.Li <wanzhuox.li@intel.com>
@1994lwz 1994lwz requested review from marc-hb, a user and plbossart September 22, 2021 02:20
@marc-hb marc-hb dismissed their stale review November 1, 2021 19:25

git breakdown now OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants