From 127494e3b135a92d85b867874fe3213d39445d63 Mon Sep 17 00:00:00 2001 From: Amery Song Date: Wed, 18 Nov 2020 13:36:00 +0800 Subject: [PATCH 1/3] test-case: refine multiple-pipeline-playback/capture In these two cases, The variable tmp_count is used and modified everywhere, this is error-prone. This patch refine code structure, renames some variables and add some debug logs to root cause sof-test#472 Signed-off-by: Amery Song --- test-case/multiple-pipeline-capture.sh | 32 +++++++++++++++---------- test-case/multiple-pipeline-playback.sh | 32 +++++++++++++++---------- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/test-case/multiple-pipeline-capture.sh b/test-case/multiple-pipeline-capture.sh index fad79fd6..4b971902 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() { @@ -110,6 +108,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 +121,14 @@ 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" + 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" # 2. check arecord process status dlogi "checking pipeline status" @@ -137,12 +141,14 @@ 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" + 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" # 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..b19f7f1e 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() { @@ -107,6 +105,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 +118,14 @@ 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" + 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" # 2. check arecord process status dlogi "checking pipeline status" @@ -134,12 +138,14 @@ 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" + 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" # 4. check arecord process status dlogi "checking pipeline again" From a9004e9678cc781c11ea91b10d71f340db31ae87 Mon Sep 17 00:00:00 2001 From: Amery Song Date: Wed, 18 Nov 2020 13:42:15 +0800 Subject: [PATCH 2/3] test-case: make pipeline count check a function Signed-off-by: Amery Song --- test-case/multiple-pipeline-capture.sh | 27 ++++++++++++------------- test-case/multiple-pipeline-playback.sh | 27 ++++++++++++------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/test-case/multiple-pipeline-capture.sh b/test-case/multiple-pipeline-capture.sh index 4b971902..e2f9010b 100755 --- a/test-case/multiple-pipeline-capture.sh +++ b/test-case/multiple-pipeline-capture.sh @@ -103,6 +103,17 @@ func_error_exit() exit 1 } +check_running_pipeline_count() +{ + 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) do dlogi "===== Testing: (Loop: $i/$loop_cnt) =====" @@ -122,13 +133,7 @@ do # check all refer capture pipeline status # 1. check process count: dlogi "checking started playback and capture process count" - 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" + check_running_pipeline_count # 2. check arecord process status dlogi "checking pipeline status" @@ -142,13 +147,7 @@ do # 3. check process count again: dlogi "checking existing playback and capture process count" - 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" + 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 b19f7f1e..48c1bb2b 100755 --- a/test-case/multiple-pipeline-playback.sh +++ b/test-case/multiple-pipeline-playback.sh @@ -100,6 +100,17 @@ func_error_exit() exit 1 } +check_running_pipeline_count() +{ + 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) do dlogi "===== Testing: (Loop: $i/$loop_cnt) =====" @@ -119,13 +130,7 @@ do # check all refer capture pipeline status # 1. check process count: dlogi "checking started playback and capture process count" - 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" + check_running_pipeline_count # 2. check arecord process status dlogi "checking pipeline status" @@ -139,13 +144,7 @@ do # 3. check process count again: dlogi "checking existing playback and capture process count" - 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" + check_running_pipeline_count # 4. check arecord process status dlogi "checking pipeline again" From 4ad1a26c35287a96a37a829b5d8fb809651813dd Mon Sep 17 00:00:00 2001 From: Amery Song Date: Wed, 18 Nov 2020 13:47:06 +0800 Subject: [PATCH 3/3] lib.sh: move func_error_exit to lib.sh This patch moves a common function func_error_exit to lib.sh to eliminate duplicated code in multiple-pipeline-playback.sh and multiple-pipeline- capture.sh Signed-off-by: Amery Song --- case-lib/lib.sh | 10 ++++++++++ test-case/multiple-pipeline-capture.sh | 10 ---------- test-case/multiple-pipeline-playback.sh | 10 ---------- 3 files changed, 10 insertions(+), 20 deletions(-) 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 e2f9010b..ffcf8ca0 100755 --- a/test-case/multiple-pipeline-capture.sh +++ b/test-case/multiple-pipeline-capture.sh @@ -93,16 +93,6 @@ func_run_pipeline_with_type() done } -func_error_exit() -{ - dloge "$*" - pgrep -a aplay - pgrep -a arecord - pkill -9 aplay - pkill -9 arecord - exit 1 -} - check_running_pipeline_count() { arecord_count=$(pidof arecord | wc -w) diff --git a/test-case/multiple-pipeline-playback.sh b/test-case/multiple-pipeline-playback.sh index 48c1bb2b..e6d79dea 100755 --- a/test-case/multiple-pipeline-playback.sh +++ b/test-case/multiple-pipeline-playback.sh @@ -90,16 +90,6 @@ func_run_pipeline_with_type() done } -func_error_exit() -{ - dloge "$*" - pgrep -a aplay - pgrep -a arecord - pkill -9 aplay - pkill -9 arecord - exit 1 -} - check_running_pipeline_count() { arecord_count=$(pidof arecord | wc -w)