def setUp(self): test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) test_cfg = env.import_test_cfg(test_workspace) # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) self._cc_client = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test. run_names = env.get_run_names(test_workspace) runs = self._cc_client.getRunData() test_runs = [run for run in runs if run.name in run_names] self.assertEqual(len(test_runs), 1, "There should be only one run for this test.") self._runid = test_runs[0].runId
def setUp(self): """ Not much setup is needed. Runs and results are automatically generated. """ test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) self._report = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._report) # Store runs to check. self._codechecker_cfg = env.import_codechecker_cfg(test_workspace) source_dir = os.path.join(os.path.dirname(__file__), 'test_files') self._test_dir = os.path.join(test_workspace, 'test_files') shutil.copytree(source_dir, self._test_dir) _replace_path(os.path.join(self._test_dir, 'run.plist'), self._test_dir) self._codechecker_cfg['reportdir'] = self._test_dir codechecker.store(self._codechecker_cfg, 'test_hash_clash_' + uuid4().hex)
def setUp(self): test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) self._codechecker_cfg = env.import_codechecker_cfg(test_workspace) self._test_dir = os.path.join(test_workspace, 'test_files') # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) self._cc_client = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test. run_names = env.get_run_names(test_workspace) runs = self._cc_client.getRunData(None) test_runs = [run for run in runs if run.name in run_names] self._runid = test_runs[0].runId
def setUp(self): test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) self._cc_client = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test. run_names = env.get_run_names(test_workspace) runs = self._cc_client.getRunData() test_runs = [run for run in runs if run.name in run_names] for r in test_runs: print(r) # There should be at least two runs for this test. self.assertIsNotNone(runs) self.assertNotEqual(len(runs), 0) self.assertGreaterEqual(len(runs), 2) # Name order matters from __init__ ! self._base_runid = test_runs[0].runId # base self._new_runid = test_runs[1].runId # new
def setUp(self): test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) self._cc_client = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test. run_names = env.get_run_names(test_workspace) sort_mode = RunSortMode(RunSortType.DATE, Order.ASC) runs = self._cc_client.getRunData(None, None, 0, sort_mode) test_runs = [run for run in runs if run.name in run_names] self._runid = test_runs[0].runId self._project_info = env.setup_test_proj_cfg(test_workspace)
def setUp(self): test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) self._codechecker_cfg = env.import_codechecker_cfg(test_workspace) self._test_dir = os.path.join(test_workspace, 'test_files') # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) self._cc_client = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test. run_names = env.get_run_names(test_workspace) runs = self._cc_client.getRunData(None) test_runs = [run for run in runs if run.name in run_names] self._runid = test_runs[0].runId
def setUp(self): self._test_workspace = os.environ.get('TEST_WORKSPACE') test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self._test_workspace) self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(self._test_workspace) self.assertIsNotNone(self._testproject_data) self._cc_client = env.setup_viewer_client(self._test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test run_names = env.get_run_names(self._test_workspace) runs = self._cc_client.getRunData(None, None, 0, None) test_runs = [run for run in runs if run.name in run_names] self.assertEqual(len(test_runs), 1, 'There should be only one run for this test.') self._runid = test_runs[0].runId self._run_name = test_runs[0].name
def setUp(self): self._test_workspace = os.environ.get('TEST_WORKSPACE') test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self._test_workspace) self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(self._test_workspace) self.assertIsNotNone(self._testproject_data) self._cc_client = env.setup_viewer_client(self._test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test run_names = env.get_run_names(self._test_workspace) runs = self._cc_client.getRunData(None) test_runs = [run for run in runs if run.name in run_names] self.assertEqual(len(test_runs), 1, 'There should be only one run for this test.') self._runid = test_runs[0].runId self._run_name = test_runs[0].name
def setUp(self): # TEST_WORKSPACE is automatically set by test package __init__.py test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() # Get the test configuration from the prepared test workspace. self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) # Setup a viewer client to test viewer API calls. self._cc_client = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test. run_names = env.get_run_names(test_workspace) runs = self._cc_client.getRunData(None) test_runs = [run for run in runs if run.name in run_names] self.assertEqual(len(test_runs), 1, "There should be only one run for this test.") self._runid = test_runs[0].runId
def setUp(self): self._test_workspace = os.environ.get('TEST_WORKSPACE') test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self._test_workspace) self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(self._test_workspace) self.assertIsNotNone(self._testproject_data) # Get the test configuration from the prepared int the test workspace. self.test_cfg = env.import_test_cfg(self._test_workspace) self._product_name = self.test_cfg['codechecker_cfg']['viewer_product'] pr_client = env.setup_product_client(self._test_workspace, product=self._product_name) product_id = pr_client.getCurrentProduct().id # Setup an authentication client for creating sessions. self._auth_client = env.setup_auth_client(self._test_workspace, session_token='_PROHIBIT') # Create an PRODUCT_ADMIN login. admin_token = self._auth_client.performLogin("Username:Password", "admin:admin123") extra_params = '{"productID":' + str(product_id) + '}' ret = self._auth_client.addPermission(Permission.PRODUCT_ADMIN, "admin", False, extra_params) self.assertTrue(ret) self._cc_client = env.setup_viewer_client(self._test_workspace, session_token=admin_token) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test run_names = env.get_run_names(self._test_workspace) runs = self._cc_client.getRunData(None) test_runs = [run for run in runs if run.name in run_names] self.assertEqual(len(test_runs), 1, 'There should be only one run for this test.') self._runid = test_runs[0].runId self._run_name = test_runs[0].name self._component_name = 'dummy_component' self._component_value = '\n'.join( ['+*/divide_zero.cpp', '-*/new_delete.cpp']) self._component_description = "Test component"
def setup_package(): """Setup the environment for the tests then start the server.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('authentication') 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 varaibled for the 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) codechecker_cfg['run_names'] = [] test_config['codechecker_cfg'] = codechecker_cfg # Export configuration for the tests. env.export_test_cfg(TEST_WORKSPACE, test_config) # Enable authentication and start the CodeChecker server. enable_auth(TEST_WORKSPACE) print("Starting server to get results") _start_server(codechecker_cfg, test_config, False)
def setUp(self): # TEST_WORKSPACE is automatically set by test package __init__.py . self.test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self.test_workspace) # Get the test configuration from the prepared int the test workspace. self.test_cfg = env.import_test_cfg(self.test_workspace) # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() # Get the test project configuration from the prepared test workspace. self._testproject_data = env.setup_test_proj_cfg(self.test_workspace) self.assertIsNotNone(self._testproject_data) # Setup a viewer client to test viewer API calls. self._cc_client = env.setup_viewer_client(self.test_workspace) self.assertIsNotNone(self._cc_client) # Get the CodeChecker cmd if needed for the tests. self._codechecker_cmd = env.codechecker_cmd() # Get the run names which belong to this test. # Name order matters from __init__ ! run_names = env.get_run_names(self.test_workspace) sort_mode = RunSortMode(RunSortType.DATE, Order.ASC) runs = self._cc_client.getRunData(None, None, 0, sort_mode) self._test_runs = [run for run in runs if run.name in run_names] # There should be at least two runs for this test. self.assertIsNotNone(runs) self.assertNotEqual(len(runs), 0) self.assertGreaterEqual(len(runs), 2) # Name order matters from __init__ ! self._base_runid = self._test_runs[0].runId self._new_runid = self._test_runs[1].runId self._update_runid = self._test_runs[2].runId self._url = env.parts_to_url(self.test_cfg['codechecker_cfg']) self._env = self.test_cfg['codechecker_cfg']['check_env']
def setUp(self): test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) self._cc_client = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test. run_names = env.get_run_names(test_workspace) runs = self._cc_client.getRunData(None) test_runs = [run for run in runs if run.name in run_names] for r in test_runs: print(r) # There should be at least two runs for this test. self.assertIsNotNone(runs) self.assertNotEqual(len(runs), 0) self.assertGreaterEqual(len(runs), 2) # Name order matters from __init__ ! self._base_runid = test_runs[0].runId # base self._new_runid = test_runs[1].runId # new self._update_runid = test_runs[2].runId # updated self._codechecker_cmd = env.codechecker_cmd() self._report_dir = os.path.join(test_workspace, "reports") self._report_dir_baseline = os.path.join(test_workspace, "reports_baseline") self._test_config = env.import_test_cfg(test_workspace) self._run_names = env.get_run_names(test_workspace) self._html_reports = os.path.join(test_workspace, "html_reports") self._url = env.parts_to_url(self._test_config['codechecker_cfg'])
def setUp(self): test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) self._cc_client = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test. run_names = env.get_run_names(test_workspace) runs = self._cc_client.getRunData(None) test_runs = [run for run in runs if run.name in run_names] for r in test_runs: print(r) # There should be at least two runs for this test. self.assertIsNotNone(runs) self.assertNotEqual(len(runs), 0) self.assertGreaterEqual(len(runs), 2) # Name order matters from __init__ ! self._base_runid = test_runs[0].runId # base self._new_runid = test_runs[1].runId # new self._update_runid = test_runs[2].runId # updated self._codechecker_cmd = env.codechecker_cmd() self._report_dir = os.path.join(test_workspace, "reports") self._report_dir_baseline = os.path.join(test_workspace, "reports_baseline") self._test_config = env.import_test_cfg(test_workspace) self._run_names = env.get_run_names(test_workspace) self._html_reports = os.path.join(test_workspace, "html_reports") self._url = env.parts_to_url(self._test_config['codechecker_cfg'])
def setUp(self): """ Not much setup is needed. Runs and results are automatically generated. """ test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) self._report = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._report)
def setUp(self): self._test_workspace = os.environ.get('TEST_WORKSPACE') test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self._test_workspace) self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(self._test_workspace) self.assertIsNotNone(self._testproject_data) auth_client = env.setup_auth_client(self._test_workspace, session_token='_PROHIBIT') sessionToken_cc = auth_client.performLogin("Username:Password", "cc:test") sessionToken_john = auth_client.performLogin("Username:Password", "john:doe") self._cc_client =\ env.setup_viewer_client( self._test_workspace, session_token=sessionToken_cc) self._cc_client_john =\ env.setup_viewer_client( self._test_workspace, session_token=sessionToken_john) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test run_names = env.get_run_names(self._test_workspace) runs = self._cc_client.getRunData(None) self._test_runs = [run for run in runs if run.name in run_names] self.assertEqual(len(self._test_runs), 2, 'There should be two runs for this test.')
def setUp(self): self._test_workspace = os.environ.get('TEST_WORKSPACE') test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self._test_workspace) self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(self._test_workspace) self.assertIsNotNone(self._testproject_data) auth_client = env.setup_auth_client(self._test_workspace, session_token='_PROHIBIT') sessionToken_cc = auth_client.performLogin("Username:Password", "cc:test") sessionToken_john = auth_client.performLogin("Username:Password", "john:doe") self._cc_client =\ env.setup_viewer_client( self._test_workspace, session_token=sessionToken_cc) self._cc_client_john =\ env.setup_viewer_client( self._test_workspace, session_token=sessionToken_john) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test run_names = env.get_run_names(self._test_workspace) runs = self._cc_client.getRunData(None, None, 0, None) self._test_runs = [run for run in runs if run.name in run_names] self.assertEqual(len(self._test_runs), 2, 'There should be two runs for this test.')
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 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(self): test_workspace = os.environ['TEST_WORKSPACE'] self.maxDiff = None test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + test_workspace) # Get the clang version which is tested. self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(test_workspace) self.assertIsNotNone(self._testproject_data) self._cc_client = env.setup_viewer_client(test_workspace) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test. run_names = env.get_run_names(test_workspace) runs = self._cc_client.getRunData(None) self._test_runs = [run for run in runs if run.name in run_names] self._runids = [r.runId for r in self._test_runs] self.run1_checkers = \ {'core.CallAndMessage': 5, 'core.DivideZero': 10, 'core.NullDereference': 4, 'core.StackAddressEscape': 3, 'cplusplus.NewDelete': 5, 'deadcode.DeadStores': 6, 'unix.Malloc': 1} self.run2_checkers = \ {'core.CallAndMessage': 5, 'core.DivideZero': 10, 'core.NullDereference': 4, 'cplusplus.NewDelete': 5, 'deadcode.DeadStores': 6, 'unix.MismatchedDeallocator': 1} self.run1_sev_counts = { Severity.MEDIUM: 1, Severity.LOW: 6, Severity.HIGH: 27 } self.run2_sev_counts = { Severity.MEDIUM: 1, Severity.LOW: 6, Severity.HIGH: 24 } self.run1_detection_counts = \ {DetectionStatus.NEW: 34} self.run2_detection_counts = \ {DetectionStatus.NEW: 31} self.run1_files = \ {'file_to_be_skipped.cpp': 2, 'null_dereference.cpp': 5, 'new_delete.cpp': 6, 'stack_address_escape.cpp': 3, 'call_and_message.cpp': 5, 'divide_zero.cpp': 4, 'divide_zero_duplicate.cpp': 2, 'has a space.cpp': 1, 'skip_header.cpp': 1, 'skip.h': 1, 'path_begin.cpp': 2, 'path_end.h': 2 } self.run2_files = \ {'call_and_message.cpp': 5, 'new_delete.cpp': 6, 'divide_zero.cpp': 4, 'divide_zero_duplicate.cpp': 2, 'null_dereference.cpp': 5, 'file_to_be_skipped.cpp': 2, 'has a space.cpp': 1, 'skip_header.cpp': 1, 'skip.h': 1, 'path_begin.cpp': 2, 'path_end.h': 2 }
def setup_package(): """Setup the environment for testing diff_local_remote.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('diff_local_remote') # 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_local = os.path.join(TEST_WORKSPACE, "test_proj_local") shutil.copytree(project.path(test_project), test_proj_path_local) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path_remote = os.path.join(TEST_WORKSPACE, "test_proj_remote") shutil.copytree(project.path(test_project), test_proj_path_remote) project_info['project_path_local'] = test_proj_path_local project_info['project_path_remote'] = test_proj_path_remote 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'] = 'diff_local_remote' codechecker.add_test_package_product(server_access, TEST_WORKSPACE) # Extend the checker configuration with the server access. codechecker_cfg.update(server_access) # Analyze local, these reports will not be stored to the server. altered_file = os.path.join(test_proj_path_local, "call_and_message.cpp") project.insert_suppression(altered_file) codechecker_cfg['reportdir'] = os.path.join(test_proj_path_local, 'reports') codechecker_cfg['checkers'] = [ '-e', 'core.CallAndMessage', '-d', 'core.NullDereference' ] ret = codechecker.log_and_analyze(codechecker_cfg, test_proj_path_local) if ret: sys.exit(1) print('Analyzing local was successful.') # Remote analysis, results will be stored to the remote server. altered_file = os.path.join(test_proj_path_local, "call_and_message.cpp") project.insert_suppression(altered_file) codechecker_cfg['reportdir'] = os.path.join(test_proj_path_remote, 'reports') codechecker_cfg['checkers'] = [ '-d', 'core.CallAndMessage', '-e', 'core.NullDereference' ] ret = codechecker.log_and_analyze(codechecker_cfg, test_proj_path_remote) if ret: sys.exit(1) print('Analyzing new was successful.') # Store results to the remote server. test_project_name_remote = project_info['name'] + '_' + uuid.uuid4().hex ret = codechecker.store(codechecker_cfg, test_project_name_remote) if ret: sys.exit(1) print('Analyzing remote was successful.') # Save the run names in the configuration. codechecker_cfg['run_names'] = [test_project_name_remote] test_config['codechecker_cfg'] = codechecker_cfg # Export the test configuration to the workspace. env.export_test_cfg(TEST_WORKSPACE, test_config)
def setUp(self): self._test_workspace = os.environ.get('TEST_WORKSPACE') test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self._test_workspace) self._clang_to_test = env.clang_to_test() self._testproject_data = env.setup_test_proj_cfg(self._test_workspace) self.assertIsNotNone(self._testproject_data) # Get the test configuration from the prepared int the test workspace. self.test_cfg = env.import_test_cfg(self._test_workspace) self._product_name = self.test_cfg['codechecker_cfg']['viewer_product'] pr_client = env.setup_product_client( self._test_workspace, product=self._product_name) product_id = pr_client.getCurrentProduct().id # Setup an authentication client for creating sessions. self._auth_client = env.setup_auth_client(self._test_workspace, session_token='_PROHIBIT') # Create an PRODUCT_ADMIN login. admin_token = self._auth_client.performLogin("Username:Password", "admin:admin123") extra_params = '{"productID":' + str(product_id) + '}' ret = self._auth_client.addPermission(Permission.PRODUCT_ADMIN, "admin", False, extra_params) self.assertTrue(ret) self._cc_client = env.setup_viewer_client(self._test_workspace, session_token=admin_token) self.assertIsNotNone(self._cc_client) # Get the run names which belong to this test run_names = env.get_run_names(self._test_workspace) runs = self._cc_client.getRunData(None) test_runs = [run for run in runs if run.name in run_names] self.assertEqual(len(test_runs), 1, 'There should be only one run for this test.') self._runid = test_runs[0].runId self._run_name = test_runs[0].name self.components = [ { 'name': 'test_component1', 'value': '\n'.join(['+*/divide_zero.cpp', '-*/new_delete.cpp']), 'description': 'Description of my first component' }, { 'name': 'component name with whitespaces', 'value': '\n'.join(['+*/divide_zero.cpp', '-*/new_delete.cpp']), 'description': 'Description of my second component' }, { 'name': 'test_component2', 'value': '\n'.join(['+*/divide_zero.cpp', '+*/null_dereference.cpp', '-*/call_and_message.cpp', '-*/new_delete.*']), 'description': 'Description of my second component' }, { 'name': 'complex1', 'value': '\n'.join(['+*/divide_zero.cpp', '-*/call_and_message.cpp']) }, { 'name': 'complex2', 'value': '\n'.join(['+*/null_dereference.cpp', '-*/new_delete.cpp']) }, { 'name': 'exclude_all', 'value': '-*' } ]
def setup_package(): """Setup the environment for testing diff_local.""" global TEST_WORKSPACE TEST_WORKSPACE = env.get_workspace('diff_local') # 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_base = os.path.join(TEST_WORKSPACE, "test_proj_base") shutil.copytree(project.path(test_project), test_proj_path_base) # Copy the test project to the workspace. The tests should # work only on this test project. test_proj_path_new = os.path.join(TEST_WORKSPACE, "test_proj_new") shutil.copytree(project.path(test_project), test_proj_path_new) project_info['project_path_base'] = test_proj_path_base project_info['project_path_new'] = test_proj_path_new 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': [] } # Base analysis codechecker_cfg['reportdir'] = os.path.join(test_proj_path_base, 'reports') codechecker_cfg['checkers'] = ['-e', 'core.CallAndMessage', '-d', 'core.NullDereference'] ret = codechecker.log_and_analyze(codechecker_cfg, test_proj_path_base) if ret: sys.exit(1) # New analysis codechecker_cfg['reportdir'] = os.path.join(test_proj_path_new, 'reports') codechecker_cfg['checkers'] = ['-d', 'core.CallAndMessage', '-e', 'core.NullDereference'] ret = codechecker.log_and_analyze(codechecker_cfg, test_proj_path_new) if ret: sys.exit(1) codechecker_cfg['reportdir_base'] = os.path.join(test_proj_path_base, 'reports') codechecker_cfg['reportdir_new'] = os.path.join(test_proj_path_new, 'reports') 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)