Merge ~alextu/plainbox-provider-pc-sanity:pc10-s2i into plainbox-provider-pc-sanity:master

Proposed by Alex Tu
Status: Merged
Merged at revision: bb4d3e8b85045e97e7bc7e1fd063994201e8cd38
Proposed branch: ~alextu/plainbox-provider-pc-sanity:pc10-s2i
Merge into: plainbox-provider-pc-sanity:master
Diff against target: 149 lines (+113/-0)
4 files modified
debian/changelog (+2/-0)
usr/sbin/check-turbostat-power-residency.sh (+95/-0)
usr/share/plainbox-provider-checkbox/units/pc-sanity/pc-sanity-power-consumption.pxu (+15/-0)
usr/share/plainbox-provider-checkbox/units/pc-sanity/pc-sanity-smoke-test.pxu (+1/-0)
Reviewer Review Type Date Requested Status
Kai-Chuan Hsieh Approve
Shih-Yuan Lee Pending
Yuan-Chen Cheng Pending
Rex Tsai Pending
OEM Solutions Group: Engineers Pending
Review via email: mp+390080@code.launchpad.net

Commit message

    check expected power residency during s2i e.g. cpu pkg c10, s0ix, gfxrc6..etc

    this test case refer to Intel document : https://01.org/blogs/qwang59/2020/linux-s0ix-troubleshooting

To post a comment you must log in.
Revision history for this message
Kai-Chuan Hsieh (kchsieh) wrote :

Seems have error while grep the file:

u@u-Latitude:/usr/share/plainbox-provider-checkbox/units/pc-sanity$ checkbox-cli run com.canonical.certification::miscellanea/turbostate-s2i-power-residency
===========================[ Running Selected Jobs ]============================
--------------[ Running job 1 / 1. Estimated time left: unknown ]---------------
[ check if target machine can get expected power residency on e.g. cpu pkg c10, s0ix, gfxrc6..etc ]
ID: com.canonical.certification::miscellanea/turbostate-s2i-power-residency
Category: com.canonical.plainbox::miscellanea
... 8< -------------------------------------------------------------------------
+ check-turbostat-power-residency.sh --s2i
/usr/bin/turbostat
[INFO] getting turbostat log. Please wait for 60s
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "freeze" using /dev/rtc0 at Wed Sep 2 08:58:59 2020
grep: /tmp/s2i-turbostat.log: No such file or directory
(standard_in) 2: syntax error
[INFO] checking s0ix : %
(standard_in) 1: syntax error
Failed avg s0ix : NOT > 70
(standard_in) 2: syntax error
[INFO] checking gfxrc6 : %
(standard_in) 1: syntax error
Failed avg gfxrc6 : NOT > 50
(standard_in) 2: syntax error
[INFO] checking pkg_pc10 : %
(standard_in) 1: syntax error
Failed avg pkg_pc10 : NOT > 80
------------------------------------------------------------------------- >8 ---
Outcome: job failed
Finalizing session that hasn't been submitted anywhere: checkbox-run-2020-09-02T08.57.57
==================================[ Results ]===================================
 ☒ : check if target machine can get expected power residency on e.g. cpu pkg c10, s0ix, gfxrc6..etc

review: Needs Fixing
Revision history for this message
Alex Tu (alextu) wrote :

fixed the missed, part

--------------[ Running job 2 / 2. Estimated time left: unknown ]---------------
[ check if target machine can get expected power residency on e.g. cpu pkg c10, s0ix, gfxrc6..etc ]
ID: com.canonical.certification::miscellanea/turbostate-s2i-power-residency
Category: com.canonical.plainbox::miscellanea
... 8< -------------------------------------------------------------------------
+ check-turbostat-power-residency.sh --s2i
/usr/bin/turbostat
[INFO] getting turbostat log. Please wait for 60s
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "freeze" using /dev/rtc0 at Wed Sep 2 10:06:54 2020
[INFO] checking s0ix : 0%
Failed avg s0ix : 0 NOT > 70
[INFO] checking gfxrc6 : 100%
Passed.
[INFO] checking pkg_pc10 : 93%
Passed.
------------------------------------------------------------------------- >8 ---
Outcome: job failed

Revision history for this message
Kai-Chuan Hsieh (kchsieh) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 2b8a186..4c34c92 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,6 +1,8 @@
6 plainbox-provider-pc-sanity (0.2.9) UNRELEASED; urgency=medium
7
8 * add debsums checking
9+ * miscellanea/turbostate-s2i-power-residency : to check expected power state
10+ during s2i
11
12 -- Alex Tu <alex.tu@canonical.com> Tue, 18 Aug 2020 15:44:22 +0800
13
14diff --git a/usr/sbin/check-turbostat-power-residency.sh b/usr/sbin/check-turbostat-power-residency.sh
15new file mode 100755
16index 0000000..58be121
17--- /dev/null
18+++ b/usr/sbin/check-turbostat-power-residency.sh
19@@ -0,0 +1,95 @@
20+#!/bin/bash
21+
22+#refer to https://01.org/blogs/qwang59/2020/linux-s0ix-troubleshooting
23+set -e
24+state="pass"
25+command -v turbostat || exit 1
26+session_folder="$PLAINBOX_SESSION_SHARE"
27+
28+declare -A stats_p=( [gfxrc6]=0 [pkg_pc10]=7 [s0ix]=8 )
29+declare -A turbostat=( [gfxrc6]=0 [pkg_pc10]=0 [s0ix]=0 )
30+declare -A avg_criteria=( [gfxrc6]=50 [pkg_pc10]=80 [s0ix]=70 )
31+
32+usage() {
33+cat << EOF
34+usage: $0 options
35+ this tool will run turbostat and check if the power state meet our requirement.
36+ most of operations are need root permission.
37+
38+ -h|--help print this message
39+ --s2i get into s2i before run turbostat
40+ --folder sepcify the path of folder that you want to store temp logs. The default one is $session_folder
41+ -f read external turbostat log instead of doing turbostat.; do not need root permission.
42+ please get log by this command:
43+ \$turbostat --out your-log --show GFX%rc6,Pkg%pc2,Pkg%pc3,Pkg%pc6,Pkg%pc7,Pkg%pc8,Pkg%pc9,Pk%pc10,SYS%LPI
44+ then:
45+ \$$0 -f path-to-your-log
46+EOF
47+exit 1
48+}
49+
50+while [ $# -gt 0 ]
51+do
52+ case "$1" in
53+ -h | --help)
54+ usage 0
55+ exit 0
56+ ;;
57+ --s2i)
58+ S2I=1;
59+ ;;
60+ --folder)
61+ shift
62+ [ -d "$i" ] || usage
63+ session_folder=$1;
64+ ;;
65+ -f)
66+ shift
67+ if [ -f "$1" ]; then
68+ EX_FILE="$1";
69+ fi
70+ ;;
71+ *)
72+ usage
73+ esac
74+ shift
75+done
76+
77+STAT_FILE="$session_folder/s2i-turbostat.log"
78+
79+if_root(){
80+ if [ "$(id -u)" != "0" ]; then
81+ >&2 echo "[ERROR]need root permission"
82+ usage
83+ fi
84+}
85+if [ "$S2I" == "1" ]; then
86+ if_root
87+ echo "[INFO] getting turbostat log. Please wait for 60s"
88+ turbostat --out "$STAT_FILE" --show GFX%rc6,Pkg%pc2,Pkg%pc3,Pkg%pc6,Pkg%pc7,Pkg%pc8,Pkg%pc9,Pk%pc10,SYS%LPI rtcwake -m freeze -s 60
89+elif [ -n "$EX_FILE" ]; then
90+ cp "$EX_FILE" "$STAT_FILE"
91+else
92+ if_root
93+ echo "[INFO] getting turbostat log. Please wait for about 240s"
94+ turbostat --num_iterations 60 --out "$STAT_FILE" --show GFX%rc6,Pkg%pc2,Pkg%pc3,Pkg%pc6,Pkg%pc7,Pkg%pc8,Pkg%pc9,Pk%pc10,SYS%LPI
95+fi
96+while read -r -a line; do
97+ c=$((c+1));
98+ for i in "${!turbostat[@]}"; do
99+ turbostat[$i]=$(bc <<< "${turbostat[$i]}+${line[${stats_p[$i]}]}");
100+ done
101+done < <(grep -v "[a-zA-Z]" "$STAT_FILE")
102+
103+for i in "${!turbostat[@]}"; do
104+ turbostat[$i]=$(bc <<< "${turbostat[$i]}/$c");
105+ echo "[INFO] checking $i : ${turbostat[$i]}%"
106+ if [ "$(bc <<< "${turbostat[$i]} > ${avg_criteria[$i]}")" == "1" ]; then
107+ echo "Passed."
108+ else
109+ >&2 echo "Failed" "avg $i : ${turbostat[$i]} NOT > ${avg_criteria[$i]} "
110+ state="failed"
111+ fi
112+done
113+
114+[ "$state" == "pass" ] || exit 1
115diff --git a/usr/share/plainbox-provider-checkbox/units/pc-sanity/pc-sanity-power-consumption.pxu b/usr/share/plainbox-provider-checkbox/units/pc-sanity/pc-sanity-power-consumption.pxu
116index 3e5cffd..e9e4894 100644
117--- a/usr/share/plainbox-provider-checkbox/units/pc-sanity/pc-sanity-power-consumption.pxu
118+++ b/usr/share/plainbox-provider-checkbox/units/pc-sanity/pc-sanity-power-consumption.pxu
119@@ -1,3 +1,18 @@
120+
121+
122+plugin: shell
123+category_id: com.canonical.plainbox::miscellanea
124+id: miscellanea/turbostate-s2i-power-residency
125+after: miscellanea/turbostate-long-idle-c10
126+user: root
127+command:
128+ set -x
129+ check-turbostat-power-residency.sh --s2i
130+_summary: check if target machine can get expected power residency on e.g. cpu pkg c10, s0ix, gfxrc6..etc
131+_description:
132+ check if target machine can get expected power residency on e.g. cpu pkg c10, s0ix, gfxrc6..etc
133+ this test case refer to Intel document : https://01.org/blogs/qwang59/2020/linux-s0ix-troubleshooting
134+
135 plugin: shell
136 category_id: com.canonical.plainbox::miscellanea
137 id: miscellanea/turbostate-short-idle-c10
138diff --git a/usr/share/plainbox-provider-checkbox/units/pc-sanity/pc-sanity-smoke-test.pxu b/usr/share/plainbox-provider-checkbox/units/pc-sanity/pc-sanity-smoke-test.pxu
139index 9e4a885..949b742 100644
140--- a/usr/share/plainbox-provider-checkbox/units/pc-sanity/pc-sanity-smoke-test.pxu
141+++ b/usr/share/plainbox-provider-checkbox/units/pc-sanity/pc-sanity-smoke-test.pxu
142@@ -6,6 +6,7 @@ _description:
143 include:
144 com.canonical.certification::miscellanea/debsums
145 com.canonical.certification::miscellanea/turbostate-long-idle-c10
146+ com.canonical.certification::miscellanea/turbostate-s2i-power-residency
147 com.canonical.certification::miscellanea/intel-rapl
148 com.canonical.certification::miscellanea/intel-rapl-mmio
149 com.canonical.certification::miscellanea/intel-p-state

Subscribers

People subscribed via source and target branches