cppcheck/tools/rundaca2.py

84 lines
2.5 KiB
Python
Raw Normal View History

2017-06-04 22:51:48 +02:00
#!/usr/bin/env python
2015-08-20 12:57:45 +02:00
import subprocess
import pexpect
import os
import sys
2017-10-03 17:37:08 +02:00
import time
2015-08-20 12:57:45 +02:00
2016-05-10 11:00:57 +02:00
START = 0
2015-08-20 12:57:45 +02:00
PASSWORD = ''
for arg in sys.argv[1:]:
2016-07-23 13:44:05 +02:00
if len(arg) == 1:
START = '0123456789abcdefghijklmnopqrstuvwxyz'.find(arg)
if START < 0:
START = 0
else:
PASSWORD = arg
2015-08-20 12:57:45 +02:00
def compilecppcheck(CPPFLAGS):
subprocess.call(['nice', 'make', 'clean'])
2017-06-04 22:51:48 +02:00
subprocess.call(['nice', 'make', 'SRCDIR=build', 'CFGDIR=' +
os.path.expanduser('~/cppcheck/cfg'), 'CXXFLAGS=-g -O2', 'CPPFLAGS=' + CPPFLAGS])
subprocess.call(['cp', 'cppcheck', os.path.expanduser('~/daca2/cppcheck-O2')])
2017-06-04 22:51:48 +02:00
def runcppcheck(rev, folder):
subprocess.call(['rm', '-rf', os.path.expanduser('~/daca2/' + folder)])
2017-06-04 22:51:48 +02:00
subprocess.call(['nice', '--adjustment=19', 'python',
os.path.expanduser('~/cppcheck/tools/daca2.py'), folder, '--rev=' + rev,
'--skip=hashdeep', '--skip=lice'])
2017-06-04 22:51:48 +02:00
2017-06-03 12:10:41 +02:00
def daca2report(reportfolder):
2017-06-03 12:10:41 +02:00
subprocess.call(['rm', '-rf', reportfolder])
subprocess.call(['mkdir', reportfolder])
subprocess.call(['python', os.path.expanduser('~/cppcheck/tools/daca2-report.py'), reportfolder])
2017-06-04 22:51:48 +02:00
# Upload file to sourceforge server using scp
2017-06-03 12:10:41 +02:00
def upload(localfolder, webfolder):
2017-06-04 22:51:48 +02:00
if len(PASSWORD) < 3:
return
2017-09-28 09:57:13 +02:00
tries = 1
while tries <= 5:
try:
child = pexpect.spawn(
'scp -r ' + localfolder + ' danielmarjamaki,cppcheck@web.sf.net:htdocs/' + webfolder)
# child.expect('upload@trac.cppcheck.net\'s password:')
child.expect('Password:')
child.sendline(PASSWORD)
child.interact()
return
except (IOError, OSError, pexpect.TIMEOUT, pexpect.EOF):
print('Sleep for 10 seconds..')
time.sleep(10)
tries = tries + 1
2015-08-20 12:57:45 +02:00
2015-08-21 10:55:19 +02:00
2015-08-20 12:57:45 +02:00
def daca2(foldernum):
folders = '0123456789abcdefghijklmnopqrstuvwxyz'
folder = folders[foldernum % len(folders)]
print('Daca2 folder=' + folder)
os.chdir(os.path.expanduser('~/cppcheck'))
2017-06-03 12:10:41 +02:00
subprocess.call(['git', 'pull'])
2015-08-20 12:57:45 +02:00
p = subprocess.Popen(['git', 'show', '--format=%h'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
comm = p.communicate()
rev = comm[0]
rev = rev[:rev.find('\n')]
compilecppcheck('-DMAXTIME=600 -DDACA2')
runcppcheck(rev, folder)
2017-06-04 14:09:41 +02:00
runcppcheck(rev, 'lib' + folder)
daca2report(os.path.expanduser('~/daca2-report'))
upload(os.path.expanduser('~/daca2-report'), 'devinfo/')
2015-08-21 15:46:10 +02:00
foldernum = START
2015-08-20 12:57:45 +02:00
while True:
daca2(foldernum)
foldernum = foldernum + 1