Skip to content

check-pause-release-suspend-resume: timing fixes + switch to sof-tplgreader - #885

Closed
keqiaozhang wants to merge 7 commits into
thesofproject:mainfrom
keqiaozhang:s3ref
Closed

keqiaozhang wants to merge 7 commits into
thesofproject:mainfrom
keqiaozhang:s3ref

Conversation

@keqiaozhang

Copy link
Copy Markdown
Contributor

No description provided.

@keqiaozhang
keqiaozhang requested a review from a team as a code owner March 25, 2022 04:49

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can this be added to run-all-tests.sh?

We need all developpers to replicate what CI does.

@marc-hb marc-hb changed the title refine test case: check-pause-release-suspend-resume check-pause-release-suspend-resume: timing fixes + switch to sof-tplgreader Mar 27, 2022

@marc-hb marc-hb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since you're rewriting most of the test, please take the opportunity to move all the code to functions, see why in #740. At least one main() function, maybe others too.

@keqiaozhang

Copy link
Copy Markdown
Contributor Author

can this be added to run-all-tests.sh?

We need all developpers to replicate what CI does.

Done.

@keqiaozhang

Copy link
Copy Markdown
Contributor Author

Since you're rewriting most of the test, please take the opportunity to move all the code to functions, see why in #740. At least one main() function, maybe others too.

PR is updated.

@marc-hb marc-hb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The breakdown into multiple commits was a nice try but it didn't really work:

  • The first commit message talks about sof-tplgreader only but it has tons of other, unrelated changes.
  • The move to functions should have come first (but now it's too late).

You can still try to keep the "small" commits as independent commits if possible but please squash the 2 big commits into a single big commit, it's just simpler and more "honest".

Keep the run-all-tests.sh commit separate of course.

file_name=${OPT_VAL['F']}
parse_param()
{
func_opt_parse_option $@

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

shellcheck, easy

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

OPT_NAME['p']='pcm' OPT_DESC['p']='audio pcm. Example: hw:0,0'
OPT_HAS_ARG['p']=1 OPT_VAL['p']='hw:0,0'
OPT_NAME['m']='mode' OPT_DESC['m']='test mode. Example: playback; capture'
OPT_HAS_ARG['m']=1 OPT_VAL['m']='playback'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove all these whitespace changes in this area. They make it impossible to find the real changes.
https://wiki.openstack.org/wiki/GitCommitMessages#Things_to_avoid_when_creating_commits

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Answering myself: reviewing commits individually avoids this problem.


run_test()
{
for idx in $(seq 0 $((PIPELINE_COUNT - 1)))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can save one indentation level by moving the for loop to the main() function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. PR is updated.

ret=$?
if [ $ret -ne 0 ]; then
sof-process-kill.sh || dlogw "sof-process-kill.sh failed"
exit $ret

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we really want to preserve the exit code here? If it's 2 then it will be misinterpreted as a SKIP! We experienced this recently in some different place.

sleep_opts="-l 1 -T ${OPT_VAL['T']}"
else
sleep_opts="-l 1"
fi

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sleep_opts="-l 1"
[ -z "${OPT_VAL['T']}" ] || sleep_opts+="-T ${OPT_VAL['T']}"

@marc-hb marc-hb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shell script code looks good to me except for a couple shellcheck warnings easy to fix.

@plbossart or @ranj063 can you please review the test / expect logic? I think one of you requested this?

do
run_test
if [ $? -ne 0 ]; then
sof-process-kill.sh || dlogw "Kill process catch error"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
sof-process-kill.sh || dlogw "Kill process catch error"
sof-process-kill.sh || dlogw "sof-process-kill.sh cleanup failed"

OPT_NAME['p']='pcm' OPT_DESC['p']='audio pcm. Example: hw:0,0'
OPT_HAS_ARG['p']=1 OPT_VAL['p']='hw:0,0'
OPT_NAME['m']='mode' OPT_DESC['m']='test mode. Example: playback; capture'
OPT_HAS_ARG['m']=1 OPT_VAL['m']='playback'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Answering myself: reviewing commits individually avoids this problem.

for idx in $(seq 0 $((PIPELINE_COUNT - 1)))
do
run_test
if [ $? -ne 0 ]; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As reported by shellcheck:

Suggested change
if [ $? -ne 0 ]; then
run_test || {

One possible reason to use ret=$? is when you want to exit $ret after cleanup but you're not doing that here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated.

## completion.

# shellcheck source=case-lib/lib.sh
source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Last shellcheck warning / quoting issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@marc-hb marc-hb Apr 6, 2022 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fixed.

No, not completely. Can you please run shellcheck locally before pushing? Especially after fixing shellcheck issues? It would have saved a lot of time.

sudo apt install shellcheck
shellcheck -x test-case/check-pause-release-suspend-resume.sh

@plbossart

Copy link
Copy Markdown
Member

can this be added to run-all-tests.sh?
We need all developpers to replicate what CI does.

Done.

I don't see any changes to run-all-tests.sh @keqiaozhang ?

@marc-hb

marc-hb commented Apr 5, 2022

Copy link
Copy Markdown
Collaborator

I don't see any changes to run-all-tests.sh @keqiaozhang ?

That was moved to #886, not sure why. No big deal.

@keqiaozhang

Copy link
Copy Markdown
Contributor Author

@plbossart @marc-hb @ranj063
Please help with the final review. If no objections, I will merge this PR by end of this week.

@marc-hb

marc-hb commented Apr 22, 2022 •

Copy link
Copy Markdown
Collaborator

There's one shellcheck warning very easy to fix. We should not still be looking at trivial shellcheck warnings 1 month after the first version, this is a waste of time. Run shellcheck locally before submitting, it takes a split second.

warning and code cleanup

fix one shellcheck warning and some code cleanup.

Signed-off-by: Keqiao Zhang <keqiao.zhang@intel.com>
parse pipelines instead of specifying PCM to test

Consistent with other test scripts to use sof-tplgreader
to parse audio pipelines designed in tplg and use -m option
to select part of them to test.

Signed-off-by: Keqiao Zhang <keqiao.zhang@intel.com>
checking the aplay/arecord status after pause/release

This interval is too short which may casue timing issue
on some platforms. Extend the interval to 500ms to avoid
such issues.

Signed-off-by: Keqiao Zhang <keqiao.zhang@intel.com>
the sleep type for suspend/resuse

There are 2 sleep types designed in /sys/power/mem_sleep
add a -T option to specify which one you want to test.

Signed-off-by: Keqiao Zhang <keqiao.zhang@intel.com>
pausing the audio stream

There's a latency when starting audio stream, if pause
the audio stream directly after it starts, it may lead
to some unexpected errors. Add a delay to ensure that
audio stream is in a normal state before pusing.

Signed-off-by: Keqiao Zhang <keqiao.zhang@intel.com>
Move the code to a function to make the code easy
to understand and maintain.

Signed-off-by: Keqiao Zhang <keqiao.zhang@intel.com>
Add 2 new cases to run all test:
1. pause-release-suspend-resume-with-playback
2. pause-release-suspend-resume-with-capture

Signed-off-by: Keqiao Zhang <keqiao.zhang@intel.com>
@marc-hb

marc-hb commented Apr 27, 2022 •

Copy link
Copy Markdown
Collaborator

@plbossart , @ranj063 , @lyakh could you please review the pause/release/suspend/resume logic?

@plbossart

Copy link
Copy Markdown
Member

@plbossart , @ranj063 , @lyakh could you please review the pause/release/suspend/resume logic?

I don't speak shell fluently and I am unable to figure out what the 'logic' is in this heap of shell commands.

I will note however that I don't understand why the pause can only be done after a delay. What possible 'unexpected errors' could happen if we pause immediately after starting? It looks like we are masking a set of possible issues without a clear justification.

@marc-hb

marc-hb commented Apr 28, 2022

Copy link
Copy Markdown
Collaborator

Note the vast majority of this test and PR is not written in shell script but in https://en.wikipedia.org/wiki/Expect

@marc-hb

marc-hb commented Aug 1, 2024

Copy link
Copy Markdown
Collaborator

This test was finally rewritten in 006946c + follow-ups.

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.

3 participants