diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 109bbe9f..c975f364 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -270,3 +270,13 @@ is_sof_used() { grep -q "sof" /proc/asound/cards; } + +func_error_exit() +{ + dloge "$*" + pgrep -a aplay + pgrep -a arecord + pkill -9 aplay + pkill -9 arecord + exit 1 +} diff --git a/test-case/multiple-pipeline-capture.sh b/test-case/multiple-pipeline-capture.sh index fad79fd6..ffcf8ca0 100755 --- a/test-case/multiple-pipeline-capture.sh +++ b/test-case/multiple-pipeline-capture.sh @@ -63,8 +63,6 @@ DEV_LST['playback']='/dev/zero' APP_LST['capture']='arecord' DEV_LST['capture']='/dev/null' -tmp_count=$max_count - # define for load pipeline func_run_pipeline_with_type() { @@ -95,14 +93,15 @@ func_run_pipeline_with_type() done } -func_error_exit() +check_running_pipeline_count() { - dloge "$*" - pgrep -a aplay - pgrep -a arecord - pkill -9 aplay - pkill -9 arecord - exit 1 + arecord_count=$(pidof arecord | wc -w) + dlogi "$arecord_count capture process is running" + aplay_count=$(pidof aplay | wc -w) + dlogi "$aplay_count playback process is running" + overall_count=$((arecord_count + aplay_count)) + [[ $overall_count -eq $max_count ]] || + func_error_exit "$max_count pipelines started, but only $overall_count pipelines detected" } for i in $(seq 1 $loop_cnt) @@ -110,6 +109,9 @@ do dlogi "===== Testing: (Loop: $i/$loop_cnt) =====" # clean up dmesg sudo dmesg -C + # this variable is modified in func_run_pipeline_with_type, + # need to reassign at every iteration + tmp_count=$max_count # start capture: func_run_pipeline_with_type "capture" @@ -120,11 +122,8 @@ do # check all refer capture pipeline status # 1. check process count: - pcount=$(pidof arecord|wc -w) - tmp_count=$((tmp_count + pcount)) - pcount=$(pidof aplay|wc -w) - tmp_count=$((tmp_count + pcount)) - [[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count" + dlogi "checking started playback and capture process count" + check_running_pipeline_count # 2. check arecord process status dlogi "checking pipeline status" @@ -137,12 +136,8 @@ do sleep ${OPT_VALUE_lst['w']} # 3. check process count again: - tmp_count=0 - pcount=$(pidof arecord|wc -w) - tmp_count=$((tmp_count + pcount)) - pcount=$(pidof aplay|wc -w) - tmp_count=$((tmp_count + pcount)) - [[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count" + dlogi "checking existing playback and capture process count" + check_running_pipeline_count # 4. check arecord process status dlogi "checking pipeline status again" diff --git a/test-case/multiple-pipeline-playback.sh b/test-case/multiple-pipeline-playback.sh index f51c00aa..e6d79dea 100755 --- a/test-case/multiple-pipeline-playback.sh +++ b/test-case/multiple-pipeline-playback.sh @@ -60,8 +60,6 @@ DEV_LST['playback']='/dev/zero' APP_LST['capture']='arecord' DEV_LST['capture']='/dev/null' -tmp_count=$max_count - # define for load pipeline func_run_pipeline_with_type() { @@ -92,14 +90,15 @@ func_run_pipeline_with_type() done } -func_error_exit() +check_running_pipeline_count() { - dloge "$*" - pgrep -a aplay - pgrep -a arecord - pkill -9 aplay - pkill -9 arecord - exit 1 + arecord_count=$(pidof arecord | wc -w) + dlogi "$arecord_count capture process is running" + aplay_count=$(pidof aplay | wc -w) + dlogi "$aplay_count playback process is running" + overall_count=$((arecord_count + aplay_count)) + [[ $overall_count -eq $max_count ]] || + func_error_exit "$max_count pipelines started, but only $overall_count pipelines detected" } for i in $(seq 1 $loop_cnt) @@ -107,6 +106,9 @@ do dlogi "===== Testing: (Loop: $i/$loop_cnt) =====" # clean up dmesg sudo dmesg -C + # this variable is modified in func_run_pipeline_with_type, + # need to reassign at every iteration + tmp_count=$max_count # start capture: func_run_pipeline_with_type "playback" @@ -117,11 +119,8 @@ do # check all refer capture pipeline status # 1. check process count: - pcount=$(pidof arecord|wc -w) - tmp_count=$(expr $tmp_count + $pcount) - pcount=$(pidof aplay|wc -w) - tmp_count=$(expr $tmp_count + $pcount) - [[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count" + dlogi "checking started playback and capture process count" + check_running_pipeline_count # 2. check arecord process status dlogi "checking pipeline status" @@ -134,12 +133,8 @@ do sleep ${OPT_VALUE_lst['w']} # 3. check process count again: - tmp_count=0 - pcount=$(pidof arecord|wc -w) - tmp_count=$(expr $tmp_count + $pcount) - pcount=$(pidof aplay|wc -w) - tmp_count=$(expr $tmp_count + $pcount) - [[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count" + dlogi "checking existing playback and capture process count" + check_running_pipeline_count # 4. check arecord process status dlogi "checking pipeline again"