xref: /qemu/tests/functional/test_avr_mega2560.py (revision 4c0a2df81c9166a3a84293501008a85dfbe8a3a6)
1*4c0a2df8SThomas Huth#!/usr/bin/env python3
2f5d31d65SMichael Rolnik#
3bbbd9b6eSWillian Rampazzo# QEMU AVR integration tests
4f5d31d65SMichael Rolnik#
5f5d31d65SMichael Rolnik# Copyright (c) 2019-2020 Michael Rolnik <mrolnik@gmail.com>
6f5d31d65SMichael Rolnik#
7f5d31d65SMichael Rolnik# This program is free software: you can redistribute it and/or modify
8f5d31d65SMichael Rolnik# it under the terms of the GNU General Public License as published by
9f5d31d65SMichael Rolnik# the Free Software Foundation, either version 2 of the License, or
10f5d31d65SMichael Rolnik# (at your option) any later version.
11f5d31d65SMichael Rolnik#
12f5d31d65SMichael Rolnik# This program is distributed in the hope that it will be useful,
13f5d31d65SMichael Rolnik# but WITHOUT ANY WARRANTY; without even the implied warranty of
14f5d31d65SMichael Rolnik# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15f5d31d65SMichael Rolnik# GNU General Public License for more details.
16f5d31d65SMichael Rolnik#
17f5d31d65SMichael Rolnik# You should have received a copy of the GNU General Public License
18f5d31d65SMichael Rolnik# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19f5d31d65SMichael Rolnik#
20f5d31d65SMichael Rolnik
21f5d31d65SMichael Rolnikimport time
22f5d31d65SMichael Rolnik
23*4c0a2df8SThomas Huthfrom qemu_test import QemuSystemTest, Asset
24f5d31d65SMichael Rolnik
252283b627SPhilippe Mathieu-Daudéclass AVR6Machine(QemuSystemTest):
26f5d31d65SMichael Rolnik    timeout = 5
27f5d31d65SMichael Rolnik
28*4c0a2df8SThomas Huth    ASSET_ROM = Asset(('https://github.com/seharris/qemu-avr-tests'
29*4c0a2df8SThomas Huth                       '/raw/36c3e67b8755dcf/free-rtos/Demo'
30*4c0a2df8SThomas Huth                       '/AVR_ATMega2560_GCC/demo.elf'),
31*4c0a2df8SThomas Huth                      'ee4833bd65fc69e84a79ed1c608affddbd499a60e63acf87d9113618401904e4')
32*4c0a2df8SThomas Huth
33f5d31d65SMichael Rolnik    def test_freertos(self):
34f5d31d65SMichael Rolnik        """
35f5d31d65SMichael Rolnik        https://github.com/seharris/qemu-avr-tests/raw/master/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf
36f5d31d65SMichael Rolnik        constantly prints out 'ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWX'
37f5d31d65SMichael Rolnik        """
38*4c0a2df8SThomas Huth        rom_path = self.ASSET_ROM.fetch()
39f5d31d65SMichael Rolnik
40*4c0a2df8SThomas Huth        self.set_machine('arduino-mega-2560-v3')
41f5d31d65SMichael Rolnik        self.vm.add_args('-bios', rom_path)
42f5d31d65SMichael Rolnik        self.vm.add_args('-nographic')
43f5d31d65SMichael Rolnik        self.vm.launch()
44f5d31d65SMichael Rolnik
45f5d31d65SMichael Rolnik        time.sleep(2)
46f5d31d65SMichael Rolnik        self.vm.shutdown()
47f5d31d65SMichael Rolnik
48f5d31d65SMichael Rolnik        self.assertIn('ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWX',
49f5d31d65SMichael Rolnik                self.vm.get_log())
50*4c0a2df8SThomas Huth
51*4c0a2df8SThomas Huthif __name__ == '__main__':
52*4c0a2df8SThomas Huth    QemuSystemTest.main()
53