8
8
import optparse
9
9
import tempfile
10
10
import logging
11
+ import re
11
12
import shutil
13
+ import subprocess
12
14
13
15
try :
14
16
import configparser
@@ -134,6 +136,8 @@ def diff(self, other):
134
136
# 'arch' - architecture specific test (optional)
135
137
# comma separated list, ! at the beginning
136
138
# negates it.
139
+ # 'auxv' - Truthy statement that is evaled in the scope of the auxv map. When false,
140
+ # the test is skipped. For example 'auxv["AT_HWCAP"] == 10'. (optional)
137
141
#
138
142
# [eventX:base]
139
143
# - one or multiple instances in file
@@ -164,6 +168,7 @@ def __init__(self, path, options):
164
168
except :
165
169
self .arch = ''
166
170
171
+ self .auxv = parser .get ('config' , 'auxv' , fallback = None )
167
172
self .expect = {}
168
173
self .result = {}
169
174
log .debug (" loading expected events" );
@@ -175,7 +180,28 @@ def is_event(self, name):
175
180
else :
176
181
return True
177
182
178
- def skip_test (self , myarch ):
183
+ def skip_test_auxv (self ):
184
+ def new_auxv (a , pattern ):
185
+ items = list (filter (None , pattern .split (a )))
186
+ # AT_HWCAP is hex but doesn't have a prefix, so special case it
187
+ if items [0 ] == "AT_HWCAP" :
188
+ value = int (items [- 1 ], 16 )
189
+ else :
190
+ try :
191
+ value = int (items [- 1 ], 0 )
192
+ except :
193
+ value = items [- 1 ]
194
+ return (items [0 ], value )
195
+
196
+ if not self .auxv :
197
+ return False
198
+ auxv = subprocess .check_output ("LD_SHOW_AUXV=1 sleep 0" , shell = True ) \
199
+ .decode (sys .stdout .encoding )
200
+ pattern = re .compile (r"[: ]+" )
201
+ auxv = dict ([new_auxv (a , pattern ) for a in auxv .splitlines ()])
202
+ return not eval (self .auxv )
203
+
204
+ def skip_test_arch (self , myarch ):
179
205
# If architecture not set always run test
180
206
if self .arch == '' :
181
207
# log.warning("test for arch %s is ok" % myarch)
@@ -225,9 +251,12 @@ def load_events(self, path, events):
225
251
def run_cmd (self , tempdir ):
226
252
junk1 , junk2 , junk3 , junk4 , myarch = (os .uname ())
227
253
228
- if self .skip_test (myarch ):
254
+ if self .skip_test_arch (myarch ):
229
255
raise Notest (self , myarch )
230
256
257
+ if self .skip_test_auxv ():
258
+ raise Notest (self , "auxv skip" )
259
+
231
260
cmd = "PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir ,
232
261
self .perf , self .command , tempdir , self .args )
233
262
ret = os .WEXITSTATUS (os .system (cmd ))
0 commit comments