def store(test_conf, run_name, file_content): """ Store a new analysis run with multiple reports. """ check_host, check_port = get_check_server_host_port(test_conf) with CCReportHelper(check_host, check_port) as store_server: run_id = store_server.addCheckerRun('command', run_name, 'version', False) store_reports(run_id, file_content, test_conf) store_server.finishCheckerRun(run_id) return run_id
def setUp(self): self._report = CCReportHelper('localhost', int(os.environ['CC_TEST_SERVER_PORT']), '/')
def main(): # handle argument parsing parseArgs() #--- main part ------------------------------------------------------------- reportTimeList = [] getTimeList = [] with CCReportHelper(args.address, args.check_port) as ccReporter, \ CCViewerHelper(args.address, args.view_port, '/') as ccViewer, \ open(args.output, 'r+') as outFile: outFile.truncate() for runCount in range(runNumber): before = datetime.datetime.now() run_id = ccReporter.addCheckerRun('command', 'name_' + str(runCount) + '_' + str(uuid4()), 'version', False) report_ids = [] for fileCount in range(fileNumber): print('\nrun: ' + str(runCount + 1) + '/' + str(runNumber) + '\nfile: ' + str(fileCount + 1) + '/' + str(fileNumber)) file_id = ccReporter.needFileContent(run_id, 'file_' + str(fileCount)).fileId ccReporter.addFileContent(file_id, fileContent) build_action_id = ccReporter.addBuildAction(run_id, 'build_cmd_' + str(fileCount), 'check_cmd_' + str(fileCount), 'target_' + str(fileCount)) ccReporter.finishBuildAction(build_action_id, '') for bugCount in range(bugPerFile): bug_pathes = [] bug_events = [] for bugElementCount in range(bugLength): line = bugCount * bugLength + bugElementCount + 1 bug_pathes.append(BugPathPos(line, 1, line, 10, file_id)) bug_events.append(BugPathEvent(line, 1, line, 10, 'event_msg', file_id)) report_id = ccReporter.addReport(build_action_id, file_id, 'hash_' + str(run_id) + '_' + str(fileCount) + '_' + str(bugCount), 1, 'checker_message', bug_pathes, bug_events, 'checker_name', 'checker_cat', 'bug_type', 1) report_ids.append(report_id) #ccReporter.moduleToReport(run_id, 'module_id', report_ids) ccReporter.finishCheckerRun(run_id) after = datetime.datetime.now() time = (after - before).total_seconds() reportTimeList.append(time) before = datetime.datetime.now() runIDs = [rundata.runId for rundata in ccViewer.getRunData()] after = datetime.datetime.now() time = (after - before).total_seconds() getTimeList.append(time) before = datetime.datetime.now() res = ccViewer.getAllRunResults(runIDs[-1]) after = datetime.datetime.now() time = (after - before).total_seconds() getTimeList.append(time) before = datetime.datetime.now() ccViewer.getReportDetails(res[-1].reportId) after = datetime.datetime.now() time = (after - before).total_seconds() getTimeList.append(time) s = str(runCount) + ';' + str(reportTimeList[-1]) + ';' + str(getTimeList[-3]) + ';' + str(getTimeList[-2]) + ';' + str(getTimeList[-1]) print(s) outFile.write(s + '\n')
def store_reports(run_id, file_content, test_conf): """ Generate and store build actions, reports, file content. """ number_of_files = test_conf.get("number_of_files", 1) bug_per_file = test_conf.get("bug_per_file", 1) bug_length = test_conf.get("bug_length", 1) check_host, check_port = get_check_server_host_port(test_conf) with CCReportHelper(check_host, check_port) as store_server: for file_count in range(number_of_files): ba_id = store_server.addBuildAction(run_id, 'build_cmd_' + str(file_count), 'check_cmd_' + str(file_count), "clangsa", 'target_' + str(file_count) ) file_id = store_server.needFileContent(run_id, 'file_' + str(file_count) ).fileId store_server.addFileContent(file_id, file_content) store_server.finishBuildAction(ba_id, '') for bug_count in range(bug_per_file): bug_paths = [] bug_events = [] for bug_element_count in range(bug_length): line = bug_count * bug_length + bug_element_count + 1 bug_paths.append(BugPathPos(line, # start line 1, # start col line, # end line 10, # end col file_id) # file id ) bug_events.append(BugPathEvent(line, # start line 1, # start col line, # end line 10, # end col 'event_msg', # checker msg file_id) # file id ) bug_hash = 'hash_' + str(run_id) + '_' + str(file_count) + \ '_' + str(bug_count) r_id = store_server.addReport(ba_id, file_id, bug_hash, 'checker_message', bug_paths, bug_events, 'checker_name', 'checker_cat', 'bug_type', Severity.STYLE, False)