Skip to content

Test-case: Add check volume levels - #410

Merged
marc-hb merged 1 commit into
thesofproject:masterfrom
singalsu:add_volume_levels_check
Oct 21, 2020
Merged

Test-case: Add check volume levels#410
marc-hb merged 1 commit into
thesofproject:masterfrom
singalsu:add_volume_levels_check

Conversation

@singalsu

Copy link
Copy Markdown
Contributor

This patch adds a shell script that measures volume levels
to compute gains when executed with a nocodec topology where
SSP ports are connected to play -> capture loopback.

The measured gains are compared against test procedure and
error is issued if the gains deviate more than tolerance.

Signed-off-by: Seppo Ingalsuo seppo.ingalsuo@linux.intel.com

@singalsu
singalsu requested a review from a team as a code ownerOctober 6, 2020 13:56
@singalsu
singalsuforce-pushed the add_volume_levels_check branch from d25cc21 to 60e4330CompareOctober 6, 2020 14:12
@singalsu

Copy link
Copy Markdown
ContributorAuthor

Update: I changed echo commands to dlogi and dloge.

@singalsu
singalsuforce-pushed the add_volume_levels_check branch from 60e4330 to 60aa062CompareOctober 6, 2020 15:27
@singalsu

Copy link
Copy Markdown
ContributorAuthor

Fixed environment variable declarations / exports.

@singalsu
singalsuforce-pushed the add_volume_levels_check branch from 60aa062 to 3fe0934CompareOctober 6, 2020 16:01
@singalsu

Copy link
Copy Markdown
ContributorAuthor

For fun I added it to run-all-tests.sh. It will fail on most devices due to no Octave installed. Also the nocodec topologies do not create the required mute switch control. I'll do a separate SOF PR for it.

Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/run-all-tests.sh Outdated
Comment threadtest-case/check-volume-levels.sh
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
@singalsu
singalsuforce-pushed the add_volume_levels_check branch 2 times, most recently from 84956de to fa8a4cdCompareOctober 8, 2020 10:26
@singalsu

Copy link
Copy Markdown
ContributorAuthor

@marc-hb Thanks for all the help! I've tried to address all your comments now. Though there are two cases where I'm not yet sure the approach is the best one.

I'll still add to Octave part channels filtering for center frequencies. It will catch then also channels swaps. Also I'll test adding ramp length verification for the 0-100% transitions.

Can this be merged to sof-test as non-enabled test (while need for Octave)?

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

Thanks for your patience, I think we're getting very close with the shell script. Need someone to review the matlab code and logic.

Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
@singalsu
singalsuforce-pushed the add_volume_levels_check branch from fa8a4cd to b9fe1c0CompareOctober 9, 2020 14:57
@singalsusingalsu changed the title [WIP][RFC] Test-case: Add check volume levels[RFC] Test-case: Add check volume levelsOct 9, 2020
@singalsu

singalsu commented Oct 9, 2020

Copy link
Copy Markdown
ContributorAuthor

This test code needs sof-test PR #417 to not fail with channel count and device strings and SOF PR thesofproject/sof#3509 to have needed full-blown volume component controls instantiated.

@singalsu
singalsuforce-pushed the add_volume_levels_check branch from b9fe1c0 to 63f7df0CompareOctober 9, 2020 15:06
@singalsu
singalsu requested a review from marc-hbOctober 9, 2020 15:50
@singalsu
singalsuforce-pushed the add_volume_levels_check branch from 63f7df0 to f3a1108CompareOctober 12, 2020 15:28

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

I believe no one reviewed the Octave code yet :-( Who could do this?

I would be very worrying if we have only one person who can review Octave code, maybe we shouldn't even be using Octave in validation in that case! :-((

This test code needs sof-test PR #417 to not fail with channel count and device strings and SOF PR thesofproject/sof#3509 to have needed full-blown volume component controls instantiated.

I still have a few minor comments but the shell script looks basically ready to me. However considering this test cannot run in CI (yet), we need IMHO evidence of at least one person other than the submitter who could run the test. It doesn't even have to pass, just to run and produce some meaningful audio results anywhere but on the submitter's system. I tried it last week but I couldn't run it on my platform in a reasonable time, not even with some local modifications/hacks. @singalsu should I wait until thesofproject/sof#3509 is merged before trying again?

Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
@marc-hb

Copy link
Copy Markdown
Collaborator

https://sof-ci.01.org/softestpr/PR410/build251/devicetest/ experienced a device failure on BSW_CYN_MAX98090

kernel: [ 4.509348] EXT4-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsck is recommended
kernel: [ 4.515925] EXT4-fs (mmcblk0p2): re-mounted. Opts: errors=remount-ro

@keyonjie

Copy link
Copy Markdown

@singalsu I am trying to run your test case on TGL nocodec, it fails as it has no 'Switch' kcontrol there, which tplg I should use to run it?

@singalsu
singalsuforce-pushed the add_volume_levels_check branch from f3a1108 to 56f6144CompareOctober 13, 2020 12:25
@singalsu

Copy link
Copy Markdown
ContributorAuthor

@keyonjie There's need for thesofproject/sof#3509 to add the missing switch controls.

@singalsusingalsu changed the title [RFC] Test-case: Add check volume levelsTest-case: Add check volume levelsOct 13, 2020
@singalsu
singalsu requested a review from marc-hbOctober 13, 2020 15:41

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

The shell script looks good to me. Before merging I think this still needs:

  • at least one other person who could run this (even if the tests don't pass)
  • someone to review the Octave code.

Comment threadtest-case/check-volume-levels.sh Outdated
Comment threadtest-case/check-volume-levels.sh Outdated
juimonen
juimonen previously approved these changes Oct 14, 2020

@juimonenjuimonen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM for the octave code

@xiulipanxiulipan left a comment

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.

Could we add a check for octave in test case first to avoid accidently run fail for this case.

@marc-hb

Copy link
Copy Markdown
Collaborator

Could we add a check for octave in test case first to avoid accidently run fail for this case.

I think this could be useful later once we want to run this in automation but we would like to merge it earlier than that. For now I believe we still don't have any report yet of any other person besides the author who could run it manually.

@singalsu

singalsu commented Oct 15, 2020

Copy link
Copy Markdown
ContributorAuthor

@xiulipan Yes, makes sense I'll add the check for octave.

@keyonjie Can you please add your review / report of what was need to get it running on your device.

xiulipan
xiulipan previously approved these changes Oct 16, 2020

@xiulipanxiulipan left a comment

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.

LGTM, let's try to do some integration with CI framework.

@keyonjiekeyonjie left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the case, it looks professional with good coverage on the volume level.
For the pipeline coverage, it only change volume/switch for the capture one, is it worth to add these to playback pipeline also?

Comment threadtest-case/check-volume-levels.sh Outdated
}

pause () {
dlogi "Pausing"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The wording "pause" is somewhat confusion, we are not aim to pause any playback/capture stream, maybe 'sleep_1s'?

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.

The test script really pauses execution so I prefer this. Just sleep is a reserved word and don't want to hard code with the name the length to 1s. It could be adjusted later to more than 1s for better accuracy or less than 1s for lower test time.

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.

nap() ? :-)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

yes, either 'nap' / 'nop' or 'idle' sound better to me, or even exec_pause(), as we have test cases naming xxx_pause_release_xxx, I thought we are pausing the playback/capture pipeline at my first glance to the PR.

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.

nap sounds good to me!

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.

Changed

Comment threadtest-case/check-volume-levels.sh
Comment threadtools/check_volume_levels.m
Comment threadtest-case/check-volume-levels.sh
Comment threadtools/check_volume_levels.m Outdated
fprintf(1, 'PASS\n');
else
fprintf(1, 'FAIL\n');
exit(1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

shall we remove those 2 'exit(1)' as they are making my octave hang when running it with gui mode, logging errors should be enough?

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 script is not for GUI mode but for batch processing. For interactive tests with GUI I've commented out those lines. The GUI doesn't hang but it quits with exit().

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.

I'm not aware of simple ways in script to check if we are in Octave GUI. If such exist we could make a custom exit function.

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.

This script is not for GUI mode but for batch processing.

It would be great to find a solution that supports both but waiting for that should IMHO not block this "automation" PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@singalsu@marc-hb just removing this 'exit(1)' line will work for both GUI and batch processing per my testing.

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.

The shell script thinks a failed test passed if I omit the exit(1).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Okay, got you now @singalsu

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 shell script thinks a failed test passed if I omit the exit(1).

Thanks @singalsu for "testing the test code" and making sure it can report failures. I found this to be incredibly rare in this project.

After only 2 minutes googling (sorry) I found "error()", did you try it? https://octave.org/doc/v4.0.1/Raising-Errors.html

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.

Yes I'm using error() a lot to stop script execution but I haven't used to return code to shell. I'll see if it works. It doesn't quit the GUI like exit does. If it it works, it's more convenient.

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.

Thanks, yes it works for the purpose! I'll switch to error().

marc-hb
marc-hb previously approved these changes Oct 16, 2020

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

This doesn't work for me sometimes,

Considering this test is not enabled in automation yet, working "sometimes" for at least one person besides the submitter is IMHO enough "validation". Merging it will make fixing it easier.

Comment threadtest-case/check-volume-levels.sh
Comment threadtest-case/check-volume-levels.sh
Comment threadtest-case/check-volume-levels.sh Outdated
}

pause () {
dlogi "Pausing"

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.

nap() ? :-)

@marc-hb

Copy link
Copy Markdown
Collaborator

jf-icl-rvp-hda-4 boot failed in https://sof-ci.01.org/softestpr/PR410/build274/devicetest/

Comment threadtest-case/check-volume-levels.sh Outdated
keyonjie
keyonjie previously approved these changes Oct 20, 2020

@keyonjiekeyonjie left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good, we can add incremental fixes if minor issues existed.

This patch adds a shell script to check that SOF volume component
related system applies correctly channels gains and mute switches.
The script determines the volume gains from measured sine wave
levels and compares to used amixer control values.
The test can be executed with a nocodec topology where SSP ports
are connected to play -> capture loopback. The loopback avoids need
for noise sensitive acoustical test or more complex electrical
test.
An error is issued if the gains deviate more than used +/- 0.5 dB
tolerance.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu
singalsu dismissed stale reviews from keyonjie, marc-hb, and xiulipan via 575bd7bOctober 20, 2020 11:06
@singalsu
singalsuforce-pushed the add_volume_levels_check branch from 2005a99 to 575bd7bCompareOctober 20, 2020 11:06
@singalsu

Copy link
Copy Markdown
ContributorAuthor

I did the proposed and agreed updates. In addition I added a verbose flag to level check function to prevent additional reports of incorrect level printed while the script tries if swapped channels and swapped controls would pass. I always test the changes with manual add of error to controls or measurements side to see I get the pass and fail correctly.

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

Looks good, we can add incremental fixes if minor issues existed.

+1 considering this doesn't run in CI yet.

exit 2
fi

test -n "$(command -v octave)" || {

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.

Simpler and logging the location

type octave || {
...
}

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.

I didn't know that, it's very compact but not very intuitive. If you are OK to re-review I can change this.

@marc-hb
marc-hb merged commit e4380d1 into thesofproject:masterOct 21, 2020
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.

5 participants

@singalsu@marc-hb@keyonjie@juimonen@xiulipan