-
Notifications
You must be signed in to change notification settings - Fork 59
ALSA reset #1284
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
ALSA reset #1284
Conversation
Reuse set_alsa() function in test cases: check-alsa-conformance.sh check-alsabat.sh latency-metrics.sh Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
3ec5054 to
00a2d21
Compare
Add log message to `reset_sof_volume()`. Stop with `die` on incorrect ALSA tool the same way, as at the other places. Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
00a2d21 to
1a82c40
Compare
Fix `shellcheck` warinings in check-alsabat.sh Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
b319db5 to
3919ac5
Compare
case-lib/lib.sh
Outdated
| dlogi "Try to initialize all devices to their default ALSA state (alsactl init)." | ||
| printf '%s\n' '-vv------- ALSA init -------vv-' > "${alsa_log}" | ||
| alsactl -d init >> "${alsa_log}" 2>&1 || rc=$? | ||
| [[ "${rc}" -ne 0 ]] && dlogw "alsactl init error=${rc}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just:
| [[ "${rc}" -ne 0 ]] && dlogw "alsactl init error=${rc}" | |
| alsactl -d init ... || dlogw "alsactl init error=$?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dlogw clears $?, so it looks like
ls /foo || dloge "error=$?"
ls: cannot access '/foo': No such file or directory
2025-07-23 18:44:58 UTC [ERROR] error=0
vs.
ls /foo || rc=$? ; dloge "error=$rc"
ls: cannot access '/foo': No such file or directory
2025-07-23 18:43:36 UTC [ERROR] error=2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG, they are aliases! Could you try to submit this fix that converts aliases to proper functions? I tested this change in isolation and it fixes the issue but I don't have time to submit it to CI.
Don't take the second diff hunk, it's just a hack to test locally.
--- a/case-lib/logging_ctl.sh
+++ b/case-lib/logging_ctl.sh
@@ -44,14 +44,15 @@ _func_log_cmd()
for key in "${!LOG_LIST[@]}";
do
- # dymaic alias the command with different content
- cmd="alias $key='echo \$(date -u \"+%F %T %Z\")$ext_message ${LOG_LIST[$key]}'"
+ # shellcheck disable=SC2016
+ local date_cmd='$(date -u "+%F %T %Z")'
+ local cmd="$key() { printf '%s%s %s\n' \"$date_cmd\" '$ext_message ${LOG_LIST[$key]}' \"\$*\" ; }"
eval "$cmd"
done
}
# without setting up the LOG_ROOT keyword, now create the log directory for it
-_func_log_directory()
+_Xfunc_log_directory()
{
# LOG_ROOT is the top of a single test run. SOF_LOGS_BASE is higher
# up and for all tests and all runs.source case-lib/logging_ctl.sh
( exit 5 ) || dlogw "hello $?"
2025-07-23 20:01:08 UTC [WARNING] hello 5There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG, they are aliases! Could you try to submit this fix that converts aliases to proper functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1286 just merged, now this could be fixed.
At least it won't be needed elsewhere now...
|
SOFCI TEST |
4da8136 to
1307ec7
Compare
|
SOFCI TEST |
a5b87c8 to
bd17598
Compare
Reset ALSA settings with `alsactl init` and `alsactl restore` at `set_alsa()` before it calls `set_alsa_settings` which runs HW model-specific configuration scripts. This way a test case can expect that the `set_alsa` call will apply the DUT's ALSA mixer settings as the baseline configuration to avoid side-effects possible after the previous tests execution (either passed, or failed) as well as other unexpected changes. Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
bd17598 to
549d7ba
Compare
|
dear reviewers, do you have comments or objections ? |
kv2019i
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @golowanow !
| local rc=0 | ||
|
|
||
| # Read the ALSA restore service status | ||
| systemctl --no-pager status alsa-restore.service > "${alsa_log}" 2>&1 || rc=$? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose you could just rc=$? unconditionally after the systemctl call and remove the initialisation of rc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, its my intent to deal with rc explicitly and to tie command calls and rc set, so it is declared as a local variable at this function with init value and, despite any change in the following command calls, it will have the default value.
With command || rc=$? the script works the same way if it runs with bash -e - continue its execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| # Read the ALSA restore service status | ||
| systemctl --no-pager status alsa-restore.service > "${alsa_log}" 2>&1 || rc=$? | ||
| [[ "${rc}" -ne 0 ]] && dlogw "alsa-restore check error=${rc}" && rc=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if for whatever reason dlogw exits with an error, rc won't be reset. I'd just use if here for determinism. More of these below, I'd be more explicit with rc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when dlogw fails (something really bad ? hopefully with some stderr output) the rc should not reset to zero as well.
majunkier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Reset ALSA settings with
alsactl initandalsactl restoreatset_alsa()before it callsset_alsa_settingswhich runs HW model-specific configuration scripts.This way a test case can expect that the
set_alsacall will apply the DUT's default ALSA settings as the baseline configuration to avoid side-effects possible after the previous tests execution (either passed, or failed) as well as other unexpected changes.