From 78ea6d71ac0f88e4fbba582c4d9fd0725af52cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 9 Feb 2019 22:05:12 +0100 Subject: [PATCH] donate-cpu: run cppcheck with --experimental-fast also --- tools/donate-cpu-server.py | 21 +++++++++++++-------- tools/donate-cpu.py | 22 +++++++++++++++++++--- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/tools/donate-cpu-server.py b/tools/donate-cpu-server.py index d4b51c55e..98be41c29 100644 --- a/tools/donate-cpu-server.py +++ b/tools/donate-cpu-server.py @@ -718,9 +718,10 @@ def server(server_address_port, packages, packageIndex, resultPath): print('[' + strDateTime() + '] get:' + pkg) connection.send(pkg) connection.close() - elif cmd.startswith('write\nftp://'): + elif cmd.startswith('write\nftp://') or cmd.startswith('write-fast\nftp://'): + writeFast = cmd.startswith('write-fast') # read data - data = cmd[6:] + data = cmd[cmd.find('ftp'):] try: t = 0 max_data_size = 2 * 1024 * 1024 @@ -753,15 +754,19 @@ def server(server_address_port, packages, packageIndex, resultPath): print('results not written. url is not in packages.') continue print('results added for package ' + res.group(1)) - filename = resultPath + '/' + res.group(1) + if writeFast: + filename = resultPath + '-fast/' + res.group(1) + else: + filename = resultPath + '/' + res.group(1) with open(filename, 'wt') as f: f.write(strDateTime() + '\n' + data) # track latest added results.. - if len(latestResults) >= 20: - latestResults = latestResults[1:] - latestResults.append(filename) - with open('latest.txt', 'wt') as f: - f.write(' '.join(latestResults)) + if not writeFast: + if len(latestResults) >= 20: + latestResults = latestResults[1:] + latestResults.append(filename) + with open('latest.txt', 'wt') as f: + f.write(' '.join(latestResults)) elif cmd.startswith('write_info\nftp://'): # read data data = cmd[11:] diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index 09179dd21..57fa20318 100644 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -224,7 +224,7 @@ def hasInclude(path, includes): return False -def scanPackage(workPath, cppcheckPath, jobs): +def scanPackage(workPath, cppcheckPath, jobs, fast): print('Analyze..') os.chdir(workPath) libraries = ' --library=posix --library=gnu' @@ -247,6 +247,8 @@ def scanPackage(workPath, cppcheckPath, jobs): # Reference for GNU C: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html options = jobs + libraries + ' -D__GNUC__ --check-library --inconclusive --enable=style,information --platform=unix64 --template=daca2 -rp=temp temp' + if fast: + options = '--experimental-fast ' + options cmd = 'nice ' + cppcheckPath + '/cppcheck' + ' ' + options print(cmd) startTime = time.time() @@ -336,7 +338,11 @@ def uploadResults(package, results, server_address): try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(server_address) - sendAll(sock, 'write\n' + package + '\n' + results + '\nDONE') + if results.startswith('FAST'): + cmd = 'write-fast\n' + else: + cmd = 'write\n' + sendAll(sock, cmd + package + '\n' + results + '\nDONE') sock.close() print('Results have been successfully uploaded.') return True @@ -464,7 +470,7 @@ while True: current_cppcheck_dir = 'cppcheck' else: current_cppcheck_dir = ver - c, errout, info, t, cppcheck_options = scanPackage(workpath, current_cppcheck_dir, jobs) + c, errout, info, t, cppcheck_options = scanPackage(workpath, current_cppcheck_dir, jobs, False) if c < 0: crash = True count += ' Crash!' @@ -474,6 +480,16 @@ while True: resultsToDiff.append(errout) if ver == 'head': head_info_msg = info + + # Fast results + fast_c, fast_errout, fast_info, fast_t, fast_cppcheck_options = scanPackage(workpath, current_cppcheck_dir, jobs, True) + if c > 0 and errout and fast_errout: + output = 'FAST\n' + output += 'elapsed-time: %.1f %.1f' % (t, fast_t) + output += '\ndiff:\n' + output += diffResults(workpath, 'head', errout, 'fast', fast_errout) + uploadResults(package, output, server_address) + results_exist = True if len(resultsToDiff[0]) + len(resultsToDiff[1]) == 0: results_exist = False