|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +## |
| 4 | +## Case Name: test-compressed-audio |
| 5 | +## Preconditions: |
| 6 | +## - socwatch installed |
| 7 | +## - cplay installed |
| 8 | +## Description: |
| 9 | +## This test verifies if we enter PC10 state when playing MP3 with offload to DSP. |
| 10 | +## Case steps: |
| 11 | +## 1. Generate MP3 sound for testing. |
| 12 | +## 2. Start Socwatch measurement and play MP3 file. |
| 13 | +## 3. Analyze Socwatch results. |
| 14 | +## Expected results: |
| 15 | +## - generated MP3 is played |
| 16 | +## - dut stays in the PC10 state for the expected amount of time |
| 17 | +## |
| 18 | + |
| 19 | +# shellcheck source=case-lib/lib.sh |
| 20 | +source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh |
| 21 | + |
| 22 | +OPT_NAME['p']='pcm_p' OPT_DESC['p']='compression device for playback. Example: 50' |
| 23 | +OPT_HAS_ARG['p']=1 OPT_VAL['p']='' |
| 24 | + |
| 25 | +OPT_NAME['N']='channels_p' OPT_DESC['N']='channel number for playback.' |
| 26 | +OPT_HAS_ARG['N']=1 OPT_VAL['N']='2' |
| 27 | + |
| 28 | +OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data will store at $LOG_ROOT" |
| 29 | +OPT_HAS_ARG['s']=0 OPT_VAL['s']=1 |
| 30 | + |
| 31 | +OPT_NAME['d']='duration' OPT_DESC['d']='duration time for playing the test sound' |
| 32 | +OPT_HAS_ARG['d']=1 OPT_VAL['d']=10 |
| 33 | + |
| 34 | +OPT_NAME['pc10_per']='pc10_per' OPT_DESC['pc10_per']='pc10 state threshold - percentage of time that should be spent in pc10' |
| 35 | +OPT_HAS_ARG['pc10_per']=1 OPT_VAL['pc10_per']=80 |
| 36 | + |
| 37 | +: "${SOCWATCH_PATH:=$HOME/socwatch}" |
| 38 | + |
| 39 | +func_opt_parse_option "$@" |
| 40 | +setup_kernel_check_point |
| 41 | + |
| 42 | +pcm_p=${OPT_VAL['p']} |
| 43 | +channels_p=${OPT_VAL['N']} |
| 44 | +duration=${OPT_VAL['d']} |
| 45 | +pc10_threshold=${OPT_VAL['pc10_per']} |
| 46 | + |
| 47 | +analyze_socwatch_results() |
| 48 | +{ |
| 49 | + pc_states_file="$LOG_ROOT/pc_states.csv" |
| 50 | + touch "$pc_states_file" |
| 51 | + results=$(grep "Platform Monitoring Technology CPU Package C-States Residency Summary: Residency" -A 10 < "$socwatch_output".csv) |
| 52 | + echo "$results" | tee "$pc_states_file" |
| 53 | + |
| 54 | + expected_results="{\"PC10.2\":$pc10_threshold}" |
| 55 | + |
| 56 | + # Analyze if the % of the time spent in given PC state was as expected |
| 57 | + if python3 "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file" "$expected_results"; then |
| 58 | + dlogi "All Package Residency (%) values were as expected" |
| 59 | + else |
| 60 | + die "Some Package Residency (%) values different from expected!" |
| 61 | + fi |
| 62 | +} |
| 63 | + |
| 64 | +# Checks for soundfile needed for test, generates missing ones |
| 65 | +prepare_test_soundfile() |
| 66 | +{ |
| 67 | + if [ ! -f "$audio_filename" ]; then |
| 68 | + dlogi "Generating audio file for the test..." |
| 69 | + generate_mp3_file "$audio_filename" "$duration" "$channels_p" |
| 70 | + fi |
| 71 | +} |
| 72 | + |
| 73 | +check_cplay_command() |
| 74 | +{ |
| 75 | + dlogi "${play_command[@]}" |
| 76 | + if ! "${play_command[@]}"; then |
| 77 | + die "cplay command returned error, socwatch analysis not performed" |
| 78 | + fi |
| 79 | +} |
| 80 | + |
| 81 | +run_test() |
| 82 | +{ |
| 83 | + audio_filename="$HOME/Music/$channels_p-ch-$duration-s.mp3" |
| 84 | + prepare_test_soundfile |
| 85 | + |
| 86 | + socwatch_output="$LOG_ROOT/socwatch-results/socwatch_report" |
| 87 | + |
| 88 | + play_command=("cplay" "-c" "0" "-d" "$pcm_p" "-I" "MP3" "${audio_filename}" "-v") |
| 89 | + check_cplay_command |
| 90 | + |
| 91 | + run_with_socwatch "$socwatch_output" "${play_command[@]}" |
| 92 | + |
| 93 | + analyze_socwatch_results |
| 94 | +} |
| 95 | + |
| 96 | +main() |
| 97 | +{ |
| 98 | + export RUN_SOCWATCH=true |
| 99 | + start_test |
| 100 | + logger_disabled || func_lib_start_log_collect |
| 101 | + run_test |
| 102 | +} |
| 103 | + |
| 104 | +{ |
| 105 | + main "$@"; exit "$?" |
| 106 | +} |
0 commit comments