|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +## |
| 4 | +## Case Name: test-compressed-audio |
| 5 | +## |
| 6 | +## Preconditions: |
| 7 | +## TODO |
| 8 | +## |
| 9 | +## Description: |
| 10 | +## TODO |
| 11 | +## |
| 12 | +## Case step: |
| 13 | +## TODO |
| 14 | +## |
| 15 | +## Expect result: |
| 16 | +## TODO |
| 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 | +: "${SOCWATCH_PATH:=$HOME/socwatch}" |
| 35 | +SOCWATCH_VERSION=$(sudo "$SOCWATCH_PATH"/socwatch --version | grep Version) |
| 36 | + |
| 37 | +func_opt_parse_option "$@" |
| 38 | +setup_kernel_check_point |
| 39 | + |
| 40 | +pcm_p=${OPT_VAL['p']} |
| 41 | +channels_p=${OPT_VAL['N']} |
| 42 | +duration=${OPT_VAL['d']} |
| 43 | + |
| 44 | +analyze_socwatch_results() |
| 45 | +{ |
| 46 | + pc_states_file="$LOG_ROOT/pc_states.csv" |
| 47 | + touch "$pc_states_file" |
| 48 | + results=$(cat "$socwatch_output".csv | grep "Platform Monitoring Technology CPU Package C-States Residency Summary: Residency" -A 10) |
| 49 | + echo "$results" | tee "$pc_states_file" |
| 50 | + |
| 51 | + # expected_results='{"PC0":12.00, "PC2":88, "PC6.1":0, "PC6.2":11, "PC10.1":2, "PC10.2":72, "PC10.3":0}' |
| 52 | + expected_results='{"PC10.2":80}' |
| 53 | + |
| 54 | + # Analyze if the % of the time spent in given PC state was as expected |
| 55 | + if python3 "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file" "$expected_results"; then |
| 56 | + dlogi "All Package Residency (%) values were as expected" |
| 57 | + else |
| 58 | + die "Some Package Residency (%) values different from expected!" |
| 59 | + fi |
| 60 | +} |
| 61 | + |
| 62 | +# Checks for soundfile needed for test, generates missing ones |
| 63 | +prepare_test_soundfile() |
| 64 | +{ |
| 65 | + if [ ! -f "$audio_filename" ]; then |
| 66 | + dlogi "Generating audio file for the test..." |
| 67 | + generate_mp3_file "$audio_filename" "$duration" "$channels_p" |
| 68 | + fi |
| 69 | +} |
| 70 | + |
| 71 | +run_test() |
| 72 | +{ |
| 73 | + audio_filename="$HOME/Music/$channels_p-ch-$duration-s.mp3" |
| 74 | + prepare_test_soundfile |
| 75 | + |
| 76 | + socwatch_output="$LOG_ROOT/socwatch-results/socwatch_report" |
| 77 | + |
| 78 | + play_command=("aplay" "-Dhw:0,0" "Music/test.wav" "-f" "S16_LE" "-c" "2" "-v") |
| 79 | + # play_command=("cplay" "-c" "0" "-d" "$pcm_p" "-I" "MP3" "${audio_filename}" "-v") |
| 80 | + |
| 81 | + run_with_socwatch "$socwatch_output" "${play_command[@]}" |
| 82 | + |
| 83 | + analyze_socwatch_results |
| 84 | +} |
| 85 | + |
| 86 | +main() |
| 87 | +{ |
| 88 | + export RUN_SOCWATCH=true |
| 89 | + start_test |
| 90 | + logger_disabled || func_lib_start_log_collect |
| 91 | + run_test |
| 92 | +} |
| 93 | + |
| 94 | +{ |
| 95 | + main "$@"; exit "$?" |
| 96 | +} |
0 commit comments