1# 2# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6 7import os 8import sys 9 10from cot_dt2c.cli import * 11from click.testing import CliRunner 12 13def get_script_path(): 14 return os.path.dirname(os.path.realpath(sys.argv[0])) 15 16def 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 32if __name__=="__main__": 33 test_convert() 34