test_util.py 708 B

123456789101112131415161718192021222324252627282930313233
  1. #
  2. # Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. import os
  7. import sys
  8. from cot_dt2c.cli import *
  9. from click.testing import CliRunner
  10. def get_script_path():
  11. return os.path.dirname(os.path.realpath(sys.argv[0]))
  12. def test_convert():
  13. runner = CliRunner()
  14. test_file = get_script_path() + "/test.dtsi"
  15. test_output = get_script_path() + "/test.c"
  16. result = runner.invoke(convert_to_c, [test_file, test_output])
  17. try:
  18. assert result.output == ""
  19. except:
  20. print("test convert fail")
  21. try:
  22. os.remove(test_output)
  23. except OSError:
  24. pass
  25. if __name__=="__main__":
  26. test_convert()