3 # Copyright 2016 ZTE Corporation
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
22 import functest.core.TestCasesBase as base
23 import functest.utils.functest_logger as ft_logger
24 import functest.utils.functest_utils as ft_utils
27 class Parser(base.TestCasesBase):
29 super(Parser, self).__init__()
30 self.project_name = "parser"
31 self.case_name = "parser-basics"
32 self.parser_repo = self.get_conf('general.directories.dir_repo_parser')
33 self.results_dir = self.get_conf('general.directories.dir_results')
34 self.logger = ft_logger.Logger("parser").getLogger()
35 self.log_file = self.results_dir + '/parser.log'
37 def run(self, **kwargs):
38 cmd = 'cd %s/tests && ./functest_run.sh' % self.parser_repo
40 self.start_time = time.time()
41 ret = ft_utils.execute_command(cmd,
43 output_file=self.log_file)
44 self.stop_time = time.time()
46 self.criteria, details = ft_utils.check_test_result(self.project_name,
51 ft_utils.logger_test_results(self.project_name,
59 def get_conf(parameter):
60 return ft_utils.get_functest_config(parameter)
63 if __name__ == '__main__':
64 args_parser = argparse.ArgumentParser()
65 args_parser.add_argument("-r", "--report",
66 help="Create json result file",
68 args = vars(args_parser.parse_args())
71 result = parser.run(**args)
72 if result != base.TestCasesBase.EX_OK:
75 sys.exit(parser.push_to_db())
77 sys.exit(base.TestCasesBase.EX_RUN_ERROR)