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

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

Closed
wants to merge 7 commits into from

Conversation

keqiaozhang
Copy link
Contributor

No description provided.

@keqiaozhang keqiaozhang requested a review from a team as a code owner March 25, 2022 04:49
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.

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
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.

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
Contributor Author

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

We need all developpers to replicate what CI does.

Done.

@keqiaozhang
Copy link
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.

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 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
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
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
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
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
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
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
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
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']}"

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.

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
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
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
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
Contributor Author

Choose a reason for hiding this comment

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

Updated.

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

# shellcheck source=case-lib/lib.sh
source $(dirname ${BASH_SOURCE[0]})/../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.

Last shellcheck warning / quoting issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Collaborator

@marc-hb marc-hb Apr 6, 2022

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
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
Copy link
Collaborator

marc-hb commented Apr 5, 2022

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
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
Copy link
Collaborator

marc-hb commented Apr 22, 2022

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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Move the code to a function to make the code easy
to understand and maintain.

Signed-off-by: Keqiao Zhang <[email protected]>
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 <[email protected]>
@marc-hb
Copy link
Collaborator

marc-hb commented Apr 27, 2022

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

@plbossart
Copy link
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
Copy link
Collaborator

marc-hb commented Apr 28, 2022

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
Copy link
Collaborator

marc-hb commented Aug 1, 2024

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