fix: tests: SRC tests catch aplay warnings and refactor#1351
fix: tests: SRC tests catch aplay warnings and refactor#1351KamilxPaszkiet merged 1 commit intothesofproject:mainfrom
Conversation
4fe141b to
1411b51
Compare
case-lib/lib.sh
Outdated
| check_for_aplay_warnings() | ||
| { | ||
| dlogi "$1" | ||
| if echo "$1" | grep -q "Warning:"; then |
There was a problem hiding this comment.
case-lib/lib.sh
Outdated
|
|
||
| # Check aplay output for warnings | ||
| # Arguments: 1-aplay output | ||
| check_for_aplay_warnings() |
There was a problem hiding this comment.
| check_for_aplay_warnings() | |
| check_for_warnings() |
case-lib/lib.sh
Outdated
| # shellcheck disable=SC2086 | ||
| arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $1 & PID=$! | ||
| # shellcheck disable=SC2181 | ||
| if [ $? -ne 0 ]; then |
There was a problem hiding this comment.
$? will never be useful when you background a command. To get the status of a backgrounded command you need to wait $PID
There was a problem hiding this comment.
Oh yeah you're right, I've missed that. Fixed :)
case-lib/lib.sh
Outdated
| # shellcheck disable=SC2086 | ||
| aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $2 | ||
| aplay_output=$(aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $2 2>&1) | ||
| # shellcheck disable=SC2181 |
There was a problem hiding this comment.
Why not just:
aplay_output=$(aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $2 2>&1) || errors=$((errors+1))
case-lib/lib.sh
Outdated
| fi | ||
| # shellcheck disable=SC2086 | ||
| aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $2 | ||
| aplay_output=$(aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $2 2>&1) |
There was a problem hiding this comment.
Capturing output loses "real-time" feedback. You can (and should) have both with something like this:
set -o pipefail
aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $2 2>&1 | tee _.log || errors=$((errors+1))
check_warnings _.log
There are other ways:
https://stackoverflow.com/questions/1221833/pipe-output-and-capture-exit-status-in-bash
There was a problem hiding this comment.
Okay I've refactored the whole func a little bit again, now it prints log to the console and also captures it for further analysis
|
Forgot to mention this: The "real" fix should be in |
35029cb to
d58bfa4
Compare
Catch aplay incorrect sample rate warnings and refactor tests Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
What's changed: