def setUp(self): self.test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self.test_workspace) self.codechecker_cfg = env.import_codechecker_cfg(self.test_workspace) self.test_dir = os.path.join(self.test_workspace, 'test_files') try: os.makedirs(self.test_dir) except os.error: # Directory already exists. pass cc_package = env.codechecker_package() original_severity_cfg = os.path.join(cc_package, 'config', 'checker_severity_map.json') self.workspace_severity_cfg = os.path.join( self.test_workspace, 'checker_severity_map.json') copyfile(original_severity_cfg, self.workspace_severity_cfg) self.codechecker_cfg['check_env']['CC_SEVERITY_MAP_FILE'] = \ self.workspace_severity_cfg
def setUp(self): self.test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self.test_workspace) self.codechecker_cfg = env.import_codechecker_cfg(self.test_workspace) self.test_dir = os.path.join(self.test_workspace, 'test_files') try: os.makedirs(self.test_dir) except os.error: # Directory already exists. pass cc_package = env.codechecker_package() original_severity_cfg = os.path.join(cc_package, 'config', 'checker_severity_map.json') self.workspace_severity_cfg = os.path.join(self.test_workspace, 'checker_severity_map.json') copyfile(original_severity_cfg, self.workspace_severity_cfg) self.codechecker_cfg['check_env']['CC_SEVERITY_MAP_FILE'] = \ self.workspace_severity_cfg
def setUp(self): self.test_workspace = os.environ['TEST_WORKSPACE'] test_class = self.__class__.__name__ print('Running ' + test_class + ' tests in ' + self.test_workspace) self.codechecker_cfg = env.import_codechecker_cfg(self.test_workspace) self.test_dir = os.path.join(self.test_workspace, 'test_files') try: os.makedirs(self.test_dir) except os.error: # Directory already exists. pass cc_package = env.codechecker_package() self.orig_checker_labels_dir = os.path.join( cc_package, 'config', 'labels') self.workspace_labels_dir = os.path.join( self.test_workspace, 'config', 'labels') copytree(self.orig_checker_labels_dir, self.workspace_labels_dir) self.codechecker_cfg['check_env']['CC_TEST_LABELS_DIR'] = \ self.workspace_labels_dir
def enable_auth(workspace): """ Create a dummy authentication-enabled configuration and an auth-enabled server. Running the tests only work if the initial value (in package session_config.json) is FALSE for authentication.enabled. """ session_config_filename = "session_config.json" cc_package = env.codechecker_package() original_auth_cfg = os.path.join(cc_package, 'config', session_config_filename) shutil.copy(original_auth_cfg, workspace) session_cfg_file = os.path.join(workspace, session_config_filename) with open(session_cfg_file, 'r+') as scfg: __scfg_original = scfg.read() scfg.seek(0) try: scfg_dict = json.loads(__scfg_original) except ValueError as verr: print(verr) print('Malformed session config json.') sys.exit(1) scfg_dict["authentication"]["enabled"] = True scfg_dict["authentication"]["method_dictionary"]["enabled"] = True scfg_dict["authentication"]["method_dictionary"]["auths"] = ["cc:test"] json.dump(scfg_dict, scfg, indent=2, sort_keys=True) scfg.truncate()