@@ -6,6 +6,7 @@ Library String
66Library Telnet timeout=20 seconds connection_timeout=120 seconds
77Library SSHLibrary timeout=90 seconds
88Library RequestsLibrary
9+ Library DateTime
910# TODO: maybe have a single file to include if we need to include the same
1011# stuff in all test cases
1112Resource ../variables.robot
@@ -19,7 +20,9 @@ Resource ../lib/sensors/sensors.robot
1920# - go threough them and make sure they are doing what the name suggest (not
2021# exactly the case right now)
2122
22- Suite Setup Run Keywords Prepare Test Suite
23+ Suite Setup Run Keywords
24+ ... Prepare Test Suite AND
25+ ... Check Power Supply
2326
2427*** Variables ***
2528&{TESTS_TO_RUN } = &{EMPTY }
@@ -31,7 +34,7 @@ ${TESTS_IN_UBUNTU_SUPPORT}= ${TRUE}
3134*** Test Cases ***
3235
3336# Tests that can be performed immediately
34- _CANARY_CPF001.201
37+ _CANARY_CPF001.201 CPU not stuck on initial frequency (Ubuntu)
3538 VAR ${TEST_ID } = CPF001.201
3639 Add Test Case Skip Condition
3740 ... ${TESTS_TO_RUN }
@@ -50,54 +53,62 @@ _CANARY_CPF001.201
5053 ... Ubuntu not in tested distros
5154 Skip If Not Supported ${TEST_ID } ${TESTS_TO_RUN }
5255
53- # _CANARY_CPF005.201 CPU runs on expected frequency (Ubuntu)
54- # VAR ${TEST_ID}= CPF005.201
55- # Add Test Case Skip Condition
56- # ... ${TESTS_TO_RUN}
57- # ... ${TEST_ID}
58- # ... not ${CPU_FREQUENCY_MEASURE}
59- # ... frequency measure not supported
60- # Add Test Case Skip Condition
61- # ... ${TESTS_TO_RUN}
62- # ... ${TEST_ID}
63- # ... not ${TESTS_IN_UBUNTU_SUPPORT}
64- # ... tests in Ubuntu not supported
65- # Add Test Case Skip Condition
66- # ... ${TESTS_TO_RUN}
67- # ... ${TEST_ID}
68- # ... '201' not in ${TESTED_LINUX_DISTROS}
69- # ... Ubuntu not in tested distros
70- # Add Test Case Skip Condition
71- # ... ${TESTS_TO_RUN}
72- # ... ${TEST_ID}
73- # ... ${LAPTOP_PLATFORM}
74- # ... The Platform is a Laptop
75-
76- # _CANARY_CPT001.201 CPU temperature without load (Ubuntu)
77- # VAR ${TEST_ID}= CPT001.201
78- # Add Test Case Skip Condition
79- # ... ${TESTS_TO_RUN}
80- # ... ${TEST_ID}
81- # ... not ${TESTS_IN_UBUNTU_SUPPORT}
82- # ... tests in Ubuntu not supported
83- # Add Test Case Skip Condition
84- # ... ${TESTS_TO_RUN}
85- # ... ${TEST_ID}
86- # ... ${ENV_ID_UBUNTU}' not in ${TESTED_LINUX_DISTROS}
87- # ... Ubuntu not in tested distros
88- # Add Test Case Skip Condition
89- # ... ${TESTS_TO_RUN}
90- # ... ${TEST_ID}
91- # ... ${LAPTOP_PLATFORM}
92- # ... The Platform is a Laptop
56+ _CANARY_CPF005.201 CPU runs on expected frequency (Ubuntu)
57+ VAR ${TEST_ID } = CPF005.201
58+ Add Test Case Skip Condition
59+ ... ${TESTS_TO_RUN }
60+ ... ${TEST_ID }
61+ ... not ${CPU_FREQUENCY_MEASURE }
62+ ... frequency measure not supported
63+ Add Test Case Skip Condition
64+ ... ${TESTS_TO_RUN }
65+ ... ${TEST_ID }
66+ ... not ${TESTS_IN_UBUNTU_SUPPORT }
67+ ... tests in Ubuntu not supported
68+ Add Test Case Skip Condition
69+ ... ${TESTS_TO_RUN }
70+ ... ${TEST_ID }
71+ ... '201 ' not in ${TESTED_LINUX_DISTROS }
72+ ... Ubuntu not in tested distros
73+ Add Test Case Skip Condition
74+ ... ${TESTS_TO_RUN }
75+ ... ${TEST_ID }
76+ ... ${LAPTOP_PLATFORM }
77+ ... The Platform is a Laptop
78+ Skip If Not Supported ${TEST_ID } ${TESTS_TO_RUN }
79+
80+ _CANARY_CPT001.201 CPU temperature without load (Ubuntu)
81+ VAR ${TEST_ID } = CPT001.201
82+ Add Test Case Skip Condition
83+ ... ${TESTS_TO_RUN }
84+ ... ${TEST_ID }
85+ ... not ${TESTS_IN_UBUNTU_SUPPORT }
86+ ... tests in Ubuntu not supported
87+ Add Test Case Skip Condition
88+ ... ${TESTS_TO_RUN }
89+ ... ${TEST_ID }
90+ ... '${ENV_ID_UBUNTU } ' not in ${TESTED_LINUX_DISTROS }
91+ ... Ubuntu not in tested distros
92+ Add Test Case Skip Condition
93+ ... ${TESTS_TO_RUN }
94+ ... ${TEST_ID }
95+ ... ${LAPTOP_PLATFORM }
96+ ... The Platform is a Laptop
97+ Skip If Not Supported ${TEST_ID } ${TESTS_TO_RUN }
9398
9499
100+ ############################################
101+ # Tests that can be done immediately #
102+ ############################################
95103_GATHER_Background Measurements Data Init (no load) (Ubuntu)
96104 ${prepare_sensors } = Will Test Be Run Regex ${TESTS_TO_RUN } CP[TF]
97105 IF ${prepare_sensors } Prepare Sensors
106+ ${check_psu } = Will Test Be Run Regex ${TESTS_TO_RUN } CP[TF]
107+ IF ${check_psu } Check Power Supply
98108
99109_GATHER_Background Measurements Immediate (no load) (Ubuntu)
100- ${will_any_be_run } = Will Test Be Run Regex ${TESTS_TO_RUN } CP[TF]
110+ # immediately skip if no tests want these measurements
111+ ${will_any_be_run } = Will Test Be Run Regex ${TESTS_TO_RUN } CPF001.201
101112 Skip If not ${will_any_be_run }
102113
103114 Power On
@@ -129,8 +140,110 @@ CPF001.201 CPU not stuck on initial frequency (Ubuntu)
129140 END
130141 Fail CPU stuck on initial frequency: ${INITIAL_CPU_FREQUENCY }
131142
143+ #############################################################################
144+ # Tests that gather measurements on Ubuntu, no load, n/a power source #
145+ #############################################################################
146+ _GATHER_Background Measurements (no load) (Ubuntu)
147+ ${will_any_be_run } = Will Test Be Run Regex
148+ ... ${TESTS_TO_RUN }
149+ ... (CPF005)|(CPT001)|(STB001).201
150+ Skip If not ${will_any_be_run }
151+
152+ Power On
153+ Boot System Or From Connected Disk ${ENV_ID_UBUNTU }
154+ Login To Linux
155+ Switch To Root User
156+
157+ # CPF001.201 steps
158+ ${gather_temps } = Will Test Be Run Regex ${TESTS_TO_RUN } CPT
159+ ${gather_freqs } = Will Test Be Run Regex ${TESTS_TO_RUN } CPF
160+ ${measure_stab } = Will Test Be Run Regex ${TESTS_TO_RUN } STB
161+
162+ VAR @{temp_list } = @{EMPTY }
163+ VAR @{freq_list } = @{EMPTY }
164+ VAR @{stab_list } = @{EMPTY }
165+
166+ # TODO temporary debug values
167+ VAR ${FREQUENCY_TEST_MEASURE_INTERVAL } = 1
168+ VAR ${TEMPERATURE_TEST_MEASURE_INTERVAL } = 1
169+ VAR ${TEMPERATURE_TEST_DURATION } = 5
170+ VAR ${FREQUENCY_TEST_DURATION } = 5
171+ VAR ${STABILITY_TEST_DURATION } = 0
172+
173+ ${next_temp_time } = Set Variable If ${gather_temps } ${TEMPERATURE_TEST_MEASURE_INTERVAL } 999999
174+ ${next_stab_time } = Set Variable If ${gather_temps } ${STABILITY_TEST_MEASURE_INTERVAL } 999999
175+ ${next_freq_time } = Set Variable If ${gather_temps } ${FREQUENCY_TEST_MEASURE_INTERVAL } 999999
176+
177+ ${start } = DateTime.Get Current Date
178+ ${timer } = Evaluate 0
179+ VAR ${longest_duration } = max(${TEMPERATURE_TEST_DURATION } , ${FREQUENCY_TEST_DURATION } , ${STABILITY_TEST_DURATION } )
180+
181+ WHILE ${timer } < ${longest_duration }
182+ ${now } = Get Current Date
183+ ${timer } = Subtract Date From Date ${now } ${start }
184+
185+ IF ${gather_temps } and ${TEMPERATURE_TEST_DURATION } >= ${timer } >= ${next_temp_time }
186+ ${temperature } = Get CPU Temperature
187+ ${next_temp_time } = Evaluate ${timer } + ${TEMPERATURE_TEST_MEASURE_INTERVAL }
188+ Append To List ${temp_list } ${temperature }
189+ Log To Console ${timer } s: Temperature: ${temperature }
190+ END
191+
192+ IF ${gather_freqs } and ${FREQUENCY_TEST_DURATION } >= ${timer } >= ${next_freq_time }
193+ ${freqs } = Get CPU Frequencies In Ubuntu
194+ ${next_freq_time } = Evaluate ${timer } + ${FREQUENCY_TEST_MEASURE_INTERVAL }
195+ Append To List ${freq_list } ${freqs }
196+ Log To Console ${timer } s: Frequencies: ${freqs }
197+ END
198+ # ... Log To Console Stability check at ${elapsed}s
199+
200+ # Run Keyword If ${elapsed} % ${FREQUENCY_TEST_MEASURE_INTERVAL} < 0.1 and ${elapsed} <= ${FREQUENCY_TEST_DURATION}
201+ # ... Log To Console Frequency check at ${elapsed}s
202+
203+ ${time_to_next_interval } = Evaluate min(${next_temp_time } , ${next_stab_time } , ${next_freq_time } )
204+ Sleep ${time_to_next_interval }
205+ END
206+
207+ Set Test Outputs ${TESTS_TO_RUN } CPT001.201 ${temp_list }
208+ Set Test Outputs ${TESTS_TO_RUN } CPF005.201 ${freq_list }
209+
210+ CPT001.201 CPU temperature without load (Ubuntu)
211+ VAR ${test_id } = CPT001.201
212+ ${temps } = Get Test Outputs ${TESTS_TO_RUN } ${test_id }
213+ ${sum } = Evaluate 0
214+ ${len } = Get Length ${temps }
215+ FOR ${temp } IN @{temps }
216+ ${sum } = Evaluate ${sum } + ${temp }
217+ END
218+ ${avg } = Evaluate ${sum } / ${len }
219+ ${min } = Evaluate min($temps)
220+ ${max } = Evaluate max($temps)
221+ Log To Console Average temp: ${avg }
222+ Log To Console Min temp: ${min }
223+ Log To Console Max temp: ${max }
224+ Log To Console Test threshold of CPU temp: ${MAX_CPU_TEMP } °C
225+ Should Be True ${avg } < ${MAX_CPU_TEMP } Average is higher than threshold
226+
227+ CPF005.201 CPU runs on expected frequency (Ubuntu)
228+ VAR ${test_id } = CPF005.201
229+ ${freqs } = Get Test Outputs ${TESTS_TO_RUN } ${test_id }
230+ ${cpu_max_frequency_tol } = Evaluate ${CPU_MAX_FREQUENCY } * 1.125
231+ ${cpu_min_frequency_tol } = Evaluate ${CPU_MIN_FREQUENCY } * 0.875
232+ FOR ${freqs_cores } IN @{freqs }
233+ FOR ${core } IN @{freqs_cores }
234+ ${in_range } = Evaluate ${cpu_min_frequency_tol } <= ${core } <= ${cpu_max_frequency_tol }
235+ Should Be True ${in_range } Encountered invalid frequency: ${in_range } MHz
236+ END
237+ END
132238
133239*** Keywords ***
240+ Wait Until Time
241+ [Arguments] ${target }
242+ ${now } = Get Current Date result_format=%Y-%m-%d %H:%M:%S.%f
243+ ${diff } = Subtract Date From Date ${target } ${now } result_format=number
244+ ${sleep } = Evaluate max(min(${diff } , 0.1 ), 0.01)
245+ Sleep ${sleep }
246+
134247Add Test Case Skip Condition
135248 [Arguments] ${tests_dict } ${test_id } ${condition } ${skip_reason }
136249 ${current_details } = Get From Dictionary ${tests_dict } ${test_id } default=${FALSE }
0 commit comments