1*96778e69SThomas Huth#!/usr/bin/env python3 2*96778e69SThomas Huth# 3*96778e69SThomas Huth# Functional test that checks the serial console of the stellaris machines 4*96778e69SThomas Huth# 5*96778e69SThomas Huth# SPDX-License-Identifier: GPL-2.0-or-later 6*96778e69SThomas Huth 7*96778e69SThomas Huthfrom qemu_test import QemuSystemTest, Asset, exec_command_and_wait_for_pattern 8*96778e69SThomas Huthfrom qemu_test import wait_for_console_pattern 9*96778e69SThomas Huth 10*96778e69SThomas Huth 11*96778e69SThomas Huthclass StellarisMachine(QemuSystemTest): 12*96778e69SThomas Huth 13*96778e69SThomas Huth ASSET_DAY22 = Asset( 14*96778e69SThomas Huth 'https://www.qemu-advent-calendar.org/2023/download/day22.tar.gz', 15*96778e69SThomas Huth 'ae3a63ef4b7a22c21bfc7fc0d85e402fe95e223308ed23ac854405016431ff51') 16*96778e69SThomas Huth 17*96778e69SThomas Huth def test_lm3s6965evb(self): 18*96778e69SThomas Huth self.set_machine('lm3s6965evb') 19*96778e69SThomas Huth kernel_path = self.archive_extract(self.ASSET_DAY22, 20*96778e69SThomas Huth member='day22/day22.bin') 21*96778e69SThomas Huth self.vm.set_console() 22*96778e69SThomas Huth self.vm.add_args('-kernel', kernel_path) 23*96778e69SThomas Huth self.vm.launch() 24*96778e69SThomas Huth 25*96778e69SThomas Huth wait_for_console_pattern(self, 'In a one horse open') 26*96778e69SThomas Huth 27*96778e69SThomas Huth ASSET_NOTMAIN = Asset( 28*96778e69SThomas Huth 'https://github.com/Ahelion/QemuArmM4FDemoSw/raw/master/build/notmain.bin', 29*96778e69SThomas Huth '6ceda031aa081a420fca2fca9e137fa681d6e3820d820ad1917736cb265e611a') 30*96778e69SThomas Huth 31*96778e69SThomas Huth def test_lm3s811evb(self): 32*96778e69SThomas Huth self.set_machine('lm3s811evb') 33*96778e69SThomas Huth kernel_path = self.ASSET_NOTMAIN.fetch() 34*96778e69SThomas Huth 35*96778e69SThomas Huth self.vm.set_console() 36*96778e69SThomas Huth self.vm.add_args('-cpu', 'cortex-m4') 37*96778e69SThomas Huth self.vm.add_args('-kernel', kernel_path) 38*96778e69SThomas Huth self.vm.launch() 39*96778e69SThomas Huth 40*96778e69SThomas Huth # The test kernel emits an initial '!' and then waits for input. 41*96778e69SThomas Huth # For each character that we send it responds with a certain 42*96778e69SThomas Huth # other ASCII character. 43*96778e69SThomas Huth wait_for_console_pattern(self, '!') 44*96778e69SThomas Huth exec_command_and_wait_for_pattern(self, '789', 'cdf') 45*96778e69SThomas Huth 46*96778e69SThomas Huth 47*96778e69SThomas Huthif __name__ == '__main__': 48*96778e69SThomas Huth QemuSystemTest.main() 49