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