suite_setup.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #
  2. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #
  5. import os
  6. import shutil
  7. import types
  8. import time
  9. import glob
  10. from framework.test_api import *
  11. from framework.test_utils import *
  12. from harness.harness_api import *
  13. from framework.suite import *
  14. class CTestSuite(CTestSuiteBase):
  15. setup_path = ""
  16. def __init__(self, name, suite_path, run_path):
  17. CTestSuiteBase.__init__(self, name, suite_path, run_path)
  18. def on_suite_setup(self):
  19. global setup_path
  20. setup_path = os.getcwd()
  21. cases = os.listdir(self.suite_path + "/cases/")
  22. cases.sort()
  23. if api_get_value("rebuild", False):
  24. path_tmp = os.getcwd()
  25. os.chdir(self.suite_path + "/test-app")
  26. os.system(self.suite_path + "/test-app" + "/build.sh")
  27. os.chdir(path_tmp)
  28. os.makedirs(self.run_path + "/test-app")
  29. for case in cases:
  30. if case != "__init__.pyc" and case != "__init__.py":
  31. os.makedirs(self.run_path + "/" + case)
  32. #copy each case's host_tool, simple, wasm files, start/stop scripts to the run directory,
  33. shutil.copy(setup_path + "/../../samples/simple/out/simple", self.run_path + "/" + case)
  34. shutil.copy(setup_path + "/../../samples/simple/out/host_tool", self.run_path + "/" + case)
  35. for file in glob.glob(self.suite_path + "/test-app/" + "/*.wasm"):
  36. shutil.copy(file, self.run_path + "/test-app")
  37. shutil.copy(self.suite_path + "/tools/product/start.sh", self.run_path + "/" + case)
  38. shutil.copy(self.suite_path + "/tools/product/stop.sh", self.run_path + "/" + case)
  39. os.chdir(self.run_path)
  40. return True, 'OK'
  41. def on_suite_cleanup(self):
  42. global setup_path
  43. os.chdir(setup_path)
  44. api_log("stopping env..")
  45. return True, 'OK'