start.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #
  2. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #
  5. #!/usr/bin/env python
  6. # -*- coding: utf-8 -*-
  7. """
  8. It is the entrance of the iagent test framework.
  9. """
  10. import argparse
  11. import datetime
  12. import os
  13. import pprint
  14. import random
  15. import re
  16. import shlex
  17. import subprocess
  18. import signal
  19. import sys
  20. import time
  21. sys.path.append('../../../app-sdk/python')
  22. from framework.test_utils import *
  23. from framework.framework import *
  24. def signal_handler(signal, frame):
  25. print('Pressed Ctrl+C!')
  26. sys.exit(0)
  27. def Register_signal_handler():
  28. signal.signal(signal.SIGINT, signal_handler)
  29. # signal.pause()
  30. def flatten_args_list(l):
  31. if l is None:
  32. return None
  33. return [x for y in l for x in y]
  34. if __name__ == "__main__":
  35. parser = argparse.ArgumentParser(description = "to run specific case(s) "\
  36. "in specific suite(s) with FC test framework")
  37. parser.add_argument('-s', dest = 'suite_id', action = 'append',
  38. nargs = '+',
  39. help = 'one or multiple suite ids, which are also setup ids.'\
  40. 'by default if it isn\'t passed from argument, all '\
  41. 'suites are going to be run.')
  42. parser.add_argument('-t', dest = 'case_id', action = 'append',
  43. nargs = '+',
  44. help = 'one or multiple cases ids.'\
  45. 'by default if it isn\'t passed from argument, all '\
  46. 'cases in specific suites are going to be run.')
  47. parser.add_argument('-n', dest = 'repeat_time', action = 'store',
  48. default = 1,
  49. help = 'how many times do you want to run. there is 40s '\
  50. 'break time between two rounds. each round includs '\
  51. 'init_setup, run_test_case and deinit_setup.')
  52. parser.add_argument('--shuffle_all', dest = 'shuffle_all',
  53. default = False, action = 'store_true',
  54. help = 'shuffle_all test cases in per test suite '\
  55. 'by default, all cases under per suite should '\
  56. 'be executed by input order.')
  57. parser.add_argument('--cases_list', dest='cases_list_file_path',
  58. default=None,
  59. action='store',
  60. help="read cases list from a flie ")
  61. parser.add_argument('--skip_proc', dest='skip_proc',
  62. default = False, action = 'store_true',
  63. help='do not start the test process.'\
  64. 'sometimes the gw_broker process will be started in eclipse for debug purpose')
  65. parser.add_argument('-b', dest = 'binaries', action = 'store',
  66. help = 'The path of target folder ')
  67. parser.add_argument('-d', dest = 'debug', action = 'store_true',
  68. help = 'wait user to attach the target process after launch processes ')
  69. parser.add_argument('--rebuild', dest = 'rebuild', action = 'store_true',
  70. help = 'rebuild all test binaries')
  71. args = parser.parse_args()
  72. print "------------------------------------------------------------"
  73. print "parsing arguments ... ..."
  74. print args
  75. '''
  76. logger = logging.getLogger('coapthon.server.coap')
  77. logger.setLevel(logging.DEBUG)
  78. console = logging.StreamHandler()
  79. console.setLevel(logging.DEBUG)
  80. logger.addHandler(console)
  81. '''
  82. print "------------------------------------------------------------"
  83. print "preparing wamr binary and test tools ... ..."
  84. os.system("cd ../../samples/simple/ && bash build.sh -p host-interp")
  85. Register_signal_handler()
  86. api_init_globals();
  87. api_create_case_event();
  88. suites_list = flatten_args_list(args.suite_id)
  89. cases_list = flatten_args_list(args.case_id)
  90. dirname, filename = os.path.split(os.path.abspath(sys.argv[0]))
  91. api_set_root_path(dirname);
  92. framework = CTestFramework(dirname);
  93. framework.repeat_time = int(args.repeat_time)
  94. framework.shuffle_all = args.shuffle_all
  95. framework.skip_proc=args.skip_proc
  96. api_set_value('keep_env', args.skip_proc)
  97. api_set_value('debug', args.debug)
  98. api_set_value('rebuild', args.rebuild)
  99. binary_path = args.binaries
  100. if binary_path is None:
  101. binary_path = os.path.abspath(dirname + '/../..')
  102. print "checking execution binary path: " + binary_path
  103. if not os.path.exists(binary_path):
  104. print "The execution binary path was not available. quit..."
  105. os._exit(0)
  106. api_set_value('binary_path', binary_path)
  107. if suites_list is not None:
  108. framework.target_suites = suites_list
  109. else:
  110. framework.load_suites()
  111. framework.target_cases = cases_list
  112. framework.start_run()
  113. print "\n\n------------------------------------------------------------"
  114. print "The run folder is [" + framework.running_folder +"]"
  115. print "that's all. bye"
  116. print "kill to quit.."
  117. t_kill_process_by_name("start.py")
  118. sys.exit(0)
  119. os._exit()