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.
23 import functest.core.TestCasesBase as base
24 import functest.utils.functest_constants as ft_constants
25 import functest.utils.functest_logger as ft_logger
26 import functest.utils.functest_utils as ft_utils
29 class Parser(base.TestCasesBase):
32 super(Parser, self).__init__()
33 self.project_name = "parser"
34 self.case_name = "parser-basics"
35 self.logger = ft_logger.Logger("parser").getLogger()
36 self.log_file = os.path.join(
37 ft_constants.FUNCTEST_RESULTS_DIR, "parser.log")
39 def run(self, **kwargs):
40 cmd = 'cd %s/tests && ./functest_run.sh' % ft_constants.PARSER_REPO_DIR
42 self.start_time = time.time()
43 ret = ft_utils.execute_command(cmd,
45 output_file=self.log_file)
46 self.stop_time = time.time()
48 self.criteria, details = ft_utils.check_test_result(self.project_name,
53 ft_utils.logger_test_results(self.project_name,
61 def get_conf(parameter):
62 return ft_utils.get_functest_config(parameter)
65 if __name__ == '__main__':
66 args_parser = argparse.ArgumentParser()
67 args_parser.add_argument("-r", "--report",
68 help="Create json result file",
70 args = vars(args_parser.parse_args())
73 result = parser.run(**args)
74 if result != base.TestCasesBase.EX_OK:
77 sys.exit(parser.push_to_db())
79 sys.exit(base.TestCasesBase.EX_RUN_ERROR)