Skip to content
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

Add test case for sof component performance check #1090

Merged
merged 2 commits into from
Aug 23, 2023
Merged
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
8 changes: 8 additions & 0 deletions case-lib/hijack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ function func_exit_handler()
exit_status=$ret
fi

# Only do performance analysis on test passed
[ "x$exit_status" != "x0" ] || {
# On performance analysis return error, set exit code
if ! perf_analyze; then
exit_status=1
fi
}

# We must always print some 'Test Result' otherwise some callers
# will time out. These strings must match (at least) Jenkins'
# expectations, see internal sof-framework/clsTestCase.py
Expand Down
26 changes: 26 additions & 0 deletions case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -872,4 +872,30 @@ reset_sof_volume()
done
}

DO_PERF_ANALYSIS=0

perf_analyze()
{
local perf_cmd

[ "X$DO_PERF_ANALYSIS" == "X1" ] || return 0

dlogi "Checking SOF component performance"
if [ -e "$LOG_ROOT/mtrace.txt" ]; then
if [ -e "$LOG_ROOT/dmesg.txt" ]; then
perf_cmd="sof_perf_analyzer.py --kmsg=$LOG_ROOT/dmesg.txt $LOG_ROOT/mtrace.txt"
else
perf_cmd="sof_perf_analyzer.py $LOG_ROOT/mtrace.txt"
fi
dlogc "$perf_cmd"
eval "$perf_cmd" || {
dloge "SOF component performace analysis tool exit with error"
return 1
}
else
dloge "Firmware trace file not found"
return 1
fi
}

start_test
75 changes: 75 additions & 0 deletions test-case/check-performance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

##
## Case Name: check-performance
## Preconditions:
## N/A
## Description:
## Run aplay and arecord to playback and capture
## pipelines of the benchmark topology:
## sof-hda-benchmark-generic-PLATFORM.tplg
## Case step:
## 1. Parse TPLG file to get pipeline with type of playback
## and capture (exclude HDMI pipeline)
## 2. Specify the audio parameters
## 3. Run aplay and arecord on each pipeline with audio parameters
## Expect result:
## The return value of aplay/arecord is 0
## Performance statistics are printed
##

set -e

# It is pointless to perf component in HDMI pipeline, so filter out HDMI pipelines
# shellcheck disable=SC2034
NO_HDMI_MODE=true

# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh

OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file, default value is env TPLG: $''TPLG'
OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"

OPT_NAME['d']='duration' OPT_DESC['d']='aplay/arecord duration in second'
OPT_HAS_ARG['d']=1 OPT_VAL['d']=30

OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data will store at $LOG_ROOT"
OPT_HAS_ARG['s']=0 OPT_VAL['s']=1

func_opt_parse_option "$@"

tplg=${OPT_VAL['t']}
duration=${OPT_VAL['d']}

logger_disabled || func_lib_start_log_collect

setup_kernel_check_point
func_lib_check_sudo
func_pipeline_export "$tplg" "type:any"

for idx in $(seq 0 $((PIPELINE_COUNT - 1)))
do
channel=$(func_pipeline_parse_value "$idx" channel)
rate=$(func_pipeline_parse_value "$idx" rate)
dev=$(func_pipeline_parse_value "$idx" dev)
pcm=$(func_pipeline_parse_value "$idx" pcm)
type=$(func_pipeline_parse_value "$idx" type)

# Currently, copier will convert bit depth to S32_LE despite what bit depth
# is used in aplay, so make S32_LE as base bit depth for performance analysis.
fmt=S32_LE

dlogi "Running (PCM: $pcm [$dev]<$type>) in background"
if [ "$type" == "playback" ]; then
aplay_opts -D "$dev" -c "$channel" -r "$rate" -f "$fmt" -d "$duration" /dev/zero -q &
else
arecord_opts -D "$dev" -c "$channel" -r "$rate" -f "$fmt" -d "$duration" /dev/null -q &
fi
done

dlogi "Waiting for aplay/arecord process to exit"
sleep $((duration + 2))

# Enable performance analysis
# shellcheck disable=SC2034
DO_PERF_ANALYSIS=1