-
Notifications
You must be signed in to change notification settings - Fork 2
/
run-ci.py
executable file
·1706 lines (1325 loc) · 53 KB
/
run-ci.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/env python3
import os
import sys
import argparse
import logging
import subprocess
import configparser
import requests
import re
import smtplib
import shutil
import email.utils
import pathlib
import tarfile
import time
from enum import Enum
from github import Github
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Globals
logger = None
config = None
github_repo = None
github_pr = None
github_commits = None
pw_sid = None
pw_series = None
pw_series_patch_1 = None
base_dir = None
src_dir = None
src2_dir = None
src3_dir = None
src4_dir = None
src5_dir = None
ell_dir = None
test_suite = {}
PW_BASE_URL = "https://patchwork.kernel.org/api/1.1"
EMAIL_MESSAGE = '''This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:{}
---Test result---
{}
---
Regards,
Linux Bluetooth
'''
def requests_url(url):
""" Helper function to requests WEB API GET with URL """
resp = requests.get(url)
if resp.status_code != 200:
raise requests.HTTPError("GET {}".format(resp.status_code))
return resp
def requests_post(url, headers, content):
""" Helper function to post data to URL """
resp = requests.post(url, content, headers=headers)
if resp.status_code != 201:
raise requests.HTTPError("POST {}".format(resp.status_code))
return resp
def patchwork_get_series(sid):
""" Get series detail from patchwork """
url = PW_BASE_URL + "/series/" + sid
req = requests_url(url)
return req.json()
def patchwork_get_patch(patch_id: str):
""" Get patch detsil from patchwork """
url = PW_BASE_URL + "/patches/" + patch_id
req = requests_url(url)
return req.json()
def patchwork_save_patch(patch, filename):
""" Save patch to file and return the file path """
patch_mbox = requests_url(patch["mbox"])
with open(filename, "wb") as file:
file.write(patch_mbox.content)
return filename
def patchwork_save_patch_msg(patch, filename):
""" Save patch commit message to file and return the file path """
with open(filename, "wb") as file:
file.write(bytes(patch['name'], 'utf-8'))
file.write(b"\n\n")
file.write(bytes(patch['content'], 'utf-8'))
return filename
def patchwork_get_sid(pr_title):
"""
Parse PR title prefix and get PatchWork Series ID
PR Title Prefix = "[PW_S_ID:<series_id>] XXXXX"
"""
try:
sid = re.search(r'^\[PW_SID:([0-9]+)\]', pr_title).group(1)
except AttributeError:
logging.error("Unable to find the series_id from title %s" % pr_title)
sid = None
return sid
def patchwork_get_patch_detail_title(title):
"""
Use :title to find a matching patch in series and get the detail
"""
for patch in pw_series['patches']:
if (patch['name'].find(title) != -1):
logger.debug("Found matching patch title in the series")
req = requests_url(patch['url'])
return req.json()
logger.debug("No matching patch title found")
logger.error("Cannot find a matching patch from PatchWork series")
def patchwork_post_checks(url, state, target_url, context, description):
"""
Post checks(test results) to the patchwork site(url)
"""
logger.debug("URL: %s" % url)
headers = {}
if 'PATCHWORK_TOKEN' in os.environ:
token = os.environ['PATCHWORK_TOKEN']
headers['Authorization'] = f'Token {token}'
content = {
'user': 104215,
'state': state,
'target_url': target_url,
'context': context,
'description': description
}
logger.debug("Content: %s" % content)
req = requests_post(url, headers, content)
return req.json()
GITHUB_COMMENT = '''**{display_name}**
Test ID: {name}
Desc: {desc}
Duration: {elapsed:.2f} seconds
**Result: {status}**
'''
GITHUB_COMMENT_OUTPUT = '''Output:
```
{output}
```
'''
def github_pr_post_comment(test):
""" Post message to PR page """
comment = GITHUB_COMMENT.format(name=test.name,
display_name=test.display_name,
desc=test.desc,
status=test.verdict.name,
elapsed=test.elapsed())
if test.output:
output = GITHUB_COMMENT_OUTPUT.format(output=test.output)
comment += output
github_pr.create_issue_comment(comment)
def run_cmd(*args, cwd=None):
""" Run command and return return code, stdout and stderr """
cmd = []
cmd.extend(args)
cmd_str = "{}".format(" ".join(str(w) for w in cmd))
logger.info("CMD: %s" % cmd_str)
stdout = ""
try:
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
bufsize=1,
universal_newlines=True,
cwd=cwd)
except OSError as e:
logger.error("ERROR: failed to run cmd: %s" % e)
return (-1, None, None)
for line in proc.stdout:
logger.debug(line.rstrip('\n'))
stdout += line
# stdout is consumed in previous line. so, communicate() returns empty
_ignore, stderr = proc.communicate()
logger.debug(">> STDERR\n{}".format(stderr))
return (proc.returncode, stdout, stderr)
def git_config_add_safe_dir(path):
"""
Add @path to the safe.directory in git config
"""
(ret, stdout, stderr) = run_cmd("git", "config", "--global", "--add", "safe.directory", path, cwd=path)
if ret:
logger.error("Failed to add %s to safe.directory" % path)
else:
logger.debug("%s is added to safe.directory" % path)
def config_enable(config, name):
"""
Check "enable" in config[name].
Return False if it is specifed otherwise True
"""
if name in config:
if 'enable' in config[name]:
if config[name]['enable'] == 'no':
logger.info("config." + name + " is disabled")
return False
logger.info("config." + name + " is enabled")
return True
def config_submit_pw(config, name):
"""
Check "submit_pw" in config[name]
Return True if it is specified and value is "yes"
"""
if name in config:
if 'submit_pw' in config[name]:
if config[name]['submit_pw'] == 'yes':
logger.info("config." + name + ".submit_pw is enabled")
return True
logger.info("config." + name + ".submit_pw is disabled")
return False
def send_email(sender, receiver, msg):
""" Send email """
email_cfg = config['email']
if 'EMAIL_TOKEN' not in os.environ:
logging.warning("missing EMAIL_TOKEN. Skip sending email")
return
try:
session = smtplib.SMTP(email_cfg['server'], int(email_cfg['port']))
session.ehlo()
if 'starttls' not in email_cfg or email_cfg['starttls'] == 'yes':
session.starttls()
session.ehlo()
session.login(sender, os.environ['EMAIL_TOKEN'])
session.sendmail(sender, receiver, msg.as_string())
logging.info("Successfully sent email")
except Exception as e:
logging.error("Exception: {}".format(e))
finally:
session.quit()
logging.info("Sending email done")
def get_receivers(submitter):
"""
Get list of receivers
"""
logger.debug("Get Receivers list")
email_cfg = config['email']
receivers = []
if 'only-maintainers' in email_cfg and email_cfg['only-maintainers'] == 'yes':
# Send only to the addresses in the 'maintainers'
maintainers = "".join(email_cfg['maintainers'].splitlines()).split(",")
receivers.extend(maintainers)
else:
# Send to default-to address and submitter
receivers.append(email_cfg['default-to'])
receivers.append(submitter)
return receivers
def get_sender():
"""
Get Sender from configuration
"""
email_cfg = config['email']
return email_cfg['user']
def get_default_to():
"""
Get Default address which is a mailing list address
"""
email_cfg = config['email']
return email_cfg['default-to']
def is_maintainer_only():
"""
Return True if it is configured to send maintainer-only
"""
email_cfg = config['email']
if 'only-maintainers' in email_cfg and email_cfg['only-maintainers'] == 'yes':
return True
return False
def compose_email(title, body, submitter, msgid):
"""
Compose and send email
"""
receivers = get_receivers(submitter)
sender = get_sender()
# Create message
msg = MIMEMultipart()
msg['From'] = sender
msg['To'] = ", ".join(receivers)
msg['Subject'] = "RE: " + title
# In case to use default-to address, set Reply-To to mailing list in case
# submitter reply to the result email.
if not is_maintainer_only():
msg['Reply-To'] = get_default_to()
# Message Header
msg.add_header('In-Reply-To', msgid)
msg.add_header('References', msgid)
logger.debug("Message Body: %s" % body)
msg.attach(MIMEText(body, 'plain'))
logger.debug("Mail Message: {}".format(msg))
# Send email
send_email(sender, receivers, msg)
def is_workflow_patch(commit):
"""
If the message contains a word "workflow", then return True.
This is basically to prevent the workflow patch for github from running
checkpath and gitlint tests.
"""
if commit.commit.message.find("workflow:") >= 0:
return True
return False
class Verdict(Enum):
PENDING = 0
PASS = 1
FAIL = 2
ERROR = 3
SKIP = 4
WARNING = 5
def patchwork_state(verdict):
"""
Convert verdict to patchwork state
"""
if verdict == Verdict.PASS:
return 1
if verdict == Verdict.WARNING:
return 2
if verdict == Verdict.FAIL:
return 3
return 0
class CiBase:
"""
Base class for CI Tests.
"""
name = None
display_name = None
desc = None
enable = True
start_time = 0
end_time = 0
submit_pw = False
verdict = Verdict.PENDING
output = ""
def success(self):
self.end_timer()
self.verdict = Verdict.PASS
def error(self, msg):
self.verdict = Verdict.ERROR
self.output = msg
self.end_timer()
raise EndTest
def warning(self, msg):
self.verdict = Verdict.WARNING
self.output = msg
self.end_timer()
def skip(self, msg):
self.verdict = Verdict.SKIP
self.output = msg
self.end_timer()
raise EndTest
def add_failure(self, msg):
self.verdict = Verdict.FAIL
if not self.output:
self.output = msg
else:
self.output += "\n" + msg
def add_failure_end_test(self, msg):
self.add_failure(msg)
self.end_timer()
raise EndTest
def start_timer(self):
self.start_time = time.time()
def end_timer(self):
self.end_time = time.time()
def elapsed(self):
if self.start_time == 0:
return 0
if self.end_time == 0:
self.end_timer()
return self.end_time - self.start_time
def submit_result(self, patch, verdict, description, url=None, name=None):
"""
Submit the result to Patchwork
"""
if self.submit_pw == False:
logger.info("Submitting PW is disabled. Skipped")
return
if url == None:
url = github_pr.html_url
if name == None:
name = self.name
logger.debug("Submitting the result to Patchwork")
pw_output = patchwork_post_checks(patch['checks'],
patchwork_state(verdict),
url,
name,
description)
logger.debug("Submit result\n%s" % pw_output)
class CheckPatch(CiBase):
name = "checkpatch"
display_name = "CheckPatch"
desc = "Run checkpatch.pl script with rule in .checkpatch.conf"
checkpatch_pl = '/usr/bin/checkpatch.pl'
def config(self):
"""
Config the test cases.
"""
logger.debug("Parser configuration")
self.enable = config_enable(config, self.name)
self.submit_pw = config_submit_pw(config, self.name)
if self.name in config:
if 'bin_path' in config[self.name]:
self.checkpatch_pl = config[self.name]['bin_path']
logger.debug("checkpatch_pl = %s" % self.checkpatch_pl)
def run(self):
logger.debug("##### Run CheckPatch Test #####")
self.start_timer()
self.config()
# Check if it is disabled.
if self.enable == False:
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"CheckPatch SKIP(Disabled)")
self.skip("Disabled in configuration")
# Use patches from patchwork
for patch_item in pw_series['patches']:
logger.debug("patch id: %s" % patch_item['id'])
patch = patchwork_get_patch(str(patch_item["id"]))
# Run checkpatch
(output, error) = self.run_checkpatch(patch)
# Failed / Warning
if error != None:
msg = "{}\n{}".format(patch['name'], error)
if error.find("WARNING:") != -1:
if error.find("ERROR:") != -1:
self.submit_result(patch, Verdict.FAIL, msg)
else:
self.submit_result(patch, Verdict.WARNING, msg)
else:
self.submit_result(patch, Verdict.FAIL, msg)
self.add_failure(msg)
continue
# Warning in output
if output.find("WARNING:") != -1:
self.submit_result(patch, Verdict.WARNING, output)
continue
# Success
self.submit_result(patch, Verdict.PASS, "Checkpatch PASS")
# Overall status
if self.verdict != Verdict.FAIL:
self.success()
def run_checkpatch(self, patch):
"""
Run checkpatch script with patch from the patchwork.
It saves to file first and run checkpatch with the saved patch file.
On success, it returns None.
On failure, it returns the stderr output string
"""
output = None
error = None
# Save the patch content to file
filename = os.path.join(src_dir, str(patch['id']) + ".patch")
logger.debug("Save patch: %s" % filename)
patch_file = patchwork_save_patch(patch, filename)
try:
output = subprocess.check_output((self.checkpatch_pl, '--no-tree',
patch_file),
stderr=subprocess.STDOUT,
cwd=src_dir)
output = output.decode("utf-8")
except subprocess.CalledProcessError as ex:
error = ex.output.decode("utf-8")
logger.error("checkpatch.pl returned with error")
logger.error("output: %s" % error)
return (output, error)
class GitLint(CiBase):
name = "gitlint"
display_name = "GitLint"
desc = "Run gitlint with rule in .gitlint"
gitlint_config = '/.gitlint'
def config(self):
"""
Config the test cases.
"""
logger.debug("Parser configuration")
self.enable = config_enable(config, self.name)
self.submit_pw = config_submit_pw(config, self.name)
if self.name in config:
if 'config_path' in config[self.name]:
self.gitlint_config = config[self.name]['config_path']
logger.debug("gitlint_config = %s" % self.gitlint_config)
def run(self):
logger.debug("##### Run Gitlint v2 Test #####")
self.start_timer()
self.config()
# Check if it is disabled.
if self.enable == False:
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"Gitlint SKIP(Disabled)")
self.skip("Disabled in configuration")
# Use patches from patchwork
for patch_item in pw_series['patches']:
logger.debug("patch_id: %s" % patch_item['id'])
patch = patchwork_get_patch(str(patch_item['id']))
# Run gitlint
output = self.run_gitlint(patch)
# Failed
if output != None:
msg = "{}\n{}".format(patch['name'], output)
self.submit_result(patch, Verdict.FAIL, msg)
self.add_failure(msg)
continue
# Success
self.submit_result(patch, Verdict.PASS, "Gitlint PASS")
# Overall status
if self.verdict != Verdict.FAIL:
self.success()
def run_gitlint(self, patch):
"""
Run checkpatch script with patch from the patchwork.
It saves the commit message to the file first and run gitlint with it.
On success, it returns None.
On failure, it returns the stderr output string
"""
output = None
# Save the patch commit message to file
filename = os.path.join(src_dir, str(patch['id']) + ".commit_msg")
logger.debug("Save commit msg: %s" % filename)
commit_msg_file = patchwork_save_patch_msg(patch, filename)
try:
subprocess.check_output(('gitlint', '-C', self.gitlint_config,
"--msg-filename", commit_msg_file),
stderr=subprocess.STDOUT,
cwd=src_dir)
except subprocess.CalledProcessError as ex:
output = ex.output.decode("utf-8")
logger.error("gitlint returned error/warning")
logger.error("output: %s" % output)
return output
class BuildSetup_ell(CiBase):
name = "setupell"
display_name = "Prep - Setup ELL"
desc = "Clone, build, and install ELL"
def config(self):
"""
Configure the test case
"""
logger.debug("Parser configuration")
self.enable = config_enable(config, "build")
self.submit_pw = config_submit_pw(config, "build")
def run(self):
logger.debug("##### Run Build: Setup ELL #####")
self.start_timer()
self.config()
# Run only if build is enabled
if self.enable == False:
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"Setup ELL SKIP(Disabled)")
self.skip("Build is disabled")
# bootstrap-configure
(ret, stdout, stderr) = run_cmd("./bootstrap-configure", cwd=ell_dir)
if ret:
self.submit_result(pw_series_patch_1, Verdict.FAIL,
"Setup ELL - Configuration FAIL: " + stderr)
self.add_failure_end_test(stderr)
# make
(ret, stdout, stderr) = run_cmd("make", "-j2", cwd=ell_dir)
if ret:
self.submit_result(pw_series_patch_1, Verdict.FAIL,
"Setup ELL - make FAIL: " + stderr)
self.add_failure_end_test(stderr)
# install
(ret, stdout, stderr) = run_cmd("make", "install", cwd=ell_dir)
if ret:
self.submit_result(pw_series_patch_1, Verdict.FAIL,
"Setup ELL - make install FAIL: " + stderr)
self.add_failure_end_test(stderr)
self.submit_result(pw_series_patch_1, Verdict.PASS, "Setup ELL PASS")
self.success()
class BuildPrep(CiBase):
name = "buildprep"
display_name = "Build - Prep"
desc = "Prepare environment for build"
def config(self):
"""
Config the test case
"""
logger.debug("Parser configuration")
self.enable = config_enable(config, "build")
self.submit_pw = config_submit_pw(config, "build")
def run(self):
logger.debug("##### Run Build: Prep #####")
self.start_timer()
self.config()
# Duplicate the src for 2nd build test case
shutil.copytree(src_dir, src2_dir)
git_config_add_safe_dir(src2_dir)
logger.debug("Duplicate src_dir to src2_dir")
# Duplicate the src for 2nd build test case
shutil.copytree(src_dir, src3_dir)
git_config_add_safe_dir(src3_dir)
logger.debug("Duplicate src_dir to src3_dir")
# Duplicate the src for make check with valgrind
shutil.copytree(src_dir, src4_dir)
git_config_add_safe_dir(src4_dir)
logger.debug("Duplicate src_dir to src4_dir")
# Duplicate the src for scan-build
shutil.copytree(src_dir, src5_dir)
git_config_add_safe_dir(src5_dir)
logger.debug("Duplicate src_dir to src5_dir")
self.submit_result(pw_series_patch_1, Verdict.PASS, "Build Prep PASS")
self.success()
class Build(CiBase):
name = "build"
display_name = "Build - Configure"
desc = "Configure the BlueZ source tree"
def config(self):
"""
Configure the test cases.
"""
logger.debug("Parser configuration")
self.enable = config_enable(config, self.name)
self.submit_pw = config_submit_pw(config, self.name)
def run(self):
logger.debug("##### Run Build Test #####")
self.start_timer()
self.config()
# Check if it is disabled.
if self.enable == False:
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"Build SKIP(Disabled)")
self.skip("Disabled in configuration")
# bootstrap-configure
(ret, stdout, stderr) = run_cmd("./bootstrap-configure",
cwd=src_dir)
if ret:
self.submit_result(pw_series_patch_1, Verdict.FAIL,
"Build Configuration FAIL: " + stderr)
self.add_failure_end_test(stderr)
# At this point, consider test passed here
self.submit_result(pw_series_patch_1, Verdict.PASS,
"Build Configuration PASS")
self.success()
class BuildMake(CiBase):
name = "buildmake"
display_name = "Build - Make"
desc = "Build the BlueZ source tree"
def config(self):
"""
Configure the test cases.
"""
logger.debug("Parser configuration")
self.enable = config_enable(config, self.name)
self.submit_pw = config_submit_pw(config, self.name)
def run(self):
logger.debug("##### Run Build Make Test #####")
self.start_timer()
self.config()
# Check if it is disabled.
if self.enable == False:
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"Make SKIP(Disabled)")
self.skip("Disabled in configuration")
# Only run if "checkbuild" success
if test_suite["build"].verdict != Verdict.PASS:
logger.info("build test did not pass. skip this test")
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"Make SKIP")
self.skip("build test did not pass")
# make
(ret, stdout, stderr) = run_cmd("make", "-j2", cwd=src_dir)
if ret:
self.submit_result(pw_series_patch_1, Verdict.FAIL,
"Make FAIL: " + stderr)
self.add_failure_end_test(stderr)
# At this point, consider test passed here
self.submit_result(pw_series_patch_1, Verdict.PASS, "Make PASS")
self.success()
class MakeCheck(CiBase):
name = "makecheck"
display_name = "Make Check"
desc = "Run \'make check\'"
def config(self):
"""
Configure the test cases.
"""
logger.debug("Parser configuration")
self.enable = config_enable(config, self.name)
self.submit_pw = config_submit_pw(config, self.name)
def run(self):
logger.debug("##### Run MakeCheck Test #####")
self.start_timer()
self.config()
# Check if it is disabled.
if self.enable == False:
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"Make Check SKIP(Disabled)")
self.skip("Disabled in configuration")
# Only run if "checkbuild" success
if test_suite["build"].verdict != Verdict.PASS:
logger.info("build test is not success. skip this test")
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"Make SKIP")
self.skip("build test is not success")
# Run make check. Assume the code is already configuared and problem
# to build.
(ret, stdout, stderr) = run_cmd("make", "check", cwd=src_dir)
if ret:
self.submit_result(pw_series_patch_1, Verdict.FAIL,
"Make Check FAIL: " + stderr)
self.add_failure_end_test(stderr)
# At this point, consider test passed here
self.submit_result(pw_series_patch_1, Verdict.PASS, "Make Check PASS")
self.success()
class MakeCheckValgrind(CiBase):
name = "makecheckvalgrind"
display_name = "Make Check w/Valgrind"
desc = "Run \'make check\' with Valgrind"
def config(self):
"""
Configure the test cases.
"""
logger.debug("Parser configuration")
self.enable = config_enable(config, self.name)
self.submit_pw = config_submit_pw(config, self.name)
def run(self):
logger.debug("##### Run MakeCheck w/ Valgrind Test #####")
self.start_timer()
self.config()
# Check if it is disabled.
if self.enable == False:
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"Make Check Valgrind SKIP(Disabled)")
self.skip("Disabled in configuration")
# Only run if "checkbuild" success
if test_suite["build"].verdict != Verdict.PASS:
logger.info("build test is not success. skip this test")
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"Make SKIP")
self.skip("build test is not success")
# bootstrap-configure without lsan and asan enabled
(ret, stdout, stderr) = run_cmd("./bootstrap-configure",
"--disable-lsan", "--disable-asan",
cwd=src4_dir)
if ret:
self.submit_result(pw_series_patch_1, Verdict.FAIL,
"Build Configuration FAIL: " + stderr)
self.add_failure_end_test(stderr)
# make
(ret, stdout, stderr) = run_cmd("make", "-j2", cwd=src4_dir)
if ret:
self.submit_result(pw_series_patch_1, Verdict.FAIL,
"Make FAIL: " + stderr)
self.add_failure_end_test(stderr)
# Run make check. Assume the code is already configuared and problem
# to build.
(ret, stdout, stderr) = run_cmd("make", "check", cwd=src4_dir)
if ret:
self.submit_result(pw_series_patch_1, Verdict.FAIL,
"Make Check FAIL: " + stderr)
self.add_failure_end_test(stderr)
# At this point, consider test passed here
self.submit_result(pw_series_patch_1, Verdict.PASS, "Make Check PASS")
self.success()
class MakeDistcheck(CiBase):
name = "makedistcheck"
display_name = "Make Distcheck"
desc = "Run distcheck to check the distribution"
def config(self):
"""
Configure the test cases
"""
logger.debug("Parser configuration")
self.enable = config_enable(config, self.name)
self.submit_pw = config_submit_pw(config, self.name)
def run(self):
logger.debug("##### Run Make Distcheck Test #####")
self.start_timer()
self.config()
# Check if it is disabled.
if self.enable == False:
self.submit_result(pw_series_patch_1, Verdict.SKIP,
"Make Distcheck SKIP(Disabled)")
self.skip("Disabled in configuration")
# Actual test starts:
# Configure
(ret, stdout, stderr) = run_cmd("./bootstrap-configure",
"--disable-asan", "--disable-lsan",
"--disable-ubsan", "--disable-android",
cwd=src_dir)
if ret:
self.submit_result(pw_series_patch_1, Verdict.FAIL,
"Make Distcheck Configure FAIL: " + stderr)
self.add_failure_end_test(stderr)