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