Skip to content

test: add compressed audio socwatch test - #1345

Merged
redzynix merged 2 commits into
thesofproject:mainfrom
ekurdybx:compressed_audio_socwatch_test
Apr 20, 2026
Merged

test: add compressed audio socwatch test#1345
redzynix merged 2 commits into
thesofproject:mainfrom
ekurdybx:compressed_audio_socwatch_test

Conversation

@ekurdybx

@ekurdybxekurdybx commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Add test that plays MP3 sound and performs Socwatch analysis to check if dut enters and stays in PC10 state for the expected % of time (default expected value: 80% in PC10.2 state)
Note: this test will only pass when:

  1. the changes for playing compressed audio will be merged
  2. the currently known pc10 state issue will be resolved

@ekurdybxekurdybx changed the title Compressed audio socwatch testNOT READY: Compressed audio socwatch testFeb 19, 2026
@ekurdybx
ekurdybxforce-pushed the compressed_audio_socwatch_test branch 2 times, most recently from 8a46815 to 70150f4CompareMarch 5, 2026 13:42
@ekurdybx
ekurdybxforce-pushed the compressed_audio_socwatch_test branch 6 times, most recently from c9edb0c to f1455fbCompareMarch 17, 2026 12:00
@ekurdybx
ekurdybxforce-pushed the compressed_audio_socwatch_test branch 4 times, most recently from b3ad6c8 to a5626acCompareMarch 24, 2026 14:27
@ekurdybx
ekurdybxforce-pushed the compressed_audio_socwatch_test branch 2 times, most recently from 0bcbd9a to 7883e5cCompareApril 17, 2026 10:09
@ekurdybxekurdybx changed the title NOT READY: Compressed audio socwatch testtest: Compressed audio socwatch testApr 17, 2026
@ekurdybxekurdybx changed the title test: Compressed audio socwatch testtest: add compressed audio socwatch testApr 17, 2026
@ekurdybx
ekurdybxforce-pushed the compressed_audio_socwatch_test branch 2 times, most recently from 028929a to d2d4f57CompareApril 17, 2026 10:54
@ekurdybx
ekurdybx marked this pull request as ready for review April 17, 2026 11:09
Comment threadtools/analyze-pc-states.py Outdated
print(f"Incorrect value: {pc_state} time % was {value}, expected {expected_value}")
failures += 1

return 0 if failures == 0 else 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's cool but I think keeping it easier to read would be better.

Suggested change
return0iffailures==0else1
iffailures==0:
return0
return1

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

@ekurdybx
ekurdybxforce-pushed the compressed_audio_socwatch_test branch 2 times, most recently from cc6155f to 6154da5CompareApril 17, 2026 12:03

@marc-hbmarc-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.

Very clean and easy to read! Minor suggestions below

Comment threadtools/analyze-pc-states.py Outdated
with open(pc_states_file, encoding="utf-8") as file:
for line in file:
m = pattern.match(line)
if m:

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.

"early return" pattern

Suggested change
ifm:
ifnotm:
continue

Same as you already did below but saves a lot more indentation (and mental load).

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

print(f"Incorrect value: {pc_state} time % was {value}, expected {expected_value}")
failures += 1

if failures:

@marc-hbmarc-hbApr 17, 2026

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
iffailures:
returnfailures

Then you may not want the main script to exit the number of failures too because some values may have special meaning - but for sure this function has nothing better to return than the number of failures.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This func returns the result of the analysis - which is true or false.

pattern = re.compile(r'^PC(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*$')
failures = 0

with open(pc_states_file, encoding="utf-8") as file:

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 could move the with open() to the caller and save even more indentation.



def analyze_pc_states(pc_states_file, expected_results):
pattern = re.compile(r'^PC(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*$')

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.

Regexps are notoriously cryptic. What really helps in such cases is to give a few input examples in a comment.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

Comment threadtest-case/test-compressed-audio.sh Outdated
check_cplay_command()
{
dlogi "${play_command[@]}"
if ! "${play_command[@]}"; 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.

Style nit:

Suggested change
if!"${play_command[@]}";then
"${play_command[@]}"||
die ...

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

expected_results="{\"PC10.2\":$pc10_threshold}"

# Analyze if the % of the time spent in given PC state was as expected
if python3 "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file" "$expected_results"; 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.

chmod a+x analyze-pc-states.py
I'm afraid sof-test is not going to work on Windows anytime soon!

Suggested change
ifpython3 "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file""$expected_results";then
if"$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file""$expected_results";then

@ekurdybx
ekurdybxforce-pushed the compressed_audio_socwatch_test branch 5 times, most recently from 405be8b to d38b647CompareApril 20, 2026 12:10
Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
Add test that plays mp3 audio using cplay, and check PC states with
Socwatch
Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
@ekurdybx
ekurdybxforce-pushed the compressed_audio_socwatch_test branch from d38b647 to 2a9d625CompareApril 20, 2026 12:11
@redzynix
redzynix merged commit 865c789 into thesofproject:mainApr 20, 2026
2 of 3 checks passed
Sign up for freeto 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

@ekurdybx@marc-hb@redzynix@PLangowski