tests/boot_linux_console: add a test for riscv64 + virt
PATCH v3 1/1 tests/boot_linux_console: add a test for riscv64 + virt
Similar to the mips + malta test, it boots a Linux kernel on a virt board and verify the serial is working. Also, it relies on the serial device set by the machine itself.
If riscv64 is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:riscv64" tags.
Alternatively, this test can be run using:
$ avocado run -t arch:riscv64 tests/acceptance
packages
debian official
binutils-riscv64-linux-gnu_2.32-8
opensbi_0.4-1_all
linux-image-5.0.0-trunk-riscv64 5.0.2-1~exp1 third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
(the repo is also used in mips target acceptance)
--- .travis.yml | 2 +- tests/acceptance/boot_linux_console.py | 67 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-)
.travis.yml +1 -1
@@ -232,7 +232,7 @@ matrix: # Acceptance (Functional) tests - env: - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" - TEST_CMD="make check-acceptance" after_failure: - cat tests/results/latest/job.log
tests/acceptance/boot_linux_console.py +67 -0
70 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 54 lines · Chih-Min Chao
Similar to the mips + malta test, it boots a Linux kernel on a virt board and verify the serial is working. Also, it relies on the serial device set by the machine itself.
If riscv64 is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:riscv64" tags.
Alternatively, this test can be run using:
$ avocado run -t arch:riscv64 tests/acceptancepackages
debian officialbinutils-riscv64-linux-gnu_2.32-8 opensbi_0.4-1_all linux-image-5.0.0-trunk-riscv64 5.0.2-1~exp1third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
(the repo is also used in mips target acceptance)Signed-off-by Chih-Min Chao <[email protected]>--- .travis.yml | 2 +- tests/acceptance/boot_linux_console.py | 67 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-).travis.yml +1
-1@@ -232,7 +232,7 @@ matrix: # Acceptance (Functional) tests - env: - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" - TEST_CMD="make check-acceptance" after_failure: - cat tests/results/latest/job.logtests/acceptance/boot_linux_console.py +6
-0@@ -354,3 +354,70 @@ class BootLinuxConsole(Test): self.vm.launch() console_pattern = 'Kernel command line: %s' % kernel_command_line self.wait_for_console_pattern(console_pattern) + + def test_riscv64_virt(self): + """ + :avocado: tags=arch:riscv64 + :avocado: tags=machine:virt + """
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 372
Quoted 10 lines
tests/acceptance/boot_linux_console.py +10
-0+ deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190424T171759Z/pool/main/b/binutils/' + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so' + libbfd_path = self.extract_from_deb(deb_path, libbfd_path) + process.run('ls -al %s' % (objcopy_path))
Why do we need objcopy? Won't this not work on non x86 architectures?
Quoted 6 lines
tests/acceptance/boot_linux_console.py +6
-0+ + deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190708T032337Z/pool/main/o/opensbi/' + 'opensbi_0.4-1_all.deb') + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 388
Quoted 10 lines
tests/acceptance/boot_linux_console.py +10
-0+ opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' + 'qemu/virt/fw_jump.elf') + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) + + deb_url = ('https://snapshot.debian.org/archive/debian-ports/' + '20190319T205124Z/pool-riscv64/main/l/linux/' + 'linux-image-5.0.0-trunk-riscv64_5.0.2-1~exp1_riscv64.deb') + deb_hash = ('90155ed4b36673cbf7746a37cf3159c8f0b2857a') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = '/boot/vmlinux-5.0.0-trunk-riscv64'
I thought we were swapping to using an Image file?
Alistair
Quoted 39 lines
tests/acceptance/boot_linux_console.py +35
-1+ kernel_path = self.extract_from_deb(deb_path, kernel_path) + kimage_path = self.workdir + "/Image" + env = os.environ + env['LD_LIBRARY_PATH'] = ('%s:' % (os.path.dirname(libbfd_path)) + + env.get('LD_LIBRARY_PATH', '')) + process.run(('%s -O binary -O binary -R' + '.note -R .note.gnu.build-id -R .comment -S %s %s') % + (objcopy_path, kernel_path, kimage_path)) + + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' + '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' + 'riscv64/rootfs.cpio.gz') + initrd_hash = 'f4867d263754961b6f626cdcdc0cb334c47e3b49' + initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) + + self.vm.set_machine('virt') + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0 noreboot') + self.vm.add_args('-bios', "none", + '-kernel', opensbi_path, + '-device', 'loader,file=%s,addr=0x80200000' % (kimage_path), + '-initrd', initrd_path, + '-append', kernel_command_line, + '-no-reboot') + + self.vm.launch() + self.wait_for_console_pattern('Boot successful.') + + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + 'isa') + self.exec_command_and_wait_for_pattern('uname -a', + 'SMP Debian') + self.exec_command_and_wait_for_pattern('reboot', + 'reboot: Restarting system') --2.7.4
Quoted 90 lines · Alistair Francis
Quoted 10 lines · Chih-Min Chao
Similar to the mips + malta test, it boots a Linux kernel on a virt board and verify the serial is working. Also, it relies on the serial device set by the machine itself.
If riscv64 is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:riscv64" tags.
Alternatively, this test can be run using:
Quoted 9 lines
$ avocado run -t arch:riscv64 tests/acceptancepackages
debian officialbinutils-riscv64-linux-gnu_2.32-8 opensbi_0.4-1_all linux-image-5.0.0-trunk-riscv64 5.0.2-1~exp1third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
Quoted 6 lines
(the repo is also used in mips target acceptance)
Signed-off-by Chih-Min Chao <[email protected]>--- .travis.yml | 2 +- tests/acceptance/boot_linux_console.py | 67++++++++++++++++++++++++++++++++++
.travis.yml matrix: · line 235
Quoted 11 lines
2 files changed, 68 insertions(+), 1 deletion(-).travis.yml +0
-1@@ -232,7 +232,7 @@ matrix: # Acceptance (Functional) tests - env: - - CONFIG="--python=/usr/bin/python3--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu"
.travis.yml matrix: · line 235
Quoted 1 line
.travis.yml +1
-0+ - CONFIG="--python=/usr/bin/python3--target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu"
Review
Quoted 4 lines
.travis.yml +0
-0- TEST_CMD="make check-acceptance" after_failure: - cat tests/results/latest/job.log(quoted diff) +0
-0
b/tests/acceptance/boot_linux_console.pytests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 355
Quoted 6 lines
index 3215950..b0569b9 100644
tests/acceptance/boot_linux_console.py +0
-0@@ -354,3 +354,70 @@ class BootLinuxConsole(Test): self.vm.launch() console_pattern = 'Kernel command line: %s' %
kernel_command_lineQuoted 5 lines
tests/acceptance/boot_linux_console.py +4
-0self.wait_for_console_pattern(console_pattern) + + def test_riscv64_virt(self): + """ + :avocado: tags=arch:riscv64tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 10 lines
tests/acceptance/boot_linux_console.py +10
-0+ :avocado: tags=machine:virt + """ + deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190424T171759Z/pool/main/b/binutils/' + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so'
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 372
Quoted 2 lines
tests/acceptance/boot_linux_console.py +2
-0+ libbfd_path = self.extract_from_deb(deb_path, libbfd_path) + process.run('ls -al %s' % (objcopy_path))Why do we need objcopy? Won't this not work on non x86 architectures?
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 397
Quoted 13 lines
tests/acceptance/boot_linux_console.py +13
-0+ + deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190708T032337Z/pool/main/o/opensbi/' + 'opensbi_0.4-1_all.deb') + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' + 'qemu/virt/fw_jump.elf') + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) + + deb_url = ('https://snapshot.debian.org/archive/debian-ports/' + '20190319T205124Z/pool-riscv64/main/l/linux/' +'linux-image-5.0.0-trunk-riscv64_5.0.2-1~exp1_riscv64.deb')
Quoted 9 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 388
Quoted 3 lines
tests/acceptance/boot_linux_console.py +3
-0+ deb_hash = ('90155ed4b36673cbf7746a37cf3159c8f0b2857a') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = '/boot/vmlinux-5.0.0-trunk-riscv64'I thought we were swapping to using an Image file?
Alistair
For objcopy,
Philippe had the same question in PATCH v2 thread. Debian
linux-kernel package only has vmlinux and riscv vmlinux ELF header doesn't contain the correct physical loading address 0x8020_0000.
What I think is to extract the Image from vmlinux by objcopy.
This is what kernel do when generating arch/riscv/boot/Image.
For swapping to using an image file,
I think what you talk about is we have included opensbi.bin into
qemu master ?
The reason is the test use -initrd and -append to pass rootfs and
kernel command line option and the two options requires using of -kernel option.
But -kernel option can't load the opensbi.bin to expected address.
chihmin
Quoted 45 lines
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 4 lines
tests/acceptance/boot_linux_console.py +4
-0+ kernel_path = self.extract_from_deb(deb_path, kernel_path) + kimage_path = self.workdir + "/Image" + env = os.environ + env['LD_LIBRARY_PATH'] = ('%s:' %(
os.path.dirname(libbfd_path)) +tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 3 lines
tests/acceptance/boot_linux_console.py +3
-0+ env.get('LD_LIBRARY_PATH', '')) + process.run(('%s -O binary -O binary -R' + '.note -R .note.gnu.build-id -R .comment -S %s%s') %
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 7 lines
tests/acceptance/boot_linux_console.py +7
-0+ (objcopy_path, kernel_path, kimage_path)) + + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' + '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' + 'riscv64/rootfs.cpio.gz') + initrd_hash = 'f4867d263754961b6f626cdcdc0cb334c47e3b49' + initrd_path = self.fetch_asset(initrd_url,asset_hash=initrd_hash)
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 8 lines
tests/acceptance/boot_linux_console.py +8
-0+ + self.vm.set_machine('virt') + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0 noreboot') + self.vm.add_args('-bios', "none", + '-kernel', opensbi_path, + '-device', 'loader,file=%s,addr=0x80200000' %(
kimage_path),tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test):
Quoted 13 lines
tests/acceptance/boot_linux_console.py +13
-0+ '-initrd', initrd_path, + '-append', kernel_command_line, + '-no-reboot') + + self.vm.launch() + self.wait_for_console_pattern('Boot successful.') + + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + 'isa') + self.exec_command_and_wait_for_pattern('uname -a', + 'SMP Debian') + self.exec_command_and_wait_for_pattern('reboot', + 'reboot: Restartingsystem')
Quoted 4 lines
--
2.7.4
Quoted 92 lines · Chih-Min Chao
Quoted 88 lines · Alistair Francis
Quoted 54 lines · Chih-Min Chao
Similar to the mips + malta test, it boots a Linux kernel on a virt board and verify the serial is working. Also, it relies on the serial device set by the machine itself.
If riscv64 is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:riscv64" tags.
Alternatively, this test can be run using:
$ avocado run -t arch:riscv64 tests/acceptancepackages
debian officialbinutils-riscv64-linux-gnu_2.32-8 opensbi_0.4-1_all linux-image-5.0.0-trunk-riscv64 5.0.2-1~exp1third-party
https://github.com/groeck/linux-build-test/rootfs/riscv64/rootfs.cpio.gz
(the repo is also used in mips target acceptance)Signed-off-by Chih-Min Chao <[email protected]>--- .travis.yml | 2 +- tests/acceptance/boot_linux_console.py | 67 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-).travis.yml +1
-1@@ -232,7 +232,7 @@ matrix: # Acceptance (Functional) tests - env: - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu" + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,riscv64-softmmu" - TEST_CMD="make check-acceptance" after_failure: - cat tests/results/latest/job.logtests/acceptance/boot_linux_console.py +6
-0@@ -354,3 +354,70 @@ class BootLinuxConsole(Test): self.vm.launch() console_pattern = 'Kernel command line: %s' % kernel_command_line self.wait_for_console_pattern(console_pattern) + + def test_riscv64_virt(self): + """ + :avocado: tags=arch:riscv64 + :avocado: tags=machine:virt + """tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 372
Quoted 10 lines
tests/acceptance/boot_linux_console.py +10
-0+ deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190424T171759Z/pool/main/b/binutils/' + 'binutils-riscv64-linux-gnu_2.32-8_amd64.deb') + deb_hash = ('7fe376fd4452696c03acd508d6d613ca553ea15e') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + objcopy_path = '/usr/bin/riscv64-linux-gnu-objcopy' + objcopy_path = self.extract_from_deb(deb_path, objcopy_path) + libbfd_path = '/usr/lib/x86_64-linux-gnu/libbfd-2.32-riscv64.so' + libbfd_path = self.extract_from_deb(deb_path, libbfd_path) + process.run('ls -al %s' % (objcopy_path))Why do we need objcopy? Won't this not work on non x86 architectures?
Quoted 6 lines
tests/acceptance/boot_linux_console.py +6
-0+ + deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190708T032337Z/pool/main/o/opensbi/' + 'opensbi_0.4-1_all.deb') + deb_hash = ('2319dcd702958291d323acf5649fd98a11d90112') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 388
Quoted 10 lines
tests/acceptance/boot_linux_console.py +10
-0+ opensbi_path = ('/usr/lib/riscv64-linux-gnu/opensbi/' + 'qemu/virt/fw_jump.elf') + opensbi_path = self.extract_from_deb(deb_path, opensbi_path) + + deb_url = ('https://snapshot.debian.org/archive/debian-ports/' + '20190319T205124Z/pool-riscv64/main/l/linux/' + 'linux-image-5.0.0-trunk-riscv64_5.0.2-1~exp1_riscv64.deb') + deb_hash = ('90155ed4b36673cbf7746a37cf3159c8f0b2857a') + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = '/boot/vmlinux-5.0.0-trunk-riscv64'I thought we were swapping to using an Image file?
Quoted 6 lines
Quoted 2 lines
Alistair
For objcopy,
Philippe had the same question in PATCH v2 thread. Debian linux-kernel package only has vmlinux and riscv vmlinux ELF header doesn't contain the correct physical loading address 0x8020_0000.
What I think is to extract the Image from vmlinux by objcopy. This is what kernel do when generatingarch/riscv/boot/Image.
That is a real pain. I've never used Debian on RISC-V but that seems strange that they don't build Image files. I think you should use a Fedora kernel instead then.
Quoted 3 lines
For swapping to using an image file,
I think what you talk about is we have included opensbi.bin into qemu master ?
That has already happened, but you don't need it included.
Alistair
Quoted 45 lines
The reason is the test use -initrd and -append to pass rootfs and kernel command line option and the two options requires using of -kernel option. But -kernel option can't load the opensbi.bin to expected address.
chihmin
Quoted 40 lines
Quoted 40 lines
tests/acceptance/boot_linux_console.py +35
-1+ kernel_path = self.extract_from_deb(deb_path, kernel_path) + kimage_path = self.workdir + "/Image" + env = os.environ + env['LD_LIBRARY_PATH'] = ('%s:' % (os.path.dirname(libbfd_path)) + + env.get('LD_LIBRARY_PATH', '')) + process.run(('%s -O binary -O binary -R' + '.note -R .note.gnu.build-id -R .comment -S %s %s') % + (objcopy_path, kernel_path, kimage_path)) + + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' + '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' + 'riscv64/rootfs.cpio.gz') + initrd_hash = 'f4867d263754961b6f626cdcdc0cb334c47e3b49' + initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) + + self.vm.set_machine('virt') + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0 noreboot') + self.vm.add_args('-bios', "none", + '-kernel', opensbi_path, + '-device', 'loader,file=%s,addr=0x80200000' % (kimage_path), + '-initrd', initrd_path, + '-append', kernel_command_line, + '-no-reboot') + + self.vm.launch() + self.wait_for_console_pattern('Boot successful.') + + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + 'isa') + self.exec_command_and_wait_for_pattern('uname -a', + 'SMP Debian') + self.exec_command_and_wait_for_pattern('reboot', + 'reboot: Restarting system') --2.7.4