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