-
Notifications
You must be signed in to change notification settings - Fork 13
/
test-all.py
executable file
·1890 lines (1564 loc) · 53.7 KB
/
test-all.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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python3
import os
import re
import sys
import yaml
import random
import signal
import argparse
import subprocess
from copy import copy
from glob import glob
from fnmatch import fnmatch
from tempfile import mkdtemp
from datetime import datetime
from semver import VersionInfo
from requests.exceptions import ConnectionError
from mlxredmine import MlxRedmine
from ansi2html import Ansi2HTMLConverter
# HTML components
ENV_ROW = """
<tr>
<td>{key}</td>
<td>{val}</td>
</tr>"""
SUMMARY_ROW = """
<tr>
<td>{number_of_tests}</td>
<td>{passed_tests}</td>
<td>{failed_tests}</td>
<td>{skip_tests}</td>
<td>{ignored_tests}</td>
<td>{pass_rate}</td>
<td>{runtime}</td>
</tr>"""
RESULT_ROW = """
<tr>
<td class="testname">{test}</td>
<td>{run_time}</td>
<td>{status}</td>
</tr>
"""
HTML_CSS = """
<style>
.asap_table th { text-align: left; background-color: gray; }
.asap_table td { background-color: lightgray; }
.asap_table td:first-child { font-weight: bold; }
.asap_table td.testname { font-weight: bold; white-space: nowrap; }
table#summary_table td { font-weight: bold; }
</style>
"""
RERUN_HTML = """
<h2>Rerun Results</h2>
<table id="rerun_table" class="asap_table">
<thead>
<tr>
<th>Test</th>
<th>Time</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{rerun_results}
</tbody>
</table>
"""
HTML = """<!DOCTYPE html>
<html>
<head>
<title>Summary</title>
{style}
</head>
<body>
<h2>Environment</h2>
<table id="env_table" class="asap_table">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{envinfo}
</tbody>
</table>
<h2>Summary</h2>
<table id="summary_table" class="asap_table">
<thead>
<tr>
<th>Tests</th>
<th>Passed</th>
<th>Failed</th>
<th>Skipped</th>
<th>Ignored</th>
<th>Passrate</th>
<th>Runtime</th>
</tr>
</thead>
<tbody>
{summary}
</tbody>
</table>
<h2>Tests Results</h2>
<table id="results_table" class="asap_table">
<thead>
<tr>
<th>Test</th>
<th>Time</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{results}
</tbody>
</table>
{rerun}
</body>
</html>
"""
MYNAME = os.path.basename(__file__)
MYDIR = os.path.abspath(os.path.dirname(__file__))
LOGDIR = ''
TESTS = []
RERUN_TESTS = []
WONT_FIX = {}
COLOURS = {
"black": 30,
"red": 31,
"green": 32,
"yellow": 33,
"blue": 34,
"magenta": 25,
"cyan": 36,
"gray": 37,
"dark-gray": 90,
"light-red": 91,
"light-green": 92,
"light-yellow": 93,
"light-blue": 94,
"light-magenta": 95,
"light-cyan": 96,
"white": 97,
}
DB_PATH = None
MINI_REG_LIST = []
IGNORE_LIST = []
TEST_TIMEOUT_MAX = 900
KMEMLEAK_SYSFS = "/sys/kernel/debug/kmemleak"
TAG_COLOR = "yellow"
RERUN_TAG = "*rerun"
INJECT_TAG = "*inject"
envinfo = {}
kmemleak_ignore = os.path.join(MYDIR, "kmemleak.ignore")
TIME_DURATION_UNITS = (
('h', 60*60),
('m', 60),
('s', 1)
)
try:
with open('/labhome/roid/scripts/redmine/redmine_key.txt') as f:
RM_API_KEY = f.read().strip()
except:
RM_API_KEY = None
def human_time_duration(seconds):
if seconds == 0:
return 'inf'
parts = []
for unit, div in TIME_DURATION_UNITS:
amount, seconds = divmod(int(seconds), div)
if amount > 0:
parts.append('{}{}'.format(amount, unit))
return ''.join(parts)
class DeviceType(object):
CX4_LX = "0x1015"
CX5_PCI_3 = "0x1017"
CX5_PCI_4 = "0x1019"
CX6 = "0x101b"
CX6_DX = "0x101d"
CX6_LX = "0x101f"
CX7 = "0x1021"
CX8 = "0x1023"
BF2 = "0xa2d6"
BF3 = "0xa2dc"
devices = {
CX4_LX: "cx4lx",
CX5_PCI_3: "cx5",
CX5_PCI_4: "cx5",
CX6: "cx6",
CX6_DX: "cx6dx",
CX6_LX: "cx6lx",
CX7: "cx7",
CX8: "cx8",
BF2: "bf2",
BF3: "bf3",
}
@staticmethod
def get(device_id):
return DeviceType.devices.get(device_id, '')
@staticmethod
def is_valid_compare(nic1, nic2):
if nic1.startswith('cx') and nic2.startswith('cx'):
return True
if nic1.startswith('bf') and nic2.startswith('bf'):
return True
return False
@staticmethod
def __normalize(nic):
if nic == 'bf2':
return 'cx6dx'
elif nic == 'bf3':
return 'cx7'
return nic
@staticmethod
def cmp(nic1, nic2):
"""
-1 - nic1 < nic2
0 - nic1 == nic2
1 - nic1 > nic2
"""
nic1 = DeviceType.__normalize(nic1)
nic2 = DeviceType.__normalize(nic2)
if not DeviceType.is_valid_compare(nic1, nic2):
raise AttributeError("Invalid nics for comparison %s %s" % (nic1, nic2))
major1 = nic1[2]
major2 = nic2[2]
if major1 < major2:
return -1
if major1 > major2:
return 1
minor1 = nic1[3:]
minor2 = nic2[3:]
if minor1 == minor2:
return 0
if minor1 == "" and minor2 != "":
return -1
if minor1 != "" and minor2 == "":
return 1
if minor1 == "lx" and minor2 == "dx":
return -1
if minor1 == "dx" and minor2 == "lx":
return 1
raise RuntimeError("Cannot compare nics %s %s" % (nic1, nic2))
@staticmethod
def lte(nic1, nic2):
return DeviceType.cmp(nic1, nic2) <= 0
@staticmethod
def gte(nic1, nic2):
return DeviceType.cmp(nic1, nic2) >= 0
class ExecCmdFailed(Exception):
pass
class Test(object):
def __init__(self, test_file, opts={}):
self._test_file = test_file
self._name = os.path.basename(test_file)
self._relpath = MYDIR
self._relname = os.path.relpath(test_file, self._relpath)
self.init_state()
self.issues = []
self.set_logs()
self.iteration = 0
self.opts = opts or {}
self.tag = ''
self.group = ''
self.cmd = self._test_file
def init_state(self):
self._passed = False
self._failed = False
self._skip = False
self._wont_fix = False
self._ignore = False
self._reason = ''
self.run_time = 0.0
self.status = "DIDN'T RUN"
def set_logs(self, post=0):
post_log = '.log' if not post else '.%s.log' % post
post_html = '.html' if not post else '.%s.html' % post
self.test_log = self._name + post_log
self.test_log_html = self._name + post_html
def run(self, html=False):
return run_test(self, html)
@property
def passed(self):
return self._passed and not self._failed
def set_passed(self):
self._passed = True
self._failed = False
@property
def failed(self):
return self._failed
def set_failed(self, reason):
self._passed = False
self._failed = True
self._reason = reason
@property
def fname(self):
return self._test_file
def exists(self):
return os.path.exists(self._test_file)
@property
def skip(self):
return self._skip
def set_skip(self, reason):
self._skip = True
self._reason = reason
def unset_skip(self):
self._skip = False
@property
def wont_fix(self):
return self._wont_fix
def set_wont_fix(self):
self._wont_fix = True
@property
def ignore(self):
return self._ignore
def set_ignore(self, reason):
self._ignore = True
self._reason = reason
@property
def reason(self):
return self._reason
@property
def name(self):
return self._name
@property
def relname(self):
return self._relname
def __repr__(self):
return "<Test %s>" % self._name
def kmsg(msg):
with open("/dev/kmsg", "w") as f:
f.write(msg+"\n")
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', '-v', action='store_true',
help='verbose output')
parser.add_argument('--stop', '-s', action='store_true',
help='stop on first error')
parser.add_argument('--dry', '-d', action='store_true',
help='not to actually run the test')
parser.add_argument('--from-test', '-f',
help='start from test')
parser.add_argument('--to-test', '-t',
help='stop at a test')
parser.add_argument('--inject-test', '-j',
help='Inject provided test after each test planned to run')
parser.add_argument('--exclude', '-e', action='append',
help='exclude tests')
parser.add_argument('--glob', '-g', action='append',
help='glob of tests')
parser.add_argument('--db', nargs='+',
help='DB file to read for tests to run')
parser.add_argument('--db-check', action='store_true',
help='DB check')
parser.add_argument('--test-kernel',
help='Test specified kernel instead of current kernel. works with db.')
parser.add_argument('--test-nic',
help='Test specified nic instead of current nic. works with db.')
parser.add_argument('--test-fw',
help='Test specified fw instead of current fw. works with db.')
parser.add_argument('--test-simx', action='store_true', help="Test SimX.")
parser.add_argument('--log_dir',
help='Log dir to save all logs under')
parser.add_argument('--html', action='store_true',
help='Save log files in HTML and a summary')
parser.add_argument('--randomize', '-r', action='store_true',
help='Randomize the order of the tests')
parser.add_argument('--group', action='store_true',
help='Sort tests by group')
parser.add_argument('--loops', default=0, type=int,
help='Loop the tests. stop if loop fails.')
parser.add_argument('--run-skipped', action='store_true',
help='Run tests that are skipped by open issue.')
parser.add_argument('--rerun-failed', action='store_true',
help='Rerun failed test.')
return parser.parse_args()
def get_better_status(rc, log):
status = log.splitlines()[-1].strip()
status = strip_color(status)
lookback = 7
if rc:
# look for better status
for line in log.splitlines()[-lookback:]:
line = strip_color(line.strip())
if line.startswith('ERROR: '):
status = line
break
return status
if 'TEST PASSED' not in status:
# maybe some cleanup prints so look a bit back but not too much
for line in log.splitlines()[-lookback:]:
line = strip_color(line.strip())
if line == 'TEST PASSED':
status = line
break
return status
def get_kmemleak_info():
if not os.path.exists(KMEMLEAK_SYSFS):
return ''
data = ''
with open(KMEMLEAK_SYSFS) as f:
data = f.read().strip()
if data:
data = "\n\n\n%s\n%s\n" % ("kmemleak trace", data)
with open(KMEMLEAK_SYSFS, 'w') as f:
f.write('clear')
return data
def run_test(test, html=False):
cmd = test.cmd
env = os.environ.copy()
env.update({"ENABLE_OVS_LOG_DUMP": "1"})
env.update(test.opts.get('env', {}))
test_timeout = test.opts.get('timeout', TEST_TIMEOUT_MAX)
logname = os.path.join(LOGDIR, test.test_log)
logname_html = os.path.join(LOGDIR, test.test_log_html)
# piping stdout to file seems to miss stderr msgs to we use pipe
# and write to file at the end.
timedout = False
terminated = False
subp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, close_fds=True, env=env)
try:
try:
out, _ = subp.communicate(timeout=test_timeout)
except subprocess.TimeoutExpired as e:
subp.kill()
out = e.output
try:
out, _ = subp.communicate(timeout=1)
except subprocess.TimeoutExpired as e:
subp.terminate()
out = e.output
kmsg("Test got terminated")
terminated = True
timedout = True
except AttributeError:
# timeout introduced in python3.3
out, _ = subp.communicate()
if args.dry:
return "nothing"
if not out:
raise ExecCmdFailed("Empty result")
rc = subp.returncode
log = out.decode('ascii', 'ignore')
if not log:
raise ExecCmdFailed("Empty output")
if timedout:
if terminated:
status = "Test timed out and got terminated"
else:
status = "Test timed out and got killed"
log += "\n%s\n" % deco("ERROR: %s" % status, 'red')
rc = 1
else:
# not timedout
status = get_better_status(rc, log)
memleak = get_kmemleak_info()
if memleak:
log += "\n\n"
unref_count = memleak.count("unreferenced object")
ignore_count = 0
with open(kmemleak_ignore) as f:
for line in f.readlines():
line = line.strip()
if not line or line.startswith("#"):
continue
ignore_count += memleak.count(line)
if unref_count == ignore_count:
log += "Found %d known memory leaks\n\n" % ignore_count
else:
status = "kmemleak found issues"
rc = 1
log += memleak
with open(logname, 'w') as f1:
f1.write(log)
if html:
with open(logname_html, 'w') as f2:
f2.write(Ansi2HTMLConverter().convert(log))
if rc:
raise ExecCmdFailed(status)
return status
def deco(line, color, html=False):
if not line or not color:
return line
if html:
return "<span style='color: %s'>%s</span>" % (color, line)
return "\033[%dm%s\033[0m" % (COLOURS[color], line)
def strip_color(line):
return re.sub(r"\033\[[0-9 ;]*m", '', line)
def err(line):
print(deco('ERROR', 'red') + ' %s' % line)
def warn(line):
print(deco('WARNING', 'yellow') + ' %s' % line)
def format_result(res, out='', html=False):
res_color = {
'TEST PASSED': 'green',
'SKIP': 'yellow',
'OK': 'green',
'DRY': 'gray',
'FAILED': 'red',
'TERMINATED': 'red',
'IGNORED': 'gray',
"DIDN'T RUN": 'darkred',
}
color = res_color.get(res, 'yellow')
if "SKIP SHOW STOPPER" in res:
color = 'yellow'
elif "IGNORED SHOW STOPPER" in res:
color = 'gray'
elif "FAILED SHOW STOPPER" in res:
color = 'red'
if out and "TEST FAILED" not in out and "TEST PASSED" not in out:
res += ' (%s)' % out
return deco(res, color, html)
def sort_tests(tests, randomize=False):
def cmp1(x):
return x[:-3].replace('-', 'a')
if randomize:
warn('Randomize temporarily disabled. sort by name.')
randomize = False
if randomize:
print('Randomizing the tests order')
random.shuffle(tests)
elif type(tests[0]) == str:
key=lambda x: cmp1(os.path.basename(x))
elif args.group:
key=lambda x: cmp1(x.group + x.name)
else:
key=lambda x: cmp1(x.name)
tests.sort(key=key)
def glob_tests(glob_filter):
if not glob_filter:
return
_tests = []
if len(glob_filter) == 1 and (' ' in glob_filter[0] or '\n' in glob_filter[0]):
glob_filter = glob_filter[0].strip().split()
elif len(glob_filter) == 1 and ',' in glob_filter[0]:
glob_filter = glob_filter[0].split(',')
for test in TESTS:
for g in glob_filter:
if fnmatch(test.name, g):
_tests.append(test)
break
for test in TESTS[:]:
if test not in _tests:
TESTS.remove(test)
def get_config():
if 'CONFIG' not in os.environ:
if not (args.dry or args.db_check):
raise RuntimeError("CONFIG environment variable is missing.")
return
config = os.environ['CONFIG']
if os.path.exists(config):
return config
elif os.path.exists(os.path.join(MYDIR, config)):
return os.path.join(MYDIR, config)
raise RuntimeError("Cannot find config %s" % config)
def get_config_value(key):
config = get_config()
if not config:
return
try:
with open(config, 'r') as f1:
for line in f1.readlines():
if line.startswith("%s=" % key):
return line.split('=')[1].strip().strip('"')
except IOError:
err("Cannot read config %s." % config)
def get_pci(nic):
try:
return os.path.basename(os.readlink("/sys/class/net/%s/device" % nic))
except FileNotFoundError:
return ''
def get_flow_steering_mode_compat(nic):
ofed_compat = "/sys/class/net/%s/compat/devlink/steering_mode" % nic
try:
with open(ofed_compat, 'r') as f:
return f.read().strip()
except IOError:
pass
def get_flow_steering_mode(nic):
if not nic:
return ''
mode = get_flow_steering_mode_compat(nic)
if mode:
return mode
pci = get_pci(nic)
cmd = "devlink dev param show pci/%s name flow_steering_mode" % pci
try:
output = subprocess.check_output(cmd, shell=True).decode().strip()
except subprocess.CalledProcessError:
return
return output.split()[-1]
def check_ovs_asan():
try:
output1 = subprocess.check_output("nm /usr/sbin/ovs-vswitchd 2>/dev/null", shell=True).decode().strip()
output2 = subprocess.check_output("nm -D /usr/sbin/ovs-vswitchd 2>/dev/null", shell=True).decode().strip()
output1 += output2
except subprocess.CalledProcessError:
return
return '__sanitizer_syscall_' in output1 or '__asan_init' in output1
def get_current_fw(nic):
if not nic:
return ''
cmd = "ethtool -i %s | grep firmware-version | awk {'print $2'}" % nic
output = subprocess.check_output(cmd, shell=True).decode().strip()
if not output:
err("Cannot get FW version.")
return output
def get_current_nic_type(nic):
if not nic:
return ''
try:
with open('/sys/class/net/%s/device/device' % nic, 'r') as f:
return f.read().strip()
except FileNotFoundError:
return ''
def check_simx(nic):
if not nic:
return False
current_pci = get_pci(nic)
cmd = "lspci -s %s -vvv | grep SimX" % current_pci
try:
output = subprocess.check_output(cmd, shell=True).decode().strip()
except subprocess.CalledProcessError:
return False
return True
def fix_path_from_config():
path = get_config_value('PATH')
if not path:
return
newp = []
for p in path.split(os.pathsep):
if p == "$PATH":
continue
newp.append(p)
os.environ['PATH'] = os.pathsep.join(newp) + os.pathsep + os.environ['PATH']
def get_ovs_vswitchd_version_output():
try:
output = subprocess.check_output("ovs-vswitchd --version", shell=True, stderr=subprocess.DEVNULL).decode().strip()
except subprocess.CalledProcessError:
return ''
return output
def get_ovs_version():
output = get_ovs_vswitchd_version_output()
if 'ovs-vswitchd' in output:
return output.splitlines()[0].split()[-1]
return ''
def get_ovs_dpdk_version():
output = get_ovs_vswitchd_version_output()
for line in output.splitlines():
if 'DPDK' in line:
return line.split()[-1]
return ''
def get_ovs_doca_version():
output = get_ovs_vswitchd_version_output()
for line in output.splitlines():
if 'DOCA' in line:
return line.split()[-1]
return ''
def get_mlnx_ofed_version():
try:
output = subprocess.check_output("ofed_info -s", shell=True, stderr=subprocess.DEVNULL).decode().strip()
except subprocess.CalledProcessError:
return ''
return output.strip(':')
__is_bf_host = None
def is_bf_host():
global __is_bf_host
if __is_bf_host is not None:
return __is_bf_host
try:
subprocess.check_output("lspci 2>/dev/null | grep -m1 -wq \"Mellanox .* BlueField.* integrated\"", shell=True)
__is_bf_host = True
except subprocess.CalledProcessError:
__is_bf_host = False
return __is_bf_host
def get_current_state():
global envinfo
global current_nic
global current_fw_ver
global current_kernel
global flow_steering_mode
global simx_mode
global dpdk_mode
global ovs_asan
_distro = get_distro()
if 'PRETTY_NAME' in _distro:
distro = _distro['PRETTY_NAME']
else:
distro = ''
fix_path_from_config()
nic = get_config_value('NIC')
dpdk_mode = get_config_value('DPDK') == '1'
current_fw_ver = args.test_fw or get_current_fw(nic)
current_nic = args.test_nic if args.test_nic else DeviceType.get(get_current_nic_type(nic))
current_kernel = args.test_kernel if args.test_kernel else os.uname()[2]
flow_steering_mode = get_flow_steering_mode(nic)
simx_mode = True if args.test_simx else check_simx(nic)
ovs_asan = check_ovs_asan()
envinfo.update({
'dpdk version': get_ovs_dpdk_version(),
'doca version': get_ovs_doca_version(),
'ovs version': get_ovs_version(),
'mlnx ofed version': get_mlnx_ofed_version(),
'nic': current_nic,
'firmware version': current_fw_ver,
'kernel': current_kernel,
'flow steering mode': flow_steering_mode,
'simx': simx_mode,
'ovs_asan': ovs_asan,
'distro': distro,
'config dpdk': dpdk_mode,
'is_bf_host': is_bf_host(),
})
for key in envinfo:
print("%s: %s" % (key, envinfo[key]))
def update_skip_according_to_db(rm, _tests, data):
if type(data['tests']) is list:
return
def kernel_match(kernel1, kernel2):
if kernel1 in custom_kernels:
kernel1 = custom_kernels[kernel1]
if kernel1 in kernel2:
return True
# regex issue with strings like "3.10-100+$" so use string compare for exact match.
if (kernel1.strip('()') == kernel2 or re.search("^%s$" % kernel1, kernel2)):
return True
return False
def should_ignore(key, t):
if key is True:
t.set_ignore("Not supported")
return True
elif type(key) == str:
t.set_ignore("Not supported: %s" % key)
return True
elif type(key) == list:
for k in key:
if k == flow_steering_mode:
t.set_ignore("Unsupported flow steering mode %s" % k)
return True
if k == current_nic:
t.set_ignore("Unsupported nic %s" % k)
return True
if kernel_match(k, current_kernel):
t.set_ignore("Unsupported kernel %s" % k)
return True
return False
def fw_ignore(min_fw, current_fw_ver, t):
if current_fw_ver:
cx_type = min_fw.split('.')[0]
cx_ver = min_fw[min_fw.index('.')+1:]
current_cx_type = current_fw_ver.split('.')[0]
current_cx_ver = current_fw_ver[current_fw_ver.index('.')+1:]
if cx_type in (current_cx_type, 'xx') and VersionInfo(current_cx_ver) < VersionInfo(cx_ver):
t.set_ignore("Unsupported fw version. Minimum %s" % min_fw)
else:
t.set_failed("Invalid fw to compare")
custom_kernels = data.get('custom_kernels', {})
is_debug_kernel = '_debug_' in current_kernel and '_min_debug_' not in current_kernel
print_newline = False
bugs_list_count = 0
for t in _tests:
if t.ignore:
continue
name = t.name
opts = t.opts
t.bugs_list = []
ignore_for_linust = opts.get('ignore_for_linust', 0)
ignore_for_upstream = opts.get('ignore_for_upstream', 0)
ignore_for_debug_kernel = opts.get('ignore_for_debug_kernel', 0)
if ignore_for_debug_kernel and is_debug_kernel:
t.set_ignore("Ignore on debug kernel")
if ignore_for_linust and ignore_for_upstream:
raise RuntimeError("%s: Do not ignore on both for_linust and for_upstream." % name)
if ignore_for_linust and 'linust' in current_kernel:
t.set_ignore("Ignore on for-linust kernel")
continue
if ignore_for_upstream and 'upstream' in current_kernel:
t.set_ignore("Ignore on for-upstream kernel")
continue
ignore_fs = opts.get('ignore_flow_steering', '')
if ignore_fs and (not flow_steering_mode or ignore_fs == flow_steering_mode):
t.set_ignore("Ignore flow steering mode %s" % ignore_fs)
continue
ignore_not_supported = opts.get('ignore_not_supported', 0)
if should_ignore(ignore_not_supported, t):
continue
ignore_failed = opts.get('ignore_failed', 0)
if ignore_failed:
t.set_skip("Test failed and first ignored - check manually")
if is_bf_host():
min_kernel = ''
elif re.search(r'\.el[0-9]+[\.|_]', current_kernel):
min_kernel = str(opts.get('min_kernel_rhel', ''))
elif 'bluefield' in current_kernel:
min_kernel = str(opts.get('min_kernel_bf', ''))
else:
min_kernel = str(opts.get('min_kernel', ''))
if 'for_upstream' in min_kernel:
if 'for_upstream' in current_kernel:
try:
d1 = re.search(r'(\d\d\d\d)_(\d\d)_(\d\d)', min_kernel).group()
d1 = datetime.strptime(d1, '%Y_%m_%d')
d2 = re.search(r'(\d\d\d\d)_(\d\d)_(\d\d)', current_kernel).group()
d2 = datetime.strptime(d2, '%Y_%m_%d')
if d1 > d2:
t.set_ignore("Unsupported kernel version. Minimum %s" % min_kernel)
except AttributeError as e:
t.set_failed("Failed to parse datetime from kernel")
elif 'for_linust' in min_kernel:
if 'for_linust' in current_kernel:
try:
d1 = re.search(r'(\d\d\d\d)_(\d\d)_(\d\d)', min_kernel).group()
d1 = datetime.strptime(d1, '%Y_%m_%d')
d2 = re.search(r'(\d\d\d\d)_(\d\d)_(\d\d)', current_kernel).group()
d2 = datetime.strptime(d2, '%Y_%m_%d')
if d1 > d2:
t.set_ignore("Unsupported kernel version. Minimum %s" % min_kernel)
except AttributeError as e:
t.set_failed("Failed to parse datetime from kernel")
elif min_kernel:
# dont match min_kernel with custom_kernels list.
kernels = []
kernels += custom_kernels.values()
ok = False
for kernel in kernels:
if kernel_match(kernel, current_kernel):
ok = True
break
if not ok:
a = VersionInfo(min_kernel)
b = VersionInfo(current_kernel)
if b < a:
t.set_ignore("Unsupported kernel version. Minimum %s" % min_kernel)
continue
for nic in opts.get('ignore_nic', []):
if nic == current_nic:
t.set_ignore("Unsupported nic %s" % nic)
break