start.py 4.9 KB

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