Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions case-lib/hijack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,14 @@ function func_exit_handler()
wcLog=$(wc -l "$logfile")
dlogi "nlines=$wcLog"
fi
# when case ends, store kernel log
# /var/log/kern.log format:
# f1 f2 f3 f4 f5 f6 f7 f8...
# Mouth day Time MachineName kernel: [ time] content
# May 15 21:28:38 MachineName kernel: [ 6.469255] sof-audio-pci 0000:00:0e.0: ipc rx: 0x90020000: GLB_TRACE_MSG
# May 15 21:28:38 MachineName kernel: [ 6.469268] sof-audio-pci 0000:00:0e.0: ipc rx done: 0x90020000: GLB_TRACE_MSG
if [[ -n "$DMESG_LOG_START_LINE" && "$DMESG_LOG_START_LINE" -ne 0 ]]; then
tail -n +"$DMESG_LOG_START_LINE" /var/log/kern.log |cut -f5- -d ' ' > "$LOG_ROOT/dmesg.txt"

if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then
journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "$LOG_ROOT/dmesg.txt"
else
cut -f5- -d ' ' /var/log/kern.log > "$LOG_ROOT/dmesg.txt"
die "Kernel check point is not properly setup"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

die "KERNEL_CHECKPOINT is not properly setup"

Much faster git grep when this happens.

Copy link
Author

@aiChaoSONG aiChaoSONG Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally, this should not happen, I just want to use this to tell the case owner that he/she should setup up check point.
could you please explain more on git grep?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When someone sees the message with KERNEL_CHECKPOINT then they can immediately git grep that and find all relevant locations in sof-test.

fi
# After log collected, KERNEL_CHECKPOINT will not be used any more
unset KERNEL_CHECKPOINT

# get ps command result as list
local -a cmd_lst
Expand Down
16 changes: 5 additions & 11 deletions case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ if [ ! "$SOFCARD" ]; then
awk '/sof-[a-z]/ && $1 ~ /^[0-9]+$/ { $1=$1; print $1; exit 0;}')
fi

func_lib_setup_kernel_checkpoint()
setup_kernel_check_point()
{
# shellcheck disable=SC2034 # external script will use it
KERNEL_CHECKPOINT=$(date +%s)
# There is a 5s delay between two cases by sof-framework,
# make the check point 5s earlier to avoid log loss.
export KERNEL_CHECKPOINT=$(($(date +%s) - 5))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still belong to a different PR but OK, it's in a different commit and it's a small enough change. Small in number of lines, not in consequences...

Can you please

  1. Add this to the comment:
# There is a 5s delay between two cases by sof-framework,
# make the check point 5s earlier to avoid log loss.
# Note this can make an error caused by one test appear in the next one
  1. Make the 5s a global, $SOF_TEST_INTERVAL variable and use it here?

}

# This function adds a fake error to dmesg (which is always saved by
Expand Down Expand Up @@ -326,13 +327,6 @@ die()
exit 1
}

# force ask buffer data write into file system
sudo sync -f || true
# catch kern.log last line as current case start line
if [ ! "$DMESG_LOG_START_LINE" ]; then
DMESG_LOG_START_LINE=$(wc -l /var/log/kern.log|awk '{print $1;}')
fi

is_sof_used()
Copy link
Collaborator

@marc-hb marc-hb Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an ideal world every commit should be usable for bisecatability, cherry-picking, reverting, etc. reasons. I guess this implies the entire DMESG_LOG_START_LINE removal should be a single commit? Good the second commit does not even have a commit message :-)

{
grep -q "sof" /proc/asound/cards;
Expand All @@ -342,5 +336,5 @@ is_sof_used()
journalctl_cmd()
{
journalctl -k -q --no-pager --utc --output=short-monotonic \
--no-hostname "$@"
--no-hostname --boot "$@"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-k implies --boot, please remove this.

Feel free to expand -k to --kernel. Short options are meant to save typing time on the command line but they are less readable in scripts which are read many times more than they are written.

}
1 change: 1 addition & 0 deletions test-case/check-alsabat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data wi
OPT_HAS_ARG['s']=0 OPT_VAL['s']=1

func_opt_parse_option "$@"
setup_kernel_check_point

pcm_p=${OPT_VAL['p']}
pcm_c=${OPT_VAL['c']}
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-capture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ file_prefix=${OPT_VAL['f']}

[[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect

func_lib_setup_kernel_checkpoint
setup_kernel_check_point
func_lib_check_sudo
func_pipeline_export "$tplg" "type:capture & ${OPT_VAL['S']}"

Expand Down
2 changes: 1 addition & 1 deletion test-case/check-fw-echo-reference.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ frequency=${OPT_VAL['f']}
[[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect

func_pipeline_export "$tplg" "echo:any"
func_lib_setup_kernel_checkpoint
setup_kernel_check_point

if [ "$PIPELINE_COUNT" != "2" ]; then
die "Only detect $PIPELINE_COUNT pipeline(s) from topology, but two are needed"
Expand Down
3 changes: 2 additions & 1 deletion test-case/check-ipc-flood.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ OPT_NAME['l']='loop' OPT_DESC['l']='loop count'
OPT_HAS_ARG['l']=1 OPT_VAL['l']=1

func_opt_parse_option "$@"
setup_kernel_check_point

lpc_loop_cnt=${OPT_VAL['c']}
ipc_flood_dfs=${OPT_VAL['f']}
Expand All @@ -44,7 +45,7 @@ do
# cleanup dmesg buffer for each iteration
sudo dmesg -c > /dev/null
# set up timestamp for each iteration
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
dlogi "===== [$i/$loop_cnt] loop Begin ====="
dlogc "sudo bash -c 'echo $lpc_loop_cnt > $ipc_flood_dfs'"
sudo bash -c "'echo $lpc_loop_cnt > $ipc_flood_dfs'"
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-keyword-detection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ duration=${OPT_VAL['d']}
[[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect

func_pipeline_export "$tplg" "kpbm:any"
func_lib_setup_kernel_checkpoint
setup_kernel_check_point

if test "$PIPELINE_COUNT" != "1"; then
die "detected $PIPELINE_COUNT wov pipeline(s) from topology, but 1 is needed"
Expand Down
2 changes: 2 additions & 0 deletions test-case/check-kmod-load-unload-after-playback.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ fi

for counter in $(seq 1 $loop_cnt)
do
# Only collect the latest success/failure logs
setup_kernel_check_point
dlogi "===== Starting iteration $counter of $loop_cnt ====="

# logic: if this case disables pulseaudio, the sub case does not need to disable pulseaudio
Expand Down
6 changes: 3 additions & 3 deletions test-case/check-kmod-load-unload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ OPT_NAME['p']='pulseaudio' OPT_DESC['p']='disable pulseaudio on the test proce
OPT_HAS_ARG['p']=0 OPT_VAL['p']=1

func_opt_parse_option "$@"
func_lib_setup_kernel_checkpoint
setup_kernel_check_point

loop_cnt=${OPT_VAL['l']}

Expand All @@ -48,7 +48,7 @@ for idx in $(seq 1 $loop_cnt)
do
dlogi "===== Starting iteration $idx of $loop_cnt ====="
## - 1: remove module section
func_lib_setup_kernel_checkpoint
setup_kernel_check_point

# After module removal, it takes about 10s for "aplay -l" to show
# device list, within this 10s, it shows "no soundcard found". Here
Expand Down Expand Up @@ -78,7 +78,7 @@ do
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" ||
die "error found after kmod unload is real error, failing"

func_lib_setup_kernel_checkpoint
setup_kernel_check_point
dlogi "run kmod/sof_insert.sh"
sudo sof_insert.sh || {
# FIXME: don't exit the status of dloge(). Use die()
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-pause-release-suspend-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ esac

[[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect

func_lib_setup_kernel_checkpoint
setup_kernel_check_point

dlogi "Entering audio stream expect script with: $cmd -D $pcm -r $rate -c $channel -f $fmt -vv -i $dummy_file -q"
dlogi "Will enter suspend-resume cycle during paused period of audio stream process"
Expand Down
3 changes: 2 additions & 1 deletion test-case/check-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ OPT_NAME['S']='filter_string' OPT_DESC['S']="run this case on specified pipeli
OPT_HAS_ARG['S']=1 OPT_VAL['S']="id:any"

func_opt_parse_option "$@"
setup_kernel_check_point

tplg=${OPT_VAL['t']}
test_mode=${OPT_VAL['m']}
Expand Down Expand Up @@ -81,7 +82,7 @@ func_pipeline_export "$tplg" "type:$test_mode & ${OPT_VAL['S']}"
for idx in $(seq 0 $((PIPELINE_COUNT - 1)))
do
# set up checkpoint for each iteration
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
channel=$(func_pipeline_parse_value "$idx" channel)
rate=$(func_pipeline_parse_value "$idx" rate)
fmt=$(func_pipeline_parse_value "$idx" fmt)
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-playback.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ else
dlogi "using $file as playback source"
fi

func_lib_setup_kernel_checkpoint
setup_kernel_check_point
func_lib_check_sudo
func_pipeline_export "$tplg" "type:playback & ${OPT_VAL['S']}"

Expand Down
3 changes: 2 additions & 1 deletion test-case/check-reboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ $old_content

$boot_once_flag
export LOG_ROOT='$(realpath $LOG_ROOT)'
export DMESG_LOG_START_LINE=$(wc -l /var/log/kern.log|awk '{print $1;}')
setup_kernel_check_point
export KERNEL_CHECKPOINT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining why this one needs the export when the others don't?

Wouldn't it be simpler to export KERNEL_CHECKPOINT always? If not why not?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this is a mistake from previously version, the export KERNEL_CHECKPOINT should be removed.

bash -c '$full_cmd'

exit 0
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-runtime-pm-double-active.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ do
for i in $(seq 1 $loop_count)
do
# set up checkpoint for each iteration
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
dlogi "===== Iteration $i of $loop_count for $pcm ====="
# playback or capture device - check status
dlogc "$cmd -D $dev -r $rate -c $channel -f $fmt $dummy_file -q"
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-runtime-pm-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ do
for i in $(seq 1 $loop_count)
do
# set up checkpoint for each iteration
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
dlogi "===== Iteration $i of $loop_count for $pcm ====="
# playback or capture device - check status
dlogc "$cmd -D $dev -r $rate -c $channel -f $fmt $dummy_file -q"
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-signal-stop-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ case $test_mode in
;;
esac

func_lib_setup_kernel_checkpoint
setup_kernel_check_point

func_stop_start_pipeline()
{
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-smart-amplifier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ tplg=${OPT_VAL['t']}
[[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect

func_pipeline_export "$tplg" "smart_amp:any"
func_lib_setup_kernel_checkpoint
setup_kernel_check_point

[ "$PIPELINE_COUNT" == "2" ] || die "Only detect $PIPELINE_COUNT pipeline(s) from topology, but two are needed"

Expand Down
3 changes: 1 addition & 2 deletions test-case/check-sof-logger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ func_opt_parse_option "$@"

#TODO: need to add arguments for user to give location for logger and ldc file

# hijack DMESG_LOG_START_LINE which refer dump kernel log in exit function
DMESG_LOG_START_LINE=$(sof-get-kernel-line.sh|tail -n 1 |awk '{print $1;}')
setup_kernel_check_point

# check sof-logger location
if [ -z $(which sof-logger) ]; then
Expand Down
3 changes: 2 additions & 1 deletion test-case/check-suspend-resume-with-audio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ OPT_NAME['P']='pipelines' OPT_DESC['P']="run test case on specified pipelines"
OPT_HAS_ARG['P']=1 OPT_VAL['P']="id:any"

func_opt_parse_option "$@"
setup_kernel_check_point
func_lib_check_sudo

tplg=${OPT_VAL['t']}
Expand Down Expand Up @@ -91,7 +92,7 @@ fi
for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1))
do
# set up checkpoint for each iteration
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
# store local checkpoint as we have sub-test
LOCAL_CHECK_POINT="$KERNEL_CHECKPOINT"
channel=$(func_pipeline_parse_value $idx channel)
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-suspend-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ for i in $(seq 1 $loop_count)
do
dlogi "===== Round($i/$loop_count) ====="
# set up checkpoint for each iteration
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
sleep_count=$(cat /sys/power/wakeup_count)
dlogc "Run the command: rtcwake -m mem -s ${sleep_lst[$i]}"
sudo rtcwake -m mem -s ${sleep_lst[$i]}
Expand Down
2 changes: 1 addition & 1 deletion test-case/check-xrun-injection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interval=${OPT_VAL['i']}

[[ ${OPT_VAL['s']} -eq 1 ]] && func_lib_start_log_collect

func_lib_setup_kernel_checkpoint
setup_kernel_check_point
func_lib_check_sudo

case $test_mode in
Expand Down
2 changes: 1 addition & 1 deletion test-case/multiple-pause-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ for i in $(seq 1 $loop_count)
do
dlogi "===== Loop count( $i / $loop_count ) ====="
# set up checkpoint for each iteration
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
for pipeline_combine_str in "${pipeline_combine_lst[@]}"
do
unset pid_lst
Expand Down
2 changes: 1 addition & 1 deletion test-case/multiple-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ ps_checks()
for i in $(seq 1 $loop_cnt)
do
# set up checkpoint for each iteration
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
dlogi "===== Testing: (Loop: $i/$loop_cnt) ====="

# start playback or capture:
Expand Down
4 changes: 3 additions & 1 deletion test-case/simultaneous-playback-capture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ OPT_NAME['l']='loop' OPT_DESC['l']='loop count'
OPT_HAS_ARG['l']=1 OPT_VAL['l']=1

func_opt_parse_option "$@"
setup_kernel_check_point

tplg=${OPT_VAL['t']}
wait_time=${OPT_VAL['w']}
loop_cnt=${OPT_VAL['l']}
Expand Down Expand Up @@ -69,7 +71,7 @@ func_error_exit()
for i in $(seq 1 $loop_cnt)
do
# set up checkpoint for each iteration
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
dlogi "===== Testing: (Loop: $i/$loop_cnt) ====="
# following sof-tplgreader, split 'both' pipelines into separate playback & capture pipelines, with playback occurring first
for order in $(seq 0 2 $(expr $PIPELINE_COUNT - 1))
Expand Down
2 changes: 1 addition & 1 deletion test-case/test-speaker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tplg=${OPT_VAL['t']}

func_pipeline_export "$tplg" "type:playback"
tcnt=${OPT_VAL['l']}
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1))
do
channel=$(func_pipeline_parse_value $idx channel)
Expand Down
1 change: 1 addition & 0 deletions test-case/verify-firmware-presence.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set -e
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh

func_opt_parse_option "$@"
setup_kernel_check_point

path=$(sof-dump-status.py -P)
platform=$(sof-dump-status.py -p)
Expand Down
3 changes: 1 addition & 2 deletions test-case/verify-kernel-module-load-probe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh

func_opt_parse_option "$@"

# hijack DMESG_LOG_START_LINE which refer dump kernel log in exit function
DMESG_LOG_START_LINE=$(sof-get-kernel-line.sh|tail -n 1 |awk '{print $1;}')
setup_kernel_check_point

dlogi "Checking if sof relative modules loaded"
dlogc "lsmod | grep \"sof\""
Expand Down
3 changes: 1 addition & 2 deletions test-case/verify-pcm-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ tplg=${OPT_VAL['t']}
tplg_path=`func_lib_get_tplg_path "$tplg"`
[[ "$?" != "0" ]] && die "No available topology for this test case"

# hijack DMESG_LOG_START_LINE which refer dump kernel log in exit function
DMESG_LOG_START_LINE=$(sof-get-kernel-line.sh|tail -n 1 |awk '{print $1;}')
setup_kernel_check_point

tplg_str="$(sof-tplgreader.py $tplg_path -d id pcm type -o)"
pcm_str="$(sof-dump-status.py -i ${SOFCARD:-0})"
Expand Down
4 changes: 1 addition & 3 deletions test-case/verify-sof-firmware-load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh

func_opt_parse_option "$@"

# hijack DMESG_LOG_START_LINE to dump kernel from file start is not Sub-Test
# TODO: clean up Sub-Test feature
alias | grep -q 'Sub-Test' || DMESG_LOG_START_LINE=$(sof-get-kernel-line.sh | tail -n 1 | awk '{print $1;}' )
alias | grep -q 'Sub-Test' || setup_kernel_check_point

cmd="journalctl_cmd"

Expand Down
1 change: 1 addition & 0 deletions test-case/verify-tplg-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file, default value is env TPLG: $'
OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"

func_opt_parse_option "$@"
setup_kernel_check_point
tplg=${OPT_VAL['t']}

tplg_path=`func_lib_get_tplg_path "$tplg"`
Expand Down
2 changes: 1 addition & 1 deletion test-case/volume-basic-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dlogi "pgalist number = ${#pgalist[@]}"

for i in $(seq 1 $maxloop)
do
func_lib_setup_kernel_checkpoint
setup_kernel_check_point
dlogi "===== Round($i/$maxloop) ====="
# TODO: need to check command effect
for i in "${pgalist[@]}"
Expand Down