Skip to content

greg-intel/sof-test

 
 

Repository files navigation

SOF Test Case repo

Environment set up

requirements

apt packages

expect alsa-utils python3 python3-construct python3-graphviz

sudo apt install expect alsa-utils python3 python3-construct python3-graphviz

user group

sudo adm audio

env-check.sh

You can use this script to ensure the sof-test environment is set up properly

Usage

test cases

To run a test, call the scripts directly

  • -h will show the usage for the test

Example:

~/sof-test/test-case$ SOF_ALSA_OPTS='-q --fatal-errors' ./check-playback.sh -h
Usage: ./check-playback.sh [OPTION]

    -F |  --fmts
	    Iterate all supported formats
	    Default Value: Off
    -d parameter |  --duration parameter
	    aplay duration in second
	    Default Value: 10
    ...
~/sof-test/test-case$ ./check-playback.sh -d 4
2020-03-19 22:13:32 UTC [INFO] no source file, use /dev/zero as dummy playback source
2020-03-19 22:13:32 UTC [INFO] ./check-playback.sh using /lib/firmware/intel/sof-tplg/sof-apl-pcm512x.tplg as target TPLG to run the test case
2020-03-19 22:13:32 UTC [INFO] Catch block option from TPLG_BLOCK_LST will block 'pcm=HDA Digital,Media Playback,DMIC16k' for /lib/firmware/intel/sof-tplg/sof-apl-pcm512x.tplg
2020-03-19 22:13:32 UTC [INFO] Run command: 'sof-tplgreader.py /lib/firmware/intel/sof-tplg/sof-apl-pcm512x.tplg -f type:playback,both -b pcm:'HDA Digital,Media Playback,DMIC16k' -s 0 -e' to get BASH Array
2020-03-19 22:13:32 UTC [INFO] Testing: (Round: 1/1) (PCM: Port5 [hw:0,0]<both>) (Loop: 1/3)
2020-03-19 22:13:32 UTC [COMMAND] aplay -q --fatal-errors  -Dhw:0,0 -r 48000 -c 2 -f S16_LE -d 4 /dev/zero -v -q
    ...

Some tests support SOF_ALSA_OPTS, SOF_APLAY_OPTS and SOF_ARECORD_OPTS, work in progress. Where supported, optional parameters in SOF_APLAY_OPTS and SOF_ARECORD_OPTS are passed to all aplay and arecord invocations. SOF_ALSA_OPTS parameters are passed to both aplay and arecord. Warning these environments variables do NOT support parameters with whitespace or globbing characters, in other words this does NOT work:

SOF_ALSA_OPTS='--foo --bar="spaces do not work"'

For the up-to-date list of tests supporting these environment variables run:

git grep -l 'a[[:alnum:]]*_opts'

tools

To use tool script, call the scripts directly

  • -h will show the usage for the tool

Example:

$ ./tools/sof-dump-status.py -p
apl

test case result

exit code display description
0 PASS Test has passed
1 FAIL Test has failed
2 N/A Test is not applicable
* unknown exit status

Folder description

  • case-lib
    Test case helper functions library

  • test-case
    The test cases

  • tools
    Script helper tools for the test cases.
    Can also be used directly via the command line
    Filenames should have the "sof-" prefix

  • logs
    Records in the test-case log folder.
    It will be auto created and follow the test name
    Ordered by time tag, the last link will link to the last run result

Tools list description

  • sof-boot-once.sh
    This script writes to rc.local, which is loaded and read after reboot.
    After rc.local command is run, the command will be removed.
    example: sof-boot-once.sh reboot
    Effect: when system boots up it will auto reboot again

  • sof-combinatoric.py
    Used to compute permutations or combinations of the various pipelines avilable during tests if multiple are needed at once.

  • sof-disk-usage.sh
    Used to ensure we have enough disk space to collect logs and avoid system problems.

  • sof-dump-status.py
    Dump the sound card status

  • sof-get-default-tplg.sh
    Load the tplg file name from system log which is recorded from system bootup

  • sof-get-kernel-line.sh
    Print all kernel versions and their line numbers from /var/log/kern.log, with the most recent <first/last>

  • sof-kernel-dump.sh
    Catch all kernel information after system boot up from /var/log/kern.log file

  • sof-kernel-log-check.sh
    Check dmesg for errors and ensure that any found are real errors

  • sof-process-kill.sh
    Kills aplay or arecord processes

  • sof-process-state.sh
    Shows the current state of a given process

  • sof-tplgreader.py
    tplgtool.py wrapper, it reads info from tplgtool.py to analyze topologies.

  • tplgtool2.py
    Dumps info from tplg binary file.

  • tplgtool.py
    Dumps info from tplg binary file. (deprecated)

System configuration tips

sudo noise

sof-test uses sudo a lot which creates a lot of noise in journalctl output which is especially a problem when testing. To turn off that noise first run sudo visudo and add the following line:

Defaults:USER_LOGIN,root !log_allowed

For more see man sudoers.

Then add the following line at the top of /etc/pam.d/sudo

# Be "done" when the pam_succeed_if.so arguments are matched; don't
# process other lines. If not matched then "ignore" this line.
# Also support "double sudo" :-(
session [success=done default=ignore] pam_succeed_if.so quiet         uid = 0 ruser = root
session [success=done default=ignore] pam_succeed_if.so quiet_success uid = 0 ruser = USER_LOGIN

Note PAM security configuration is complex and distribution-specific. This was tested only on Ubuntu 20.04. See man pam.d or one of the PAM guides available on the Internet. Be careful not to make your system vulnerable.

On systems using auditd, sof-test will also generate a huge amount of log. If you need to keep audit, check man auditctl to find how to filter out sudo noise.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 60.5%
  • Python 37.7%
  • MATLAB 1.8%