2 ##############################################################################
3 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 '''This file realize the function of how to run posca.
11 In this file, The first thing is to read testcase config
12 for example: you could run this by use
13 posca_run('testcase', "Which testcase you will run")
14 posca_run('teststory', "Which story you will run")
15 and if you run "python run_posca", this will run testcase,
16 posca_factor_system_bandwidth by default.'''
20 import utils.parser as conf_parser
21 import utils.logger as log
22 INTERPRETER = "/usr/bin/python"
24 LOG = log.Logger(__name__).getLogger()
25 # ------------------------------------------------------
26 # run testcase in posca
27 # ------------------------------------------------------
30 def posca_testcase_run(testcase_script, test_config):
32 module_string = "testsuites.posca.testcase_script.%s" % (testcase_script)
33 module = importlib.import_module(module_string)
34 module.run(test_config)
37 def posca_run(test_level, test_name):
38 if test_level == "testcase":
39 config = conf_parser.Parser.testcase_read("posca", test_name)
40 elif test_level == "teststory":
41 config = conf_parser.Parser.story_read("posca", test_name)
42 for testcase in config:
43 LOG.info("Begin to run %s testcase in POSCA testsuite", testcase)
44 config[testcase]['out_file'] =\
45 conf_parser.Parser.testcase_out_dir(testcase)
46 posca_testcase_run(testcase, config[testcase])
47 LOG.info("End of %s testcase in POSCA testsuite", testcase)
51 test_level = sys.argv[1]
52 test_name = sys.argv[2]
53 posca_run(test_level, test_name)
56 if __name__ == '__main__':