thesofproject / sof-test

BSD 3-Clause "New" or "Revised" License
12 stars 44 forks source link

SOF Test Case repo

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

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

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

Tools list description

See tools/README.md

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.