-
Notifications
You must be signed in to change notification settings - Fork 59
add User space test cases (version2) #479
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5981b27
case-lib: add helper function to check pulseaudio status
libinyang b281225
userspace: add check-userspace-cardinfo
libinyang 28ee0bd
tools: add pactlinfo
libinyang 6b05cf2
userspace: add check-userspace-paplay
libinyang 82bfaf1
userspace: add check-userspace-parecord
libinyang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/bin/bash | ||
|
|
||
| ## | ||
| ## Case Name: check-userspace-cardinfo | ||
| ## Preconditions: | ||
| ## N/A | ||
| ## Description: | ||
| ## Get the card name from pactl info | ||
| ## check if there is an available card to do the following tests | ||
| ## Case step: | ||
| ## 1. run pactl to get the cards info | ||
| ## 2. check the card name | ||
| ## Expect result: | ||
| ## There is at least one available card for test | ||
| ## | ||
|
|
||
| set -e | ||
|
|
||
| # shellcheck source=case-lib/lib.sh | ||
| source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh | ||
|
|
||
| # check pulseaudio runs properly or not | ||
| func_lib_check_pa || die "Please check whether pulseaudio runs correctly or not" | ||
|
|
||
| func_opt_parse_option "$@" | ||
|
|
||
| : $((available_card=0)) | ||
| while read -r card; do | ||
| # pactl list cards short format should be like: | ||
| # 0 alsa_card.pci-0000_00_1f.3-platform-sof_sdw module-alsa-card.c | ||
| dlogi "found card: $(echo "$card" | awk '{print $2}')" | ||
| echo "$card" | grep -q -i "usb" || : $((available_card++)) | ||
| done < <(pactl list cards short) | ||
|
|
||
| if [ "$available_card" == "0" ]; then | ||
| # TODO: do more check to give hint why there is no available card | ||
| die "no available card for test" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| #!/bin/bash | ||
|
|
||
| ## | ||
| ## Case Name: check-userspace-paplay | ||
| ## Preconditions: | ||
| ## N/A | ||
| ## Description: | ||
| ## Go through all the sinks and paplay on the sinks whose | ||
| ## active port is available (jack connected) or unknown (speaker) | ||
| ## Case step: | ||
| ## 1. go through all the sinks | ||
| ## 2. check the sink's active port is available or not | ||
| ## 3. paplay on the active port which is available or unknown | ||
| ## Expect result: | ||
| ## paplay on the sinks successfully | ||
| ## | ||
|
|
||
| set -e | ||
|
|
||
| # shellcheck source=case-lib/lib.sh | ||
| source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh | ||
|
|
||
| # check pulseaudio runs properly or not | ||
| func_lib_check_pa || die "Please check whether pulseaudio runs correctly or not" | ||
|
|
||
| OPT_OPT_lst['r']='round' OPT_DESC_lst['r']='round count' | ||
| OPT_PARM_lst['r']=1 OPT_VALUE_lst['r']=3 | ||
|
|
||
| OPT_OPT_lst['d']='duration' OPT_DESC_lst['d']='paplay duration in second' | ||
| OPT_PARM_lst['d']=1 OPT_VALUE_lst['d']=8 | ||
|
|
||
| OPT_OPT_lst['f']='file' OPT_DESC_lst['f']='source file path' | ||
| OPT_PARM_lst['f']=1 OPT_VALUE_lst['f']='/dev/zero' | ||
|
|
||
| OPT_OPT_lst['F']='format' OPT_DESC_lst['F']='sample format' | ||
| OPT_PARM_lst['F']=1 OPT_VALUE_lst['F']=s16le | ||
|
|
||
| OPT_OPT_lst['R']='rate' OPT_DESC_lst['R']='sample rate' | ||
| OPT_PARM_lst['R']=1 OPT_VALUE_lst['R']=44100 | ||
|
|
||
| OPT_OPT_lst['C']='channels' OPT_DESC_lst['C']='channels' | ||
| OPT_PARM_lst['C']=1 OPT_VALUE_lst['C']=2 | ||
|
|
||
| func_opt_parse_option "$@" | ||
|
|
||
| round_cnt=${OPT_VALUE_lst['r']} | ||
| duration=${OPT_VALUE_lst['d']} | ||
| file=${OPT_VALUE_lst['f']} | ||
| format=${OPT_VALUE_lst['F']} | ||
| rate=${OPT_VALUE_lst['R']} | ||
| channel=${OPT_VALUE_lst['C']} | ||
|
|
||
| [[ -e $file ]] || { dlogw "$file does not exist, use /dev/zero as dummy playback source" && file=/dev/zero; } | ||
|
|
||
| # TODO: check the parameter is valid or not | ||
|
|
||
| # go through all the sinks | ||
| # get all the sinks name | ||
| sinkkeys=$(pactlinfo.py --showsinks) | ||
| for round in $(seq 1 $round_cnt); do | ||
| for i in $sinkkeys; do | ||
| sinkcard=$(pactlinfo.py --getsinkcardname "$i") || { | ||
| dlogw "failed to get sink $i card_name" | ||
| continue | ||
| } | ||
|
|
||
| # Let's skip testing on USB card | ||
| # TODO: add a list for other skipped cards such as HDA | ||
| if echo "$sinkcard" |grep -q -i "usb"; then | ||
| continue | ||
| fi | ||
|
|
||
| # get the sink's active port | ||
| actport=$(pactlinfo.py --getsinkactport "$i") || { | ||
| dlogw "failed to get sink $i active port" | ||
| continue | ||
| } | ||
|
|
||
| # get the active port's information | ||
| actportvalue=$(pactlinfo.py --getsinkportinfo "$actport") || { | ||
| dlogw "failed to get sink $i active port $actport info" | ||
| continue | ||
| } | ||
|
|
||
| # check the active port is available or not from the port's information | ||
| portavailable=$(echo "$actportvalue" |grep "not available") || true | ||
| if [ -z "$portavailable" ]; then | ||
| # now prepare to paplay on this sink as the active port is not "not available" | ||
| # get the sink's name | ||
| sinkname=$(pactlinfo.py --getsinkname "$i") | ||
| sinkname=$(eval echo "$sinkname") | ||
| dlogi "===== Testing: (Round: $round/$round_cnt) (sink: $sinkname.$actport) =====" | ||
| dlogc "paplay -v --device=$sinkname --raw --rate=$rate --format=$format --channels=$channel $file" | ||
| paplay -v --device="$sinkname" --raw --rate=$rate --format=$format --channels=$channel $file & | ||
| pid=$! | ||
| sleep $duration | ||
| # check whether process is still running | ||
| count=$(ps -A| grep -c $pid) || true | ||
| if [[ $count -eq 0 ]]; then | ||
| if wait $pid; then #checks if process executed successfully or not | ||
aiChaoSONG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| dlogi "paplay has stopped successfully" | ||
| else | ||
| die "paplay on $sinkname failed (returned $?)" | ||
| fi | ||
| else | ||
| dlogi "paplay runs successfully" | ||
| # kill all paplay process | ||
| kill -9 $pid | ||
| sleep 0.5 | ||
| fi | ||
| fi | ||
| done | ||
| done | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| #!/bin/bash | ||
|
|
||
| ## | ||
| ## Case Name: check-userspace-parecord | ||
| ## Preconditions: | ||
| ## N/A | ||
| ## Description: | ||
| ## Go through all the sources and parecord on the sources whose | ||
| ## active port is available (jack connected) or unknown (DMIC) | ||
| ## Case step: | ||
| ## 1. go through all the sources | ||
| ## 2. check the source's active port is available or not | ||
| ## 3. parecord on the active port which is available or unknown | ||
| ## Expect result: | ||
| ## parecord on the source successfully | ||
| ## | ||
|
|
||
| set -e | ||
|
|
||
| # shellcheck source=case-lib/lib.sh | ||
| source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh | ||
|
|
||
| # check pulseaudio runs properly or not | ||
| func_lib_check_pa || die "Please check whether pulseaudio runs correctly or not" | ||
|
|
||
| OPT_OPT_lst['r']='round' OPT_DESC_lst['r']='round count' | ||
| OPT_PARM_lst['r']=1 OPT_VALUE_lst['r']=3 | ||
|
|
||
| OPT_OPT_lst['d']='duration' OPT_DESC_lst['d']='parecord duration in second' | ||
| OPT_PARM_lst['d']=1 OPT_VALUE_lst['d']=8 | ||
|
|
||
| OPT_OPT_lst['f']='file' OPT_DESC_lst['f']='source file path' | ||
| OPT_PARM_lst['f']=1 OPT_VALUE_lst['f']='/dev/zero' | ||
|
|
||
| OPT_OPT_lst['F']='format' OPT_DESC_lst['F']='sample format' | ||
| OPT_PARM_lst['F']=1 OPT_VALUE_lst['F']=s16le | ||
|
|
||
| OPT_OPT_lst['R']='rate' OPT_DESC_lst['R']='sample rate' | ||
| OPT_PARM_lst['R']=1 OPT_VALUE_lst['R']=44100 | ||
|
|
||
| OPT_OPT_lst['C']='channels' OPT_DESC_lst['C']='channels' | ||
| OPT_PARM_lst['C']=1 OPT_VALUE_lst['C']=2 | ||
|
|
||
| func_opt_parse_option "$@" | ||
|
|
||
| round_cnt=${OPT_VALUE_lst['r']} | ||
| duration=${OPT_VALUE_lst['d']} | ||
| file=${OPT_VALUE_lst['f']} | ||
| format=${OPT_VALUE_lst['F']} | ||
| rate=${OPT_VALUE_lst['R']} | ||
| channel=${OPT_VALUE_lst['C']} | ||
|
|
||
| [[ -e $file ]] || { dlogw "$file does not exist, use /dev/zero as dummy playback source" && file=/dev/null; } | ||
|
|
||
| # TODO: check the parameter is valid or not | ||
|
|
||
| # go through all the sources | ||
| # get all the sources name | ||
| sourcekeys=$(pactlinfo.py --showsources) | ||
| for round in $(seq 1 $round_cnt); do | ||
| for i in $sourcekeys; do | ||
| sourcecard=$(pactlinfo.py --getsourcecardname "$i") || { | ||
| dlogw "failed to get source $i card_name" | ||
| continue | ||
| } | ||
|
|
||
| # Let's skip testing on USB card | ||
| # TODO: add a list for other skipped cards such as HDA | ||
| if echo "$sourcecard" |grep -q -i "usb"; then | ||
| continue | ||
| fi | ||
|
|
||
| sourceclass=$(pactlinfo.py --getsourcedeviceclass "$i") || { | ||
| dlogw "failed to get source $i device class" | ||
| continue | ||
| } | ||
| # Let's skip the monitor sources | ||
| if echo "$sourceclass" |grep "monitor" &>/dev/null; then | ||
| continue | ||
| fi | ||
|
|
||
| # get the source's active port | ||
| actport=$(pactlinfo.py --getsourceactport "$i") || { | ||
| dlogw "failed to get source $i active port" | ||
| continue | ||
| } | ||
| # get the active port's information | ||
| actportvalue=$(pactlinfo.py --getsourceportinfo "$actport") || { | ||
| dlogw "failed to get source $i active port $actport info" | ||
| continue | ||
| } | ||
| # check the active port is available or not from the port's information | ||
| portavailable=$(echo "$actportvalue" |grep "not available") || true | ||
| if [ -z "$portavailable" ]; then | ||
| # now prepare to parecord on this source as the active port is not "not available" | ||
| # get the source's name | ||
| sourcename=$(pactlinfo.py --getsourcename "$i") | ||
| sourcename=$(eval echo "$sourcename") | ||
| dlogi "===== Testing: (Round: $round/$round_cnt) (source: $sourcename.$actport) =====" | ||
| dlogc "parecord -v --device=$sourcename --raw --rate=$rate --format=$format --channels=$channel $file" | ||
| parecord -v --device="$sourcename" --raw --rate=$rate --format=$format --channels=$channel $file & | ||
| pid=$! | ||
| sleep $duration | ||
| # check whether process is still running | ||
| count=$(ps -A| grep -c $pid) || true | ||
| if [[ $count -eq 0 ]]; then | ||
| if wait $pid; then #checks if process executed successfully or not | ||
| die "parecord has stopped successfully, which is abnormal" | ||
| else | ||
| die "parecord on $sourcename failed (returned $?)" | ||
| fi | ||
| else | ||
| dlogi "parecord runs successfully" | ||
| # kill all parecord processes | ||
| kill -9 $pid | ||
| sleep 0.5 | ||
| fi | ||
| fi | ||
|
|
||
| done | ||
| done |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.