def setup_package(): """Setup the environment for testing blame information.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('blame') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' test_config = {} project_info = project.get_info(test_project) test_project_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_project_path) project_info['project_path'] = test_project_path test_project_name = project_info['name'] + '_' + uuid.uuid4().hex test_config['test_project'] = project_info suppress_file = None skip_list_file = None test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [], 'clean': True } # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server(auth_required=True) server_access['viewer_product'] = 'blame' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) # Clean the test project, if needed by the tests. ret = project.clean(test_project) if ret: sys.exit(ret) ret = codechecker.check_and_store( codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing test project was succcessful.") # Save the run names in the configuration. codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for testing review_status.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('review_status') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE dir_path = os.path.dirname(os.path.realpath(__file__)) shutil.copytree(os.path.join(dir_path, 'review_status_files'), os.path.join(TEST_WORKSPACE, 'review_status_files')) test_project = 'single_bug' test_config = {} project_info = project.get_info(test_project) test_config['test_project'] = project_info skip_list_file = None test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': None, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } ret = project.clean(test_project, test_env) if ret: sys.exit(ret) # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'review_status' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) test_project_name = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.check_and_store(codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for testing review_status.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('review_status') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'single_bug' test_config = {} project_info = project.get_info(test_project) test_config['test_project'] = project_info skip_list_file = None test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': None, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } ret = project.clean(test_project, test_env) if ret: sys.exit(ret) # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'review_status' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) test_project_name = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for the tests.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('suppress') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'suppress' test_config = {} project_info = project.get_info(test_project) test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path test_config['test_project'] = project_info # Generate a suppress file for the tests. suppress_file = os.path.join(TEST_WORKSPACE, 'suppress_file') if os.path.isfile(suppress_file): os.remove(suppress_file) _generate_suppress_file(suppress_file) test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': None, 'skip_list_file': None, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } ret = project.clean(test_project, test_env) if ret: sys.exit(ret) output_dir = codechecker_cfg['reportdir'] \ if 'reportdir' in codechecker_cfg \ else os.path.join(codechecker_cfg['workspace'], 'reports') codechecker_cfg['reportdir'] = output_dir ret = codechecker.log_and_analyze(codechecker_cfg, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config)
def test_disable_checker(self): """ The test depends on a run which was configured for update mode. Compared to the original test analysis in this run the deadcode.Deadstores checker was disabled. """ run_results = get_all_run_results(self._cc_client, self._runid) print_run_results(run_results) # Get check command for the first storage. original_check_command = \ self._cc_client.getCheckCommand(None, self._runid) # Run the anaysis again with different setup. test_project_path = self._testproject_data['project_path'] ret = project.clean(test_project_path) if ret: sys.exit(ret) initial_codechecker_cfg = env.import_test_cfg( self._test_workspace)['codechecker_cfg'] # Disable some checkers for the analysis. deadcode = 'deadcode.DeadStores' initial_codechecker_cfg['checkers'] = ['-d', deadcode] initial_test_project_name = self._run_name ret = codechecker.check_and_store(initial_codechecker_cfg, initial_test_project_name, test_project_path) if ret: sys.exit(1) # Get the results to compare. updated_results = get_all_run_results(self._cc_client, self._runid) all_bugs = self._testproject_data[self._clang_to_test]['bugs'] deadcode_bugs = \ [bug['hash'] for bug in all_bugs if bug['checker'] == deadcode] self.assertEquals(len(updated_results), len(all_bugs)) self.assertTrue(all(map( lambda b: b.detectionStatus == 'unresolved', filter(lambda x: x in deadcode_bugs, updated_results)))) # Get check command for the updated storage. updated_check_command = \ self._cc_client.getCheckCommand(None, self._runid) # Check that the check command is changed. self.assertNotEqual(original_check_command, updated_check_command) self.assertTrue(deadcode not in original_check_command) self.assertTrue(deadcode in updated_check_command)
def setup_package(): """Setup the environment for testing statistics.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('statistics') # Set the TEST_WORKSPACE used by the tests. os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_config = {} test_project = 'cpp' project_info = project.get_info(test_project) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path test_config['test_project'] = project_info # Suppress file should be set here if needed by the tests. suppress_file = None # Skip list file should be set here if needed by the tests. skip_list_file = None # Get an environment which should be used by the tests. test_env = env.test_env(TEST_WORKSPACE) # Create a basic CodeChecker config for the tests, this should # be imported by the tests and they should only depend on these # configuration options. codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } # Clean the test project, if needed by the tests. ret = project.clean(test_project) if ret: sys.exit(ret) test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def test_remove_run_results(self): """ Test for removing run results and run. """ # Run the anaysis again with different setup. test_project_path = self._testproject_data['project_path'] ret = project.clean(test_project_path) if ret: sys.exit(ret) codechecker.check(self._codechecker_cfg, 'remove_run_results', test_project_path) run_filter = RunFilter(names=['remove_run_results'], exactMatch=True) runs = self._cc_client.getRunData(run_filter) self.assertEqual(len(runs), 1) run_id = runs[0].runId orig_results_count = \ self._cc_client.getRunResultCount([run_id], None, None) self.assertNotEqual(orig_results_count, 0) checker_filter = ReportFilter(checkerName=["core.CallAndMessage"]) res_count = self._cc_client.getRunResultCount([run_id], checker_filter, None) self.assertNotEqual(res_count, 0) self._cc_client.removeRunReports([run_id], checker_filter, None) res_count = self._cc_client.getRunResultCount([run_id], checker_filter, None) self.assertEqual(res_count, 0) # Remove the run. self._cc_client.removeRun(run_id) # Check that we removed all results from the run. res = self._cc_client.getRunResultCount([run_id], None, None) self.assertEqual(res, 0)
def test_disable_checker(self): """ The test depends on a run which was configured for update mode. Compared to the original test analysis in this run the deadcode.Deadstores checker was disabled. """ run_results = get_all_run_results(self._cc_client, self._runid) print_run_results(run_results) # Run the anaysis again with different setup. test_project_path = self._testproject_data['project_path'] ret = project.clean(test_project_path) if ret: sys.exit(ret) initial_codechecker_cfg = env.import_test_cfg( self._test_workspace)['codechecker_cfg'] # Disable some checkers for the analysis. deadcode = 'deadcode.DeadStores' initial_codechecker_cfg['checkers'] = ['-d', deadcode] initial_test_project_name = self._run_name ret = codechecker.check(initial_codechecker_cfg, initial_test_project_name, test_project_path) if ret: sys.exit(1) # Get the results to compare. updated_results = get_all_run_results(self._cc_client, self._runid) all_bugs = self._testproject_data[self._clang_to_test]['bugs'] deadcode_bugs = \ [bug['hash'] for bug in all_bugs if bug['checker'] == deadcode] self.assertEquals(len(updated_results), len(all_bugs)) self.assertTrue(all(map( lambda b: b.detectionStatus == 'unresolved', filter(lambda x: x in deadcode_bugs, updated_results))))
def test_disable_checker(self): """ The test depends on a run which was configured for update mode. Compared to the original test analysis in this run the deadcode.Deadstores checker was disabled. """ run_results = get_all_run_results(self._cc_client, self._runid) print_run_results(run_results) # Run the anaysis again with different setup. test_project_path = self._testproject_data['project_path'] ret = project.clean(test_project_path) if ret: sys.exit(ret) initial_codechecker_cfg = env.import_test_cfg( self._test_workspace)['codechecker_cfg'] # Disable some checkers for the analysis. deadcode = 'deadcode.DeadStores' initial_codechecker_cfg['checkers'] = ['-d', deadcode] initial_test_project_name = self._run_name ret = codechecker.check(initial_codechecker_cfg, initial_test_project_name, test_project_path) if ret: sys.exit(1) # Get the results to compare. updated_results = get_all_run_results(self._cc_client, self._runid) all_bugs = self._testproject_data[self._clang_to_test]['bugs'] deadcode_bugs = [bug for bug in all_bugs if bug['checker'] == deadcode] self.assertEquals(len(updated_results), len(all_bugs) - len(deadcode_bugs))
def setup_package(): """ Setup the environment for the tests. Check the test project twice, then start the server. """ global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('diff') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' test_project_path = project.path(test_project) pg_db_config = env.get_postgresql_cfg() test_config = {} project_info = project.get_info(test_project) test_config['test_project'] = project_info suppress_file = None skip_list_file = None # Setup environment variabled for test cases. host_port_cfg = env.get_host_port_cfg() test_env = env.test_env() codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'reportdir': os.path.join(TEST_WORKSPACE, 'reports'), 'pg_db_config': pg_db_config, 'checkers': ['-d', 'core.CallAndMessage', '-e', 'core.StackAddressEscape'] } codechecker_cfg.update(host_port_cfg) test_config['codechecker_cfg'] = codechecker_cfg ret = project.clean(test_project, test_env) if ret: sys.exit(ret) # Start the CodeChecker server. print("Starting server to get results") _start_server(codechecker_cfg, test_config, False) test_project_name_base = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name_base, test_project_path) if ret: sys.exit(1) print("First analysis of the test project was successful.") ret = project.clean(test_project, test_env) if ret: sys.exit(ret) test_project_name_new = project_info['name'] + '_' + uuid.uuid4().hex # Let's run the second analysis with different # checkers to have some real difference. codechecker_cfg['checkers'] = [ '-e', 'core.CallAndMessage', '-d', 'core.StackAddressEscape' ] ret = codechecker.check(codechecker_cfg, test_project_name_new, test_project_path) if ret: sys.exit(1) print("Second analysis of the test project was successful.") # Run the second analysis results # into a report directory ret = codechecker.analyze(codechecker_cfg, test_project_name_new, test_project_path) if ret: sys.exit(1) print("CodeChecker analyze of test project was successful.") if pg_db_config: print("Waiting for PotgreSQL to stop.") codechecker.wait_for_postgres_shutdown(TEST_WORKSPACE) # Order of the test run names matter at comparison! codechecker_cfg['run_names'] = [ test_project_name_base, test_project_name_new ] test_config['codechecker_cfg'] = codechecker_cfg # Export test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for testing products.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('producttest') # Set the TEST_WORKSPACE used by the tests. os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_config = {} test_project = 'single_bug' project_info = project.get_info(test_project) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path # Generate a unique name for this test run. test_project_name = project_info['name'] + '_' + uuid.uuid4().hex test_config['test_project'] = project_info # Get an environment which should be used by the tests. test_env = env.test_env(TEST_WORKSPACE) # Create a basic CodeChecker config for the tests, this should # be imported by the tests and they should only depend on these # configuration options. codechecker_cfg = { 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server(auth_required=True) server_access['viewer_product'] = 'producttest' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) # Clean the test project, if needed by the tests. ret = project.clean(test_project) if ret: sys.exit(ret) # Check the test project, if needed by the tests. ret = codechecker.check_and_store(codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") # Save the run names in the configuration. codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """ Setup the environment for the tests. Check the test project twice. """ global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('diff') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' test_project_path = project.path(test_project) test_project_path_altered = os.path.join(TEST_WORKSPACE, "cpp_copy") # We create a copy of the test project which we will change # to simulate code editing. dir_util.copy_tree(test_project_path, test_project_path_altered) test_config = {} project_info = project.get_info(test_project) test_config['test_project'] = project_info suppress_file = None skip_list_file = None test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'force': True, 'workspace': TEST_WORKSPACE, 'reportdir': os.path.join(TEST_WORKSPACE, 'reports'), 'checkers': ['-d', 'core.CallAndMessage', '-e', 'core.StackAddressEscape'] } test_config['codechecker_cfg'] = codechecker_cfg ret = project.clean(test_project, test_env) if ret: sys.exit(ret) # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'diff' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) test_project_name_base = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name_base, test_project_path) if ret: sys.exit(1) print("First analysis of the test project was successful.") ret = project.clean(test_project, test_env) if ret: sys.exit(ret) test_project_name_new = project_info['name'] + '_' + uuid.uuid4().hex # Let's run the second analysis with different # checkers to have some real difference. codechecker_cfg['checkers'] = [ '-e', 'core.CallAndMessage', '-d', 'core.StackAddressEscape' ] ret = codechecker.check(codechecker_cfg, test_project_name_new, test_project_path_altered) if ret: sys.exit(1) print("Second analysis of the test project was successful.") # Insert a real suppression into the code altered_file = os.path.join(test_project_path_altered, "call_and_message.cpp") insert_suppression(altered_file) # Run the second analysis results # into a report directory ret = codechecker.analyze(codechecker_cfg, test_project_name_new, test_project_path_altered) if ret: sys.exit(1) print("CodeChecker analyze of test project was successful.") test_project_name_update = project_info['name'] + '_' + uuid.uuid4().hex codechecker_cfg['tag'] = 't1' codechecker_cfg['checkers'] = [ '-d', 'core.CallAndMessage', '-e', 'core.StackAddressEscape' ] codechecker_cfg['reportdir'] = os.path.join(TEST_WORKSPACE, 'reports2') ret = codechecker.check(codechecker_cfg, test_project_name_update, test_project_path) if ret: sys.exit(1) print("Third analysis of the test project was successful.") codechecker_cfg['tag'] = 't2' codechecker_cfg['checkers'] = [ '-e', 'core.CallAndMessage', '-d', 'core.StackAddressEscape' ] ret = codechecker.check(codechecker_cfg, test_project_name_update, test_project_path) if ret: sys.exit(1) print("Fourth analysis of the test project was successful.") codechecker_cfg['tag'] = 't3' ret = codechecker.check(codechecker_cfg, test_project_name_update, test_project_path) if ret: sys.exit(1) print("Fifth analysis of the test project was successful.") # Order of the test run names matter at comparison! codechecker_cfg['run_names'] = [ test_project_name_base, test_project_name_new, test_project_name_update ] test_config['codechecker_cfg'] = codechecker_cfg # Export test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for the tests.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('cmdline') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' test_config = {} project_info = project.get_info(test_project) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path test_config['test_project'] = project_info suppress_file = None skip_list_file = None test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } ret = project.clean(test_project) if ret: sys.exit(ret) # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'cmdline' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) # Generate a unique name for this test run. test_project_name_1 = project_info['name'] + '1_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name_1, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") test_project_name_2 = project_info['name'] + '2_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name_2, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") codechecker_cfg['run_names'] = [test_project_name_1, test_project_name_2] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for the tests.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('report_viewer_api') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' test_config = {} project_info = project.get_info(test_project) test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path test_config['test_project'] = project_info suppress_file = None skip_list_file = None tag = 'v1.0' test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [], 'tag': tag } ret = project.clean(test_project) if ret: sys.exit(ret) # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'report_viewer_api' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) test_project_name = project_info['name'] + '_' + uuid.uuid4().hex + '**' ret = codechecker.check(codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") test_project_name_new = project_info['name'] + '*' + uuid.uuid4().hex + '%' # Let's run the second analysis with different # checkers to have some real difference. codechecker_cfg['checkers'] = [ '-e', 'core.CallAndMessage', '-d', 'core.StackAddressEscape', '-d', 'unix.Malloc' ] codechecker_cfg['tag'] = None ret = codechecker.check(codechecker_cfg, test_project_name_new, project.path(test_project)) if ret: sys.exit(1) print("Second analysis of the test project was successful.") codechecker_cfg['run_names'] = [test_project_name, test_project_name_new] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for testing products.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('producttest') # Set the TEST_WORKSPACE used by the tests. os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_config = {} test_project = 'single_bug' project_info = project.get_info(test_project) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path # Generate a unique name for this test run. test_project_name = project_info['name'] + '_' + uuid.uuid4().hex test_config['test_project'] = project_info # Get an environment which should be used by the tests. test_env = env.test_env(TEST_WORKSPACE) # Create a basic CodeChecker config for the tests, this should # be imported by the tests and they should only depend on these # configuration options. codechecker_cfg = { 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'producttest' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) # Clean the test project, if needed by the tests. ret = project.clean(test_project) if ret: sys.exit(ret) # Check the test project, if needed by the tests. ret = codechecker.check(codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") # Save the run names in the configuration. codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for testing $TEST_NAME$.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('$TEST_NAME$') # Set the TEST_WORKSPACE used by the tests. os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE # Get the clang version which is used for testing. # Important because different clang releases might # find different errors. clang_version = env.clang_to_test() # PostgreSQL configuration might be empty if tests are run # with SQLite. pg_db_config = env.get_postgresql_cfg() test_config = {} project_info = project.get_info(project.path()) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(), test_proj_path) project_info['project_path'] = test_proj_path # Generate a unique name for this test run. test_project_name = project_info['name'] + '_' + uuid.uuid4().hex test_config['test_project'] = project_info # Suppress file should be set here if needed by the tests. suppress_file = None # Skip list file should be set here if needed by the tests. skip_list_file = None # Get an environment which should be used by the tests. test_env = env.test_env() # Create a basic CodeChecker config for the tests, this should # be imported by the tests and they should only depend on these # configuration options. codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'pg_db_config': pg_db_config, 'checkers': [] } # Get new unique port numbers for this test run. host_port_cfg = env.get_host_port_cfg() # Extend the checker configuration with the port numbers. codechecker_cfg.update(host_port_cfg) # Clean the test project, if needed by the tests. ret = project.clean(project.path()) if ret: sys.exit(ret) # Check the test project, if needed by the tests. ret = codechecker.check(codechecker_cfg, test_project_name, project.path()) if ret: sys.exit(1) print("Analyzing the test project was successful.") if pg_db_config: print("Waiting for PostgreSQL to stop.") codechecker.wait_for_postgres_shutdown(TEST_WORKSPACE) # Save the run names in the configuration. codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config) # Start the CodeChecker server. print("Starting server to get results") _start_server(codechecker_cfg, test_config, False)
def setup_package(): """Setup the environment for the tests.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('cmdline') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' test_config = {} project_info = project.get_info(test_project) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path test_config['test_project'] = project_info suppress_file = None skip_list_file = None test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [], 'description': "Runs for command line test." } ret = project.clean(test_project) if ret: sys.exit(ret) # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'cmdline' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) # Generate a unique name for this test run. test_project_name_1 = project_info['name'] + '1_' + uuid.uuid4().hex ret = codechecker.check_and_store(codechecker_cfg, test_project_name_1, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") test_project_name_2 = project_info['name'] + '2_' + uuid.uuid4().hex ret = codechecker.check_and_store(codechecker_cfg, test_project_name_2, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") codechecker_cfg['run_names'] = [test_project_name_1, test_project_name_2] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for the tests. """ global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('update') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project_path = project.path() clang_version = env.clang_to_test() pg_db_config = env.get_postgresql_cfg() test_config = {} project_info = project.get_info(project.path()) test_project_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(), test_project_path) project_info['project_path'] = test_project_path test_project_name = project_info['name'] + '_' + uuid.uuid4().hex test_config['test_project'] = project_info suppress_file = None skip_list_file = None # Get port numbers for the tests. host_port_cfg = env.get_host_port_cfg() test_env = env.test_env() codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'pg_db_config': pg_db_config, 'checkers': [] } codechecker_cfg.update(host_port_cfg) ret = project.clean(test_project_path, test_env) if ret: sys.exit(ret) ret = codechecker.check(codechecker_cfg, test_project_name, test_project_path) if ret: sys.exit(1) print("Analyzing test project was succcessful.") if pg_db_config: print("Waiting for PotgreSQL to stop.") codechecker.wait_for_postgres_shutdown(TEST_WORKSPACE) codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config) # Start the CodeChecker server. print("Starting server to get results") _start_server(codechecker_cfg, test_config, False)
def setup_package(): """ Setup the environment for the tests. Check the test project twice, then start the server. """ global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('diff') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project_path = project.path() clang_version = env.clang_to_test() pg_db_config = env.get_postgresql_cfg() test_config = {} project_info = project.get_info(project.path()) test_config['test_project'] = project_info suppress_file = None skip_list_file = None # Setup environment variabled for test cases. host_port_cfg = env.get_host_port_cfg() test_env = env.test_env() codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'pg_db_config': pg_db_config, 'checkers': [] } codechecker_cfg.update(host_port_cfg) test_config['codechecker_cfg'] = codechecker_cfg ret = project.clean(test_project_path, test_env) if ret: sys.exit(ret) test_project_name_base = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name_base, test_project_path) if ret: sys.exit(1) print("First analysis of the test project was successful.") if pg_db_config: print("Waiting for PotgreSQL to stop.") codechecker.wait_for_postgres_shutdown(TEST_WORKSPACE) ret = project.clean(test_project_path, test_env) if ret: sys.exit(ret) test_project_name_new = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name_new, test_project_path) if ret: sys.exit(1) print("Second analysis of the test project was successful.") if pg_db_config: print("Waiting for PotgreSQL to stop.") codechecker.wait_for_postgres_shutdown(TEST_WORKSPACE) # Order of the test run names matter at comparison! codechecker_cfg['run_names'] = [ test_project_name_base, test_project_name_new ] test_config['codechecker_cfg'] = codechecker_cfg # Export test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config) # Start the CodeChecker server. print("Starting server to get results") _start_server(codechecker_cfg, test_config, False)
def setup_package(): """Setup the environment for the tests.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('suppress') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'suppress' test_config = {} project_info = project.get_info(test_project) test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path test_config['test_project'] = project_info # Generate a suppress file for the tests. suppress_file = os.path.join(TEST_WORKSPACE, 'suppress_file') if os.path.isfile(suppress_file): os.remove(suppress_file) _generate_suppress_file(suppress_file) test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': None, 'skip_list_file': None, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } ret = project.clean(test_project, test_env) if ret: sys.exit(ret) # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'suppress' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) test_project_name = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """ Setup the environment for the tests. Check the test project twice. """ global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('diff') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' test_project_path = project.path(test_project) test_project_path_altered = os.path.join(TEST_WORKSPACE, "cpp_copy") # We create a copy of the test project which we will change # to simulate code editing. dir_util.copy_tree(test_project_path, test_project_path_altered) test_config = {} project_info = project.get_info(test_project) test_config['test_project'] = project_info suppress_file = None skip_list_file = None test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'force': True, 'workspace': TEST_WORKSPACE, 'reportdir': os.path.join(TEST_WORKSPACE, 'reports'), 'checkers': ['-d', 'core.CallAndMessage', '-e', 'core.StackAddressEscape'] } test_config['codechecker_cfg'] = codechecker_cfg ret = project.clean(test_project, test_env) if ret: sys.exit(ret) # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'diff' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) test_project_name_base = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name_base, test_project_path) if ret: sys.exit(1) print("First analysis of the test project was successful.") dir_util.copy_tree(codechecker_cfg['reportdir'], os.path.join(TEST_WORKSPACE, 'reports_baseline')) ret = project.clean(test_project, test_env) if ret: sys.exit(ret) test_project_name_new = project_info['name'] + '_' + uuid.uuid4().hex # Let's run the second analysis with different # checkers to have some real difference. codechecker_cfg['checkers'] = ['-e', 'core.CallAndMessage', '-d', 'core.StackAddressEscape' ] ret = codechecker.check(codechecker_cfg, test_project_name_new, test_project_path_altered) if ret: sys.exit(1) print("Second analysis of the test project was successful.") # Insert a real suppression into the code altered_file = os.path.join(test_project_path_altered, "call_and_message.cpp") insert_suppression(altered_file) test_project_name_update = project_info['name'] + '_' + uuid.uuid4().hex codechecker_cfg['tag'] = 't1' codechecker_cfg['checkers'] = ['-d', 'core.CallAndMessage', '-e', 'core.StackAddressEscape' ] codechecker_cfg['reportdir'] = os.path.join(TEST_WORKSPACE, 'reports2') ret = codechecker.check(codechecker_cfg, test_project_name_update, test_project_path) if ret: sys.exit(1) print("Third analysis of the test project was successful.") codechecker_cfg['tag'] = 't2' codechecker_cfg['checkers'] = ['-e', 'core.CallAndMessage', '-d', 'core.StackAddressEscape' ] ret = codechecker.check(codechecker_cfg, test_project_name_update, test_project_path) if ret: sys.exit(1) print("Fourth analysis of the test project was successful.") codechecker_cfg['tag'] = 't3' ret = codechecker.check(codechecker_cfg, test_project_name_update, test_project_path) if ret: sys.exit(1) print("Fifth analysis of the test project was successful.") # Order of the test run names matter at comparison! codechecker_cfg['run_names'] = [test_project_name_base, test_project_name_new, test_project_name_update] test_config['codechecker_cfg'] = codechecker_cfg # Export test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for the tests. Check the test project twice, then start the server.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('skip') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' pg_db_config = env.get_postgresql_cfg() test_config = {} project_info = project.get_info(test_project) test_config['test_project'] = project_info suppress_file = None # Generate skip list file for the tests. skip_list_file = os.path.join(TEST_WORKSPACE, 'skip_file') if os.path.isfile(skip_list_file): os.remove(skip_list_file) _generate_skip_list_file(skip_list_file) # Get port numbers for the tests. host_port_cfg = env.get_host_port_cfg() test_env = env.test_env() codechecker_cfg = { 'suppress_file': suppress_file, 'skip_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'pg_db_config': pg_db_config, 'checkers': [] } codechecker_cfg.update(host_port_cfg) ret = project.clean(test_project, test_env) if ret: sys.exit(ret) test_project_name = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") if pg_db_config: print("Waiting for PostgreSQL to stop.") codechecker.wait_for_postgres_shutdown(TEST_WORKSPACE) codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config) # Start the CodeChecker server. print("Starting server to get results.") _start_server(codechecker_cfg, test_config, False)
def setup_package(): """Setup the environment for the tests. Then start the server.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('report_viewer_api') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' pg_db_config = env.get_postgresql_cfg() test_config = {} project_info = project.get_info(test_project) test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path test_config['test_project'] = project_info suppress_file = None skip_list_file = None # Get port numbers for the tests. host_port_cfg = env.get_host_port_cfg() test_env = env.test_env() codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'pg_db_config': pg_db_config, 'checkers': [] } codechecker_cfg.update(host_port_cfg) ret = project.clean(test_project) if ret: sys.exit(ret) print("Starting server to get results.") _start_server(codechecker_cfg, test_config, False) test_project_name = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.check(codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for testing components.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('component') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' test_config = {} project_info = project.get_info(test_project) test_project_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_project_path) project_info['project_path'] = test_project_path test_project_name = project_info['name'] + '_' + uuid.uuid4().hex test_config['test_project'] = project_info suppress_file = None skip_list_file = None test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'component' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) # Clean the test project, if needed by the tests. ret = project.clean(test_project) if ret: sys.exit(ret) ret = codechecker.check(codechecker_cfg, test_project_name, test_project_path) if ret: sys.exit(1) print("Analyzing test project was succcessful.") # Save the run names in the configuration. codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for testing $TEST_NAME$.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('$TEST_NAME$') # Set the TEST_WORKSPACE used by the tests. os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE # Get the clang version which is used for testing. # Important because different clang releases might # find different errors. clang_version = env.clang_to_test() test_config = {} test_project = 'cpp' project_info = project.get_info(test_project) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path # Generate a unique name for this test run. test_project_name = project_info['name'] + '_' + uuid.uuid4().hex test_config['test_project'] = project_info # Suppress file should be set here if needed by the tests. suppress_file = None # Skip list file should be set here if needed by the tests. skip_list_file = None # Get an environment which should be used by the tests. test_env = env.test_env(TEST_WORKSPACE) # Create a basic CodeChecker config for the tests, this should # be imported by the tests and they should only depend on these # configuration options. codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = '$TEST_NAME$' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) # Clean the test project, if needed by the tests. ret = project.clean(test_project) if ret: sys.exit(ret) # Check the test project, if needed by the tests. ret = codechecker.check_and_store(codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") # Save the run names in the configuration. codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for the tests.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('skip') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' test_config = {} project_info = project.get_info(test_project) test_config['test_project'] = project_info suppress_file = None # Generate skip list file for the tests. skip_list_file = os.path.join(TEST_WORKSPACE, 'skip_file') if os.path.isfile(skip_list_file): os.remove(skip_list_file) _generate_skip_list_file(skip_list_file) test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': suppress_file, 'skip_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } ret = project.clean(test_project, test_env) if ret: sys.exit(ret) # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'skip' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) test_project_name = project_info['name'] + '_' + uuid.uuid4().hex skip_file = codechecker_cfg.pop('skip_file') output_dir = codechecker_cfg['reportdir'] \ if 'reportdir' in codechecker_cfg \ else os.path.join(codechecker_cfg['workspace'], 'reports') codechecker_cfg['reportdir'] = output_dir # Analyze without skip. ret = codechecker.log_and_analyze(codechecker_cfg, project.path(test_project)) if ret: print("Analyzing the test project without a skip file failed.") sys.exit(1) codechecker_cfg['skip_file'] = skip_file # Analyze with skip. ret = codechecker.log_and_analyze(codechecker_cfg, project.path(test_project)) if ret: print("Analyzing the test project with a skip file failed.") sys.exit(1) ret = codechecker.store(codechecker_cfg, test_project_name) if ret: print("Storing the results failed.") sys.exit(1) codechecker_cfg['run_names'] = [test_project_name] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for testing delete_runs.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('delete_runs') # Set the TEST_WORKSPACE used by the tests. os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_config = {} test_project = 'simple' project_info = project.get_info(test_project) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path # Generate a unique name for this test run. test_project_name = project_info['name'] test_config['test_project'] = project_info # Suppress file should be set here if needed by the tests. suppress_file = None # Skip list file should be set here if needed by the tests. skip_list_file = None # Get an environment which should be used by the tests. test_env = env.test_env(TEST_WORKSPACE) # Create a basic CodeChecker config for the tests, this should # be imported by the tests and they should only depend on these # configuration options. codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'delete_runs' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) for i in range(0, 5): # Clean the test project, if needed by the tests. ret = project.clean(test_project) if ret: sys.exit(ret) # Check the test project, if needed by the tests. ret = codechecker.check(codechecker_cfg, test_project_name + '_' + str(i), test_proj_path) if ret: sys.exit(1) print("Analyzing the test project was successful {}.".format(str(i))) # If the check process is very fast, datetime of multiple runs can be # almost the same different in microseconds. Test cases of delete runs # can be failed for this reason because we didn't process microseconds # in command line arguments. time.sleep(1) # Save the run names in the configuration. codechecker_cfg['run_names'] \ = [test_project_name + '_' + str(i) for i in range(0, 5)] test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for testing delete_runs.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('delete_runs') # Set the TEST_WORKSPACE used by the tests. os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_config = {} test_project = 'simple' project_info = project.get_info(test_project) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path # Generate a unique name for this test run. test_project_name = project_info['name'] test_config['test_project'] = project_info # Suppress file should be set here if needed by the tests. suppress_file = None # Skip list file should be set here if needed by the tests. skip_list_file = None # Get an environment which should be used by the tests. test_env = env.test_env(TEST_WORKSPACE) # Create a basic CodeChecker config for the tests, this should # be imported by the tests and they should only depend on these # configuration options. codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [] } # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'delete_runs' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) for i in range(0, 5): # Clean the test project, if needed by the tests. ret = project.clean(test_project) if ret: sys.exit(ret) # Check the test project, if needed by the tests. ret = codechecker.check_and_store(codechecker_cfg, test_project_name + '_' + str(i), test_proj_path) if ret: sys.exit(1) print("Analyzing the test project was successful {}.".format(str(i))) # If the check process is very fast, datetime of multiple runs can be # almost the same different in microseconds. Test cases of delete runs # can be failed for this reason because we didn't process microseconds # in command line arguments. time.sleep(1) # Save the run names in the configuration. codechecker_cfg['run_names'] \ = [test_project_name + '_' + str(i) for i in range(0, 5)] test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for testing delete_runs.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('delete_runs') # Set the TEST_WORKSPACE used by the tests. os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE # PostgreSQL configuration might be empty if tests are run # with SQLite. pg_db_config = env.get_postgresql_cfg() test_config = {} test_project = 'simple' project_info = project.get_info(test_project) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path # Generate a unique name for this test run. test_project_name = project_info['name'] test_config['test_project'] = project_info # Suppress file should be set here if needed by the tests. suppress_file = None # Skip list file should be set here if needed by the tests. skip_list_file = None # Get an environment which should be used by the tests. test_env = env.test_env() # Create a basic CodeChecker config for the tests, this should # be imported by the tests and they should only depend on these # configuration options. codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'pg_db_config': pg_db_config, 'checkers': [] } # Get new unique port numbers for this test run. host_port_cfg = env.get_host_port_cfg() # Extend the checker configuration with the port numbers. codechecker_cfg.update(host_port_cfg) # Start the CodeChecker server. print("Starting server to get results") _start_server(codechecker_cfg, test_config, False) for i in range(0, 5): # Clean the test project, if needed by the tests. ret = project.clean(test_project) if ret: sys.exit(ret) # Check the test project, if needed by the tests. ret = codechecker.check(codechecker_cfg, test_project_name + '_' + str(i), test_proj_path) if ret: sys.exit(1) print("Analyzing the test project was successful {}.".format(str(i))) # If the check process is very fast, datetime of multiple runs can be # almost the same different in microseconds. Test cases of delete runs # can be failed for this reason because we didn't process microseconds # in command line arguments. time.sleep(1) # Save the run names in the configuration. codechecker_cfg['run_names'] \ = [test_project_name + '_' + str(i) for i in range(0, 5)] test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setup_package(): """Setup the environment for the tests.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('report_viewer_api') os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE test_project = 'cpp' test_config = {} project_info = project.get_info(test_project) test_proj_path = os.path.join(TEST_WORKSPACE, "test_proj") shutil.copytree(project.path(test_project), test_proj_path) project_info['project_path'] = test_proj_path test_config['test_project'] = project_info suppress_file = None skip_list_file = None tag = 'v1.0' test_env = env.test_env(TEST_WORKSPACE) codechecker_cfg = { 'suppress_file': suppress_file, 'skip_list_file': skip_list_file, 'check_env': test_env, 'workspace': TEST_WORKSPACE, 'checkers': [], 'tag': tag } ret = project.clean(test_project) if ret: sys.exit(ret) # Start or connect to the running CodeChecker server and get connection # details. print("This test uses a CodeChecker server... connecting...") server_access = codechecker.start_or_get_server() server_access['viewer_product'] = 'report_viewer_api' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) test_project_name = project_info['name'] + '_' + uuid.uuid4().hex + '**' ret = codechecker.check(codechecker_cfg, test_project_name, project.path(test_project)) if ret: sys.exit(1) print("Analyzing the test project was successful.") test_project_name_new = project_info['name'] + '*' + uuid.uuid4().hex + '%' # Let's run the second analysis with different # checkers to have some real difference. codechecker_cfg['checkers'] = ['-e', 'core.CallAndMessage', '-d', 'core.StackAddressEscape', '-d', 'unix.Malloc' ] codechecker_cfg['tag'] = None ret = codechecker.check(codechecker_cfg, test_project_name_new, project.path(test_project)) if ret: sys.exit(1) print("Second analysis of the test project was successful.") test_project_name_third = project_info['name'] + uuid.uuid4().hex # Let's run the third analysis. ret = codechecker.check(codechecker_cfg, test_project_name_third, project.path(test_project)) if ret: sys.exit(1) print("Third analysis of the test project was successful.") codechecker_cfg['run_names'] = [test_project_name, test_project_name_new] test_config['codechecker_cfg'] = codechecker_cfg env.export_test_cfg(TEST_WORKSPACE, test_config)