-
Notifications
You must be signed in to change notification settings - Fork 179
/
test_pqos_l2cat.py
397 lines (354 loc) · 13.2 KB
/
test_pqos_l2cat.py
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
################################################################################
# BSD LICENSE
#
# Copyright(c) 2019 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
################################################################################
import test
import re
import pytest
from testlib.env import Env
from priority import PRIORITY_MEDIUM, PRIORITY_HIGH
class TestPqosL2Cat(test.Test):
## @cond
@pytest.fixture(autouse=True)
def init(self, request):
super(TestPqosL2Cat, self).init(request)
yield
super(TestPqosL2Cat, self).fini()
## @endcond
## PQOS - L2 CAT Detection - Negative
#
# \b Priority: High
#
# \b Objective:
# Verify L2 CAT capability is not detected on platform
#
# \b Instruction:
# Run "pqos [-I] -s -v" to print platform RDT capabilities and configuration in verbose
# mode
#
# \b Result:
# Observe "L2CA capability not detected" in output
@PRIORITY_HIGH
@pytest.mark.rdt_unsupported("cat_l2")
def test_pqos_l2cat_detection_negative(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-s -v")
assert exitstatus == 0
assert "L2CA capability not detected" in stdout
## PQOS - L2 CAT Detection
#
# \b Priority: Medium
#
# \b Objective:
# Verify L2 CAT capability is detected on platform
#
# \b Instruction:
# Run "pqos [-I] -s -v" to print platform RDT capabilities and configuration in verbose
# mode
#
# \b Result:
# Observe "L2CA capability detected" in output
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cat_l2")
def test_pqos_l2cat_detection(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-s -v")
assert exitstatus == 0
assert "L2CA capability detected" in stdout
## PQOS - L2 CAT Set COS definition
#
# \b Priority: Medium
#
# \b Objective:
# Able to set up allocation COS
#
# \b Instruction:
# 1. Run the "pqos [-I] -e 'l2:1=0xf;l2:2=0xf0'" to set COS bitmask.
# 2. Verify values with "pqos -s"
#
# \b Result:
# 1. Observe in output
# L2ID 0 L2CA COS1 => MASK 0xf
# L2ID 0 L2CA COS2 => MASK 0xf0
# Allocation configuration altered.
# 2. L2CA COS1 MASK for socket 0 is set to 0xf
# L2CA COS2 MASK for socket 0 is set to 0xf0
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cat_l2")
def test_pqos_l2cat_set(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-e l2:1=0xf;l2:2=0xf0")
assert exitstatus == 0
assert "L2ID 0 L2CA COS1 => MASK 0xf" in stdout
assert "L2ID 0 L2CA COS2 => MASK 0xf0" in stdout
assert "Allocation configuration altered" in stdout
(stdout, _, exitstatus) = self.run_pqos(iface, "-s")
assert exitstatus == 0
assert "L2CA COS1 => MASK 0xf" in stdout
assert "L2CA COS2 => MASK 0xf0" in stdout
## PQOS - L2 CAT Set COS definition - Negative
#
# \b Priority: Medium
#
# \b Objective:
# Unable to set up allocation COS with a bitmask more than 28 bits
#
# \b Instruction:
# Run "pqos [-I] -e l2:2=0xffffffff" to set the COS bitmask which is more than 28 bits.
#
# \b Result:
# Observe "SOCKET 0 L2CA COS2 - FAILED!" and "Allocation configuration error!" in output
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cat_l2")
def test_pqos_l2cat_set_negative(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-e l2:2=0xffffffff")
assert exitstatus == 1
assert "L2CA COS2 - FAILED" in stdout
assert "Allocation configuration error!" in stdout
## PQOS - L2 CAT Set COS association (core)
#
# \b Priority: Medium
#
# \b Objective:
# Allocate COS for the given cores
#
# \b Instruction:
# Run "pqos [-I] -a llc:1=1,3" to set core association. Verify core association with
# "pqos [-I] -s".
#
# \b Result:
# Observe "Allocation configuration altered." in output. Cores 1 and 3 are assigned to COS 1.
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cat_l2")
def test_pqos_l2cat_association_core(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-a llc:1=1,3")
assert exitstatus == 0
assert "Allocation configuration altered." in stdout
(stdout, _, exitstatus) = self.run_pqos(iface, "-s")
assert exitstatus == 0
assert re.search("Core 1, L2ID [0-9]+ => COS1", stdout)
assert re.search("Core 3, L2ID [0-9]+ => COS1", stdout)
## PQOS - L2 CAT Set COS association (core) - Negative
#
# \b Priority: Medium
#
# \b Objective:
# Unable to allocate COS for the unknown/offline cores
#
# \b Instruction:
# Run "pqos [-I] -a llc:1=1000" to set core association.
#
# \b Result:
# Observe "Core number or class id is out of bounds!" in output.
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cat_l2")
def test_pqos_l2cat_association_core_negative(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-a llc:1=1000")
assert exitstatus == 1
assert "Core number or class id is out of bounds!" in stdout
## PQOS - L2 CAT Set COS association (tasks)
#
# \b Priority: Medium
#
# \b Objective:
# Allocate COS for the given pids
#
# \b Instruction:
# Run "pqos -I -a pid:2=1" to set pid association.
#
# \b Result:
# Observe "Allocation configuration altered." in output.
@PRIORITY_MEDIUM
@pytest.mark.iface_os
@pytest.mark.rdt_supported("cat_l2")
def test_pqos_l2cat_association_tasks(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-a pid:2=1")
assert exitstatus == 0
assert "Allocation configuration altered." in stdout
## PQOS - L2 CAT Set COS association (tasks) - Negative
#
# \b Priority: Medium
#
# \b Objective:
# Unable to allocate COS for the invalid/unknown pids
#
# \b Instruction:
# Run "pqos -I -a pid:2=9999999999" to set pid association.
#
# \b Result:
# Observe "Task ID number or class id is out of bounds!" in output.
@PRIORITY_MEDIUM
@pytest.mark.iface_os
@pytest.mark.rdt_supported("cat_l2")
def test_pqos_l2cat_association_tasks_negative(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-a pid:2=9999999999")
assert exitstatus == 1
assert "Task ID number or class id is out of bounds!" in stdout
## PQOS - L2 CAT Reset
#
# \b Priority: Medium
#
# \b Objective:
# Reset L2 CAT settings
#
# \b Instruction:
# Run "pqos [-I] -R" to reset L2 CAT configuration.
#
# \b Result:
# Observe "Allocation reset successful" in output
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cat_l2")
def test_pqos_l2cat_reset(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-R")
assert exitstatus == 0
assert "Allocation reset successful" in stdout
## PQOS - L2 CDP Detection
#
# \b Priority: Medium
#
# \b Objective:
# Verify L2 CDP capability is detected on platform
#
# \b Instruction:
# Run "pqos [-I] -s -v" to print platform RDT capabilities and configuration in verbose mode
#
# \b Result:
# Observe "INFO: L2 CAT details: CDP support=1" in output
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cdp_l2")
def test_pqos_l2cat_cdp_detection(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-s -v")
assert exitstatus == 0
assert "INFO: L2 CAT details: CDP support=1" in stdout
## PQOS - L2 CDP enable
#
# \b Priority: Medium
#
# \b Objective:
# Verify L2 CDP can be enabled on platform
#
# \b Instruction:
# Run "pqos [-I] -R l2cdp-on -v" to enable L2 CDP.
# Verify that CDP was enabled with "pqos [-I] -s -V"
#
# \b Result:
# Observe "Turning L2 CDP ON" and "L2 CDP is enabled" in output
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cdp_l2")
def test_pqos_l2cat_cdp_enable(self, iface):
(stdout, _, exitstatus) = self.run_pqos(iface, "-R l2cdp-on -v")
assert exitstatus == 0
assert iface != "MSR" or "Turning L2 CDP ON" in stdout
(stdout, _, exitstatus) = self.run_pqos(iface, "-s -V")
assert exitstatus == 0
assert "L2 CAT details: CDP support=1, CDP on=1" in stdout
## PQOS - L2 CDP disable
#
# \b Priority: Medium
#
# \b Objective:
# Verify L2 CAT can be disabled platform
#
# \b Instruction:
# Run "pqos [-I] -R l2cdp-off -v" to disable L2 CDP.
# Verify that CDP was disabled with "pqos [-I] -s -V"
#
# \b Result:
# Observe "Turning L2 CDP OFF" and "L2 CDP is disabled" in outpuy
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cdp_l2")
def test_pqos_l2cat_cdp_disable(self, iface):
self.run_pqos(iface, "-R l2cdp-on")
(stdout, _, exitstatus) = self.run_pqos(iface, "-R l2cdp-off -v")
assert exitstatus == 0
assert iface != "MSR" or "Turning L2 CDP OFF" in stdout
(stdout, _, exitstatus) = self.run_pqos(iface, "-s -V")
assert exitstatus == 0
assert "L2 CAT details: CDP support=1, CDP on=0" in stdout
## PQOS - L2 CDP Set COS definition - Code & Data
#
# \b Priority: Medium
#
# \b Objective:
# Verify L2 CAT COS definition can be set for Code and Data
#
# \b Instruction:
# Run "pqos [-I] -R l2cdp-on" to enable L2 CDP.
# Run "pqos [-I] -e l2:2=0xe" to set both code and data cbm.
#
# \b Result:
# Observe the following in output "L2ID 1 L2CA COS2 => DATA 0xe,CODE 0xe"
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cdp_l2")
def test_pqos_l2cat_set_code_and_data(self, iface):
self.run_pqos(iface, "-R l2cdp-on")
(stdout, _, exitstatus) = self.run_pqos(iface, "-e l2:2=0xe")
assert exitstatus == 0
assert "L2ID 1 L2CA COS2 => DATA 0xe,CODE 0xe" in stdout
## PQOS - L2 CDP Set COS definition - Code only
#
# \b Priority: Medium
#
# \b Objective:
# Verify L2 CAT COS definition can be set for Code only
#
# \b Instruction:
# Run "pqos [-I] -R l2cdp-on" to enable L2 CDP.
# Run "pqos [-I] -e l2:4c=0xf" to set both code and data cbm.
#
# \b Result:
# Observe the following in output "L2ID 1 L2CA COS4 => DATA 0x7ff,CODE 0xf"
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cdp_l2")
def test_pqos_l2cat_set_code(self, iface):
self.run_pqos(iface, "-R l2cdp-on")
default_mask = (1 << Env().get('cat', 'l2', 'ways')) - 1
(stdout, _, exitstatus) = self.run_pqos(iface, "-e l2:4c=0xf")
assert exitstatus == 0
assert ("L2ID 1 L2CA COS4 => DATA {},CODE 0xf").format(hex(default_mask)) in stdout
## PQOS - L2 CDP Set COS definition - Data only
#
# \b Priority: Medium
#
# \b Objective:
# Verify L2 CAT COS definition can be set for Code and Data
#
# \b Instruction:
# Run "pqos [-I] -R l2cdp-on" to enable L2 CDP.
# Run "pqos [-I] -e l2:3d=0xf" to set both code and data cbm.
#
# \b Result:
# Observe the following in output "L2ID 1 L2CA COS3 => DATA 0xf,CODE 0x7ff"
@PRIORITY_MEDIUM
@pytest.mark.rdt_supported("cdp_l2")
def test_pqos_l2cat_set_data(self, iface):
self.run_pqos(iface, "-R l2cdp-on")
default_mask = (1 << Env().get('cat', 'l2', 'ways')) - 1
(stdout, _, exitstatus) = self.run_pqos(iface, "-e l2:3d=0xf")
assert exitstatus == 0
assert ("L2ID 1 L2CA COS3 => DATA 0xf,CODE {}").format(hex(default_mask)) in stdout