-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathtest-compressed-audio.sh
More file actions
executable file
·95 lines (75 loc) · 2.55 KB
/
test-compressed-audio.sh
File metadata and controls
executable file
·95 lines (75 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
##
## Case Name: test-compressed-audio
##
## Preconditions:
## TODO
##
## Description:
## TODO
##
## Case step:
## TODO
##
## Expect result:
## TODO
##
# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh
OPT_NAME['p']='pcm_p' OPT_DESC['p']='compression device for playback. Example: 50'
OPT_HAS_ARG['p']=1 OPT_VAL['p']=''
OPT_NAME['N']='channels_p' OPT_DESC['N']='channel number for playback.'
OPT_HAS_ARG['N']=1 OPT_VAL['N']='2'
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
OPT_NAME['d']='duration' OPT_DESC['d']='duration time for playing the test sound'
OPT_HAS_ARG['d']=1 OPT_VAL['d']=10
: "${SOCWATCH_PATH:=$HOME/socwatch}"
func_opt_parse_option "$@"
setup_kernel_check_point
pcm_p=${OPT_VAL['p']}
channels_p=${OPT_VAL['N']}
duration=${OPT_VAL['d']}
analyze_socwatch_results()
{
pc_states_file="$LOG_ROOT/pc_states.csv"
touch "$pc_states_file"
results=$(cat "$socwatch_output".csv | grep "Platform Monitoring Technology CPU Package C-States Residency Summary: Residency" -A 10)
echo "$results" | tee "$pc_states_file"
# expected_results='{"PC0":12.00, "PC2":88, "PC6.1":0, "PC6.2":11, "PC10.1":2, "PC10.2":72, "PC10.3":0}'
expected_results='{"PC10.2":80}'
# Analyze if the % of the time spent in given PC state was as expected
if python3 "$SCRIPT_HOME"/tools/analyze-pc-states.py "$pc_states_file" "$expected_results"; then
dlogi "All Package Residency (%) values were as expected"
else
die "Some Package Residency (%) values different from expected!"
fi
}
# Checks for soundfile needed for test, generates missing ones
prepare_test_soundfile()
{
if [ ! -f "$audio_filename" ]; then
dlogi "Generating audio file for the test..."
generate_mp3_file "$audio_filename" "$duration" "$channels_p"
fi
}
run_test()
{
audio_filename="$HOME/Music/$channels_p-ch-$duration-s.mp3"
prepare_test_soundfile
socwatch_output="$LOG_ROOT/socwatch-results/socwatch_report"
play_command=("aplay" "-Dhw:0,0" "Music/test.wav" "-f" "S16_LE" "-c" "2" "-v")
# play_command=("cplay" "-c" "0" "-d" "$pcm_p" "-I" "MP3" "${audio_filename}" "-v")
run_with_socwatch "$socwatch_output" "${play_command[@]}"
analyze_socwatch_results
}
main()
{
export RUN_SOCWATCH=true
start_test
logger_disabled || func_lib_start_log_collect
run_test
}
{
main "$@"; exit "$?"
}