boot_linux_console.py 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  1. # Functional test that boots a Linux kernel and checks the console
  2. #
  3. # Copyright (c) 2018 Red Hat, Inc.
  4. #
  5. # Author:
  6. # Cleber Rosa <crosa@redhat.com>
  7. #
  8. # This work is licensed under the terms of the GNU GPL, version 2 or
  9. # later. See the COPYING file in the top-level directory.
  10. import os
  11. import lzma
  12. import gzip
  13. import shutil
  14. from avocado import skip
  15. from avocado import skipUnless
  16. from avocado_qemu import QemuSystemTest
  17. from avocado_qemu import exec_command
  18. from avocado_qemu import exec_command_and_wait_for_pattern
  19. from avocado_qemu import interrupt_interactive_console_until_pattern
  20. from avocado_qemu import wait_for_console_pattern
  21. from avocado.utils import process
  22. from avocado.utils import archive
  23. """
  24. Round up to next power of 2
  25. """
  26. def pow2ceil(x):
  27. return 1 if x == 0 else 2**(x - 1).bit_length()
  28. """
  29. Expand file size to next power of 2
  30. """
  31. def image_pow2ceil_expand(path):
  32. size = os.path.getsize(path)
  33. size_aligned = pow2ceil(size)
  34. if size != size_aligned:
  35. with open(path, 'ab+') as fd:
  36. fd.truncate(size_aligned)
  37. class LinuxKernelTest(QemuSystemTest):
  38. KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
  39. def wait_for_console_pattern(self, success_message, vm=None):
  40. wait_for_console_pattern(self, success_message,
  41. failure_message='Kernel panic - not syncing',
  42. vm=vm)
  43. def extract_from_deb(self, deb, path):
  44. """
  45. Extracts a file from a deb package into the test workdir
  46. :param deb: path to the deb archive
  47. :param path: path within the deb archive of the file to be extracted
  48. :returns: path of the extracted file
  49. """
  50. cwd = os.getcwd()
  51. os.chdir(self.workdir)
  52. file_path = process.run("ar t %s" % deb).stdout_text.split()[2]
  53. process.run("ar x %s %s" % (deb, file_path))
  54. archive.extract(file_path, self.workdir)
  55. os.chdir(cwd)
  56. # Return complete path to extracted file. Because callers to
  57. # extract_from_deb() specify 'path' with a leading slash, it is
  58. # necessary to use os.path.relpath() as otherwise os.path.join()
  59. # interprets it as an absolute path and drops the self.workdir part.
  60. return os.path.normpath(os.path.join(self.workdir,
  61. os.path.relpath(path, '/')))
  62. def extract_from_rpm(self, rpm, path):
  63. """
  64. Extracts a file from an RPM package into the test workdir.
  65. :param rpm: path to the rpm archive
  66. :param path: path within the rpm archive of the file to be extracted
  67. needs to be a relative path (starting with './') because
  68. cpio(1), which is used to extract the file, expects that.
  69. :returns: path of the extracted file
  70. """
  71. cwd = os.getcwd()
  72. os.chdir(self.workdir)
  73. process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True)
  74. os.chdir(cwd)
  75. return os.path.normpath(os.path.join(self.workdir, path))
  76. class BootLinuxConsole(LinuxKernelTest):
  77. """
  78. Boots a Linux kernel and checks that the console is operational and the
  79. kernel command line is properly passed from QEMU to the kernel
  80. """
  81. timeout = 90
  82. def test_x86_64_pc(self):
  83. """
  84. :avocado: tags=arch:x86_64
  85. :avocado: tags=machine:pc
  86. """
  87. kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
  88. '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
  89. '/vmlinuz')
  90. kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
  91. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  92. self.vm.set_console()
  93. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
  94. self.vm.add_args('-kernel', kernel_path,
  95. '-append', kernel_command_line)
  96. self.vm.launch()
  97. console_pattern = 'Kernel command line: %s' % kernel_command_line
  98. self.wait_for_console_pattern(console_pattern)
  99. def test_mips_malta(self):
  100. """
  101. :avocado: tags=arch:mips
  102. :avocado: tags=machine:malta
  103. :avocado: tags=endian:big
  104. """
  105. deb_url = ('http://snapshot.debian.org/archive/debian/'
  106. '20130217T032700Z/pool/main/l/linux-2.6/'
  107. 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
  108. deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
  109. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  110. kernel_path = self.extract_from_deb(deb_path,
  111. '/boot/vmlinux-2.6.32-5-4kc-malta')
  112. self.vm.set_console()
  113. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
  114. self.vm.add_args('-kernel', kernel_path,
  115. '-append', kernel_command_line)
  116. self.vm.launch()
  117. console_pattern = 'Kernel command line: %s' % kernel_command_line
  118. self.wait_for_console_pattern(console_pattern)
  119. def test_mips64el_malta(self):
  120. """
  121. This test requires the ar tool to extract "data.tar.gz" from
  122. the Debian package.
  123. The kernel can be rebuilt using this Debian kernel source [1] and
  124. following the instructions on [2].
  125. [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
  126. #linux-source-2.6.32_2.6.32-48
  127. [2] https://kernel-team.pages.debian.net/kernel-handbook/
  128. ch-common-tasks.html#s-common-official
  129. :avocado: tags=arch:mips64el
  130. :avocado: tags=machine:malta
  131. """
  132. deb_url = ('http://snapshot.debian.org/archive/debian/'
  133. '20130217T032700Z/pool/main/l/linux-2.6/'
  134. 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
  135. deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
  136. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  137. kernel_path = self.extract_from_deb(deb_path,
  138. '/boot/vmlinux-2.6.32-5-5kc-malta')
  139. self.vm.set_console()
  140. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
  141. self.vm.add_args('-kernel', kernel_path,
  142. '-append', kernel_command_line)
  143. self.vm.launch()
  144. console_pattern = 'Kernel command line: %s' % kernel_command_line
  145. self.wait_for_console_pattern(console_pattern)
  146. def test_mips64el_fuloong2e(self):
  147. """
  148. :avocado: tags=arch:mips64el
  149. :avocado: tags=machine:fuloong2e
  150. :avocado: tags=endian:little
  151. """
  152. deb_url = ('http://archive.debian.org/debian/pool/main/l/linux/'
  153. 'linux-image-3.16.0-6-loongson-2e_3.16.56-1+deb8u1_mipsel.deb')
  154. deb_hash = 'd04d446045deecf7b755ef576551de0c4184dd44'
  155. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  156. kernel_path = self.extract_from_deb(deb_path,
  157. '/boot/vmlinux-3.16.0-6-loongson-2e')
  158. self.vm.set_console()
  159. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
  160. self.vm.add_args('-kernel', kernel_path,
  161. '-append', kernel_command_line)
  162. self.vm.launch()
  163. console_pattern = 'Kernel command line: %s' % kernel_command_line
  164. self.wait_for_console_pattern(console_pattern)
  165. def test_mips_malta_cpio(self):
  166. """
  167. :avocado: tags=arch:mips
  168. :avocado: tags=machine:malta
  169. :avocado: tags=endian:big
  170. """
  171. deb_url = ('http://snapshot.debian.org/archive/debian/'
  172. '20160601T041800Z/pool/main/l/linux/'
  173. 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
  174. deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
  175. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  176. kernel_path = self.extract_from_deb(deb_path,
  177. '/boot/vmlinux-4.5.0-2-4kc-malta')
  178. initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
  179. '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
  180. 'mips/rootfs.cpio.gz')
  181. initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'
  182. initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
  183. initrd_path = self.workdir + "rootfs.cpio"
  184. archive.gzip_uncompress(initrd_path_gz, initrd_path)
  185. self.vm.set_console()
  186. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
  187. + 'console=ttyS0 console=tty '
  188. + 'rdinit=/sbin/init noreboot')
  189. self.vm.add_args('-kernel', kernel_path,
  190. '-initrd', initrd_path,
  191. '-append', kernel_command_line,
  192. '-no-reboot')
  193. self.vm.launch()
  194. self.wait_for_console_pattern('Boot successful.')
  195. exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
  196. 'BogoMIPS')
  197. exec_command_and_wait_for_pattern(self, 'uname -a',
  198. 'Debian')
  199. exec_command_and_wait_for_pattern(self, 'reboot',
  200. 'reboot: Restarting system')
  201. # Wait for VM to shut down gracefully
  202. self.vm.wait()
  203. @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
  204. def test_mips64el_malta_5KEc_cpio(self):
  205. """
  206. :avocado: tags=arch:mips64el
  207. :avocado: tags=machine:malta
  208. :avocado: tags=endian:little
  209. :avocado: tags=cpu:5KEc
  210. """
  211. kernel_url = ('https://github.com/philmd/qemu-testing-blob/'
  212. 'raw/9ad2df38/mips/malta/mips64el/'
  213. 'vmlinux-3.19.3.mtoman.20150408')
  214. kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
  215. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  216. initrd_url = ('https://github.com/groeck/linux-build-test/'
  217. 'raw/8584a59e/rootfs/'
  218. 'mipsel64/rootfs.mipsel64r1.cpio.gz')
  219. initrd_hash = '1dbb8a396e916847325284dbe2151167'
  220. initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5',
  221. asset_hash=initrd_hash)
  222. initrd_path = self.workdir + "rootfs.cpio"
  223. archive.gzip_uncompress(initrd_path_gz, initrd_path)
  224. self.vm.set_console()
  225. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
  226. + 'console=ttyS0 console=tty '
  227. + 'rdinit=/sbin/init noreboot')
  228. self.vm.add_args('-kernel', kernel_path,
  229. '-initrd', initrd_path,
  230. '-append', kernel_command_line,
  231. '-no-reboot')
  232. self.vm.launch()
  233. wait_for_console_pattern(self, 'Boot successful.')
  234. exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
  235. 'MIPS 5KE')
  236. exec_command_and_wait_for_pattern(self, 'uname -a',
  237. '3.19.3.mtoman.20150408')
  238. exec_command_and_wait_for_pattern(self, 'reboot',
  239. 'reboot: Restarting system')
  240. # Wait for VM to shut down gracefully
  241. self.vm.wait()
  242. def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash):
  243. kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  244. kernel_path = self.workdir + "kernel"
  245. with lzma.open(kernel_path_xz, 'rb') as f_in:
  246. with open(kernel_path, 'wb') as f_out:
  247. shutil.copyfileobj(f_in, f_out)
  248. self.vm.set_console()
  249. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE
  250. + 'mem=256m@@0x0 '
  251. + 'console=ttyS0')
  252. self.vm.add_args('-no-reboot',
  253. '-kernel', kernel_path,
  254. '-append', kernel_command_line)
  255. self.vm.launch()
  256. console_pattern = 'Kernel command line: %s' % kernel_command_line
  257. self.wait_for_console_pattern(console_pattern)
  258. def test_mips_malta32el_nanomips_4k(self):
  259. """
  260. :avocado: tags=arch:mipsel
  261. :avocado: tags=machine:malta
  262. :avocado: tags=endian:little
  263. :avocado: tags=cpu:I7200
  264. """
  265. kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
  266. 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
  267. 'generic_nano32r6el_page4k.xz')
  268. kernel_hash = '477456aafd2a0f1ddc9482727f20fe9575565dd6'
  269. self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
  270. def test_mips_malta32el_nanomips_16k_up(self):
  271. """
  272. :avocado: tags=arch:mipsel
  273. :avocado: tags=machine:malta
  274. :avocado: tags=endian:little
  275. :avocado: tags=cpu:I7200
  276. """
  277. kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
  278. 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
  279. 'generic_nano32r6el_page16k_up.xz')
  280. kernel_hash = 'e882868f944c71c816e832e2303b7874d044a7bc'
  281. self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
  282. def test_mips_malta32el_nanomips_64k_dbg(self):
  283. """
  284. :avocado: tags=arch:mipsel
  285. :avocado: tags=machine:malta
  286. :avocado: tags=endian:little
  287. :avocado: tags=cpu:I7200
  288. """
  289. kernel_url = ('https://mipsdistros.mips.com/LinuxDistro/nanomips/'
  290. 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
  291. 'generic_nano32r6el_page64k_dbg.xz')
  292. kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
  293. self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
  294. def test_aarch64_xlnx_versal_virt(self):
  295. """
  296. :avocado: tags=arch:aarch64
  297. :avocado: tags=machine:xlnx-versal-virt
  298. :avocado: tags=device:pl011
  299. :avocado: tags=device:arm_gicv3
  300. :avocado: tags=accel:tcg
  301. """
  302. images_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/'
  303. 'bionic-updates/main/installer-arm64/'
  304. '20101020ubuntu543.15/images/')
  305. kernel_url = images_url + 'netboot/ubuntu-installer/arm64/linux'
  306. kernel_hash = '5bfc54cf7ed8157d93f6e5b0241e727b6dc22c50'
  307. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  308. initrd_url = images_url + 'netboot/ubuntu-installer/arm64/initrd.gz'
  309. initrd_hash = 'd385d3e88d53e2004c5d43cbe668b458a094f772'
  310. initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
  311. self.vm.set_console()
  312. self.vm.add_args('-m', '2G',
  313. '-accel', 'tcg',
  314. '-kernel', kernel_path,
  315. '-initrd', initrd_path)
  316. self.vm.launch()
  317. self.wait_for_console_pattern('Checked W+X mappings: passed')
  318. def test_arm_virt(self):
  319. """
  320. :avocado: tags=arch:arm
  321. :avocado: tags=machine:virt
  322. :avocado: tags=accel:tcg
  323. """
  324. kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
  325. '/linux/releases/29/Everything/armhfp/os/images/pxeboot'
  326. '/vmlinuz')
  327. kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
  328. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  329. self.vm.set_console()
  330. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  331. 'console=ttyAMA0')
  332. self.vm.add_args('-kernel', kernel_path,
  333. '-append', kernel_command_line)
  334. self.vm.launch()
  335. console_pattern = 'Kernel command line: %s' % kernel_command_line
  336. self.wait_for_console_pattern(console_pattern)
  337. def test_arm_emcraft_sf2(self):
  338. """
  339. :avocado: tags=arch:arm
  340. :avocado: tags=machine:emcraft-sf2
  341. :avocado: tags=endian:little
  342. :avocado: tags=u-boot
  343. :avocado: tags=accel:tcg
  344. """
  345. uboot_url = ('https://raw.githubusercontent.com/'
  346. 'Subbaraya-Sundeep/qemu-test-binaries/'
  347. 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot')
  348. uboot_hash = 'cbb8cbab970f594bf6523b9855be209c08374ae2'
  349. uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash)
  350. spi_url = ('https://raw.githubusercontent.com/'
  351. 'Subbaraya-Sundeep/qemu-test-binaries/'
  352. 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin')
  353. spi_hash = '65523a1835949b6f4553be96dec1b6a38fb05501'
  354. spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash)
  355. self.vm.set_console()
  356. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
  357. self.vm.add_args('-kernel', uboot_path,
  358. '-append', kernel_command_line,
  359. '-drive', 'file=' + spi_path + ',if=mtd,format=raw',
  360. '-no-reboot')
  361. self.vm.launch()
  362. self.wait_for_console_pattern('Enter \'help\' for a list')
  363. exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15',
  364. 'eth0: link becomes ready')
  365. exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
  366. '3 packets transmitted, 3 packets received, 0% packet loss')
  367. def do_test_arm_raspi2(self, uart_id):
  368. """
  369. :avocado: tags=accel:tcg
  370. The kernel can be rebuilt using the kernel source referenced
  371. and following the instructions on the on:
  372. https://www.raspberrypi.org/documentation/linux/kernel/building.md
  373. """
  374. serial_kernel_cmdline = {
  375. 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0',
  376. }
  377. deb_url = ('http://archive.raspberrypi.org/debian/'
  378. 'pool/main/r/raspberrypi-firmware/'
  379. 'raspberrypi-kernel_1.20190215-1_armhf.deb')
  380. deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
  381. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  382. kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
  383. dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
  384. self.vm.set_console()
  385. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  386. serial_kernel_cmdline[uart_id] +
  387. ' root=/dev/mmcblk0p2 rootwait ' +
  388. 'dwc_otg.fiq_fsm_enable=0')
  389. self.vm.add_args('-kernel', kernel_path,
  390. '-dtb', dtb_path,
  391. '-append', kernel_command_line,
  392. '-device', 'usb-kbd')
  393. self.vm.launch()
  394. console_pattern = 'Kernel command line: %s' % kernel_command_line
  395. self.wait_for_console_pattern(console_pattern)
  396. console_pattern = 'Product: QEMU USB Keyboard'
  397. self.wait_for_console_pattern(console_pattern)
  398. def test_arm_raspi2_uart0(self):
  399. """
  400. :avocado: tags=arch:arm
  401. :avocado: tags=machine:raspi2b
  402. :avocado: tags=device:pl011
  403. :avocado: tags=accel:tcg
  404. """
  405. self.do_test_arm_raspi2(0)
  406. def test_arm_raspi2_initrd(self):
  407. """
  408. :avocado: tags=arch:arm
  409. :avocado: tags=machine:raspi2b
  410. """
  411. deb_url = ('http://archive.raspberrypi.org/debian/'
  412. 'pool/main/r/raspberrypi-firmware/'
  413. 'raspberrypi-kernel_1.20190215-1_armhf.deb')
  414. deb_hash = 'cd284220b32128c5084037553db3c482426f3972'
  415. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  416. kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img')
  417. dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb')
  418. initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
  419. '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
  420. 'arm/rootfs-armv7a.cpio.gz')
  421. initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
  422. initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
  423. initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
  424. archive.gzip_uncompress(initrd_path_gz, initrd_path)
  425. self.vm.set_console()
  426. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  427. 'earlycon=pl011,0x3f201000 console=ttyAMA0 '
  428. 'panic=-1 noreboot ' +
  429. 'dwc_otg.fiq_fsm_enable=0')
  430. self.vm.add_args('-kernel', kernel_path,
  431. '-dtb', dtb_path,
  432. '-initrd', initrd_path,
  433. '-append', kernel_command_line,
  434. '-no-reboot')
  435. self.vm.launch()
  436. self.wait_for_console_pattern('Boot successful.')
  437. exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
  438. 'BCM2835')
  439. exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
  440. '/soc/cprman@7e101000')
  441. exec_command(self, 'halt')
  442. # Wait for VM to shut down gracefully
  443. self.vm.wait()
  444. def test_arm_exynos4210_initrd(self):
  445. """
  446. :avocado: tags=arch:arm
  447. :avocado: tags=machine:smdkc210
  448. :avocado: tags=accel:tcg
  449. """
  450. deb_url = ('https://snapshot.debian.org/archive/debian/'
  451. '20190928T224601Z/pool/main/l/linux/'
  452. 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb')
  453. deb_hash = 'fa9df4a0d38936cb50084838f2cb933f570d7d82'
  454. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  455. kernel_path = self.extract_from_deb(deb_path,
  456. '/boot/vmlinuz-4.19.0-6-armmp')
  457. dtb_path = '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb'
  458. dtb_path = self.extract_from_deb(deb_path, dtb_path)
  459. initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
  460. '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
  461. 'arm/rootfs-armv5.cpio.gz')
  462. initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
  463. initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
  464. initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
  465. archive.gzip_uncompress(initrd_path_gz, initrd_path)
  466. self.vm.set_console()
  467. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  468. 'earlycon=exynos4210,0x13800000 earlyprintk ' +
  469. 'console=ttySAC0,115200n8 ' +
  470. 'random.trust_cpu=off cryptomgr.notests ' +
  471. 'cpuidle.off=1 panic=-1 noreboot')
  472. self.vm.add_args('-kernel', kernel_path,
  473. '-dtb', dtb_path,
  474. '-initrd', initrd_path,
  475. '-append', kernel_command_line,
  476. '-no-reboot')
  477. self.vm.launch()
  478. self.wait_for_console_pattern('Boot successful.')
  479. # TODO user command, for now the uart is stuck
  480. def test_arm_cubieboard_initrd(self):
  481. """
  482. :avocado: tags=arch:arm
  483. :avocado: tags=machine:cubieboard
  484. :avocado: tags=accel:tcg
  485. """
  486. deb_url = ('https://apt.armbian.com/pool/main/l/'
  487. 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
  488. deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
  489. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  490. kernel_path = self.extract_from_deb(deb_path,
  491. '/boot/vmlinuz-5.10.16-sunxi')
  492. dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
  493. dtb_path = self.extract_from_deb(deb_path, dtb_path)
  494. initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
  495. '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
  496. 'arm/rootfs-armv5.cpio.gz')
  497. initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
  498. initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
  499. initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
  500. archive.gzip_uncompress(initrd_path_gz, initrd_path)
  501. self.vm.set_console()
  502. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  503. 'console=ttyS0,115200 '
  504. 'usbcore.nousb '
  505. 'panic=-1 noreboot')
  506. self.vm.add_args('-kernel', kernel_path,
  507. '-dtb', dtb_path,
  508. '-initrd', initrd_path,
  509. '-append', kernel_command_line,
  510. '-no-reboot')
  511. self.vm.launch()
  512. self.wait_for_console_pattern('Boot successful.')
  513. exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
  514. 'Allwinner sun4i/sun5i')
  515. exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
  516. 'system-control@1c00000')
  517. # cubieboard's reboot is not functioning; omit reboot test.
  518. def test_arm_cubieboard_sata(self):
  519. """
  520. :avocado: tags=arch:arm
  521. :avocado: tags=machine:cubieboard
  522. :avocado: tags=accel:tcg
  523. """
  524. deb_url = ('https://apt.armbian.com/pool/main/l/'
  525. 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
  526. deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
  527. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  528. kernel_path = self.extract_from_deb(deb_path,
  529. '/boot/vmlinuz-5.10.16-sunxi')
  530. dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
  531. dtb_path = self.extract_from_deb(deb_path, dtb_path)
  532. rootfs_url = ('https://github.com/groeck/linux-build-test/raw/'
  533. '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
  534. 'arm/rootfs-armv5.ext2.gz')
  535. rootfs_hash = '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93'
  536. rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
  537. rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
  538. archive.gzip_uncompress(rootfs_path_gz, rootfs_path)
  539. self.vm.set_console()
  540. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  541. 'console=ttyS0,115200 '
  542. 'usbcore.nousb '
  543. 'root=/dev/sda ro '
  544. 'panic=-1 noreboot')
  545. self.vm.add_args('-kernel', kernel_path,
  546. '-dtb', dtb_path,
  547. '-drive', 'if=none,format=raw,id=disk0,file='
  548. + rootfs_path,
  549. '-device', 'ide-hd,bus=ide.0,drive=disk0',
  550. '-append', kernel_command_line,
  551. '-no-reboot')
  552. self.vm.launch()
  553. self.wait_for_console_pattern('Boot successful.')
  554. exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
  555. 'Allwinner sun4i/sun5i')
  556. exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
  557. 'sda')
  558. # cubieboard's reboot is not functioning; omit reboot test.
  559. @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
  560. def test_arm_quanta_gsj(self):
  561. """
  562. :avocado: tags=arch:arm
  563. :avocado: tags=machine:quanta-gsj
  564. :avocado: tags=accel:tcg
  565. """
  566. # 25 MiB compressed, 32 MiB uncompressed.
  567. image_url = (
  568. 'https://github.com/hskinnemoen/openbmc/releases/download/'
  569. '20200711-gsj-qemu-0/obmc-phosphor-image-gsj.static.mtd.gz')
  570. image_hash = '14895e634923345cb5c8776037ff7876df96f6b1'
  571. image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash)
  572. image_name = 'obmc.mtd'
  573. image_path = os.path.join(self.workdir, image_name)
  574. archive.gzip_uncompress(image_path_gz, image_path)
  575. self.vm.set_console()
  576. drive_args = 'file=' + image_path + ',if=mtd,bus=0,unit=0'
  577. self.vm.add_args('-drive', drive_args)
  578. self.vm.launch()
  579. # Disable drivers and services that stall for a long time during boot,
  580. # to avoid running past the 90-second timeout. These may be removed
  581. # as the corresponding device support is added.
  582. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + (
  583. 'console=${console} '
  584. 'mem=${mem} '
  585. 'initcall_blacklist=npcm_i2c_bus_driver_init '
  586. 'systemd.mask=systemd-random-seed.service '
  587. 'systemd.mask=dropbearkey.service '
  588. )
  589. self.wait_for_console_pattern('> BootBlock by Nuvoton')
  590. self.wait_for_console_pattern('>Device: Poleg BMC NPCM730')
  591. self.wait_for_console_pattern('>Skip DDR init.')
  592. self.wait_for_console_pattern('U-Boot ')
  593. interrupt_interactive_console_until_pattern(
  594. self, 'Hit any key to stop autoboot:', 'U-Boot>')
  595. exec_command_and_wait_for_pattern(
  596. self, "setenv bootargs ${bootargs} " + kernel_command_line,
  597. 'U-Boot>')
  598. exec_command_and_wait_for_pattern(
  599. self, 'run romboot', 'Booting Kernel from flash')
  600. self.wait_for_console_pattern('Booting Linux on physical CPU 0x0')
  601. self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0')
  602. self.wait_for_console_pattern('OpenBMC Project Reference Distro')
  603. self.wait_for_console_pattern('gsj login:')
  604. def test_arm_quanta_gsj_initrd(self):
  605. """
  606. :avocado: tags=arch:arm
  607. :avocado: tags=machine:quanta-gsj
  608. :avocado: tags=accel:tcg
  609. """
  610. initrd_url = (
  611. 'https://github.com/hskinnemoen/openbmc/releases/download/'
  612. '20200711-gsj-qemu-0/obmc-phosphor-initramfs-gsj.cpio.xz')
  613. initrd_hash = '98fefe5d7e56727b1eb17d5c00311b1b5c945300'
  614. initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
  615. kernel_url = (
  616. 'https://github.com/hskinnemoen/openbmc/releases/download/'
  617. '20200711-gsj-qemu-0/uImage-gsj.bin')
  618. kernel_hash = 'fa67b2f141d56d39b3c54305c0e8a899c99eb2c7'
  619. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  620. dtb_url = (
  621. 'https://github.com/hskinnemoen/openbmc/releases/download/'
  622. '20200711-gsj-qemu-0/nuvoton-npcm730-gsj.dtb')
  623. dtb_hash = '18315f7006d7b688d8312d5c727eecd819aa36a4'
  624. dtb_path = self.fetch_asset(dtb_url, asset_hash=dtb_hash)
  625. self.vm.set_console()
  626. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  627. 'console=ttyS0,115200n8 '
  628. 'earlycon=uart8250,mmio32,0xf0001000')
  629. self.vm.add_args('-kernel', kernel_path,
  630. '-initrd', initrd_path,
  631. '-dtb', dtb_path,
  632. '-append', kernel_command_line)
  633. self.vm.launch()
  634. self.wait_for_console_pattern('Booting Linux on physical CPU 0x0')
  635. self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0')
  636. self.wait_for_console_pattern(
  637. 'Give root password for system maintenance')
  638. def test_arm_orangepi(self):
  639. """
  640. :avocado: tags=arch:arm
  641. :avocado: tags=machine:orangepi-pc
  642. :avocado: tags=accel:tcg
  643. """
  644. deb_url = ('https://apt.armbian.com/pool/main/l/'
  645. 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
  646. deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
  647. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  648. kernel_path = self.extract_from_deb(deb_path,
  649. '/boot/vmlinuz-5.10.16-sunxi')
  650. dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
  651. dtb_path = self.extract_from_deb(deb_path, dtb_path)
  652. self.vm.set_console()
  653. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  654. 'console=ttyS0,115200n8 '
  655. 'earlycon=uart,mmio32,0x1c28000')
  656. self.vm.add_args('-kernel', kernel_path,
  657. '-dtb', dtb_path,
  658. '-append', kernel_command_line)
  659. self.vm.launch()
  660. console_pattern = 'Kernel command line: %s' % kernel_command_line
  661. self.wait_for_console_pattern(console_pattern)
  662. def test_arm_orangepi_initrd(self):
  663. """
  664. :avocado: tags=arch:arm
  665. :avocado: tags=accel:tcg
  666. :avocado: tags=machine:orangepi-pc
  667. """
  668. deb_url = ('https://apt.armbian.com/pool/main/l/'
  669. 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
  670. deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
  671. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  672. kernel_path = self.extract_from_deb(deb_path,
  673. '/boot/vmlinuz-5.10.16-sunxi')
  674. dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
  675. dtb_path = self.extract_from_deb(deb_path, dtb_path)
  676. initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
  677. '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
  678. 'arm/rootfs-armv7a.cpio.gz')
  679. initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
  680. initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
  681. initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
  682. archive.gzip_uncompress(initrd_path_gz, initrd_path)
  683. self.vm.set_console()
  684. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  685. 'console=ttyS0,115200 '
  686. 'panic=-1 noreboot')
  687. self.vm.add_args('-kernel', kernel_path,
  688. '-dtb', dtb_path,
  689. '-initrd', initrd_path,
  690. '-append', kernel_command_line,
  691. '-no-reboot')
  692. self.vm.launch()
  693. self.wait_for_console_pattern('Boot successful.')
  694. exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
  695. 'Allwinner sun8i Family')
  696. exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
  697. 'system-control@1c00000')
  698. exec_command_and_wait_for_pattern(self, 'reboot',
  699. 'reboot: Restarting system')
  700. # Wait for VM to shut down gracefully
  701. self.vm.wait()
  702. def test_arm_orangepi_sd(self):
  703. """
  704. :avocado: tags=arch:arm
  705. :avocado: tags=accel:tcg
  706. :avocado: tags=machine:orangepi-pc
  707. :avocado: tags=device:sd
  708. """
  709. deb_url = ('https://apt.armbian.com/pool/main/l/'
  710. 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
  711. deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
  712. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  713. kernel_path = self.extract_from_deb(deb_path,
  714. '/boot/vmlinuz-5.10.16-sunxi')
  715. dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
  716. dtb_path = self.extract_from_deb(deb_path, dtb_path)
  717. rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/'
  718. 'kci-2019.02/armel/base/rootfs.ext2.xz')
  719. rootfs_hash = '692510cb625efda31640d1de0a8d60e26040f061'
  720. rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
  721. rootfs_path = os.path.join(self.workdir, 'rootfs.cpio')
  722. archive.lzma_uncompress(rootfs_path_xz, rootfs_path)
  723. image_pow2ceil_expand(rootfs_path)
  724. self.vm.set_console()
  725. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  726. 'console=ttyS0,115200 '
  727. 'root=/dev/mmcblk0 rootwait rw '
  728. 'panic=-1 noreboot')
  729. self.vm.add_args('-kernel', kernel_path,
  730. '-dtb', dtb_path,
  731. '-drive', 'file=' + rootfs_path + ',if=sd,format=raw',
  732. '-append', kernel_command_line,
  733. '-no-reboot')
  734. self.vm.launch()
  735. shell_ready = "/bin/sh: can't access tty; job control turned off"
  736. self.wait_for_console_pattern(shell_ready)
  737. exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
  738. 'Allwinner sun8i Family')
  739. exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
  740. 'mmcblk0')
  741. exec_command_and_wait_for_pattern(self, 'ifconfig eth0 up',
  742. 'eth0: Link is Up')
  743. exec_command_and_wait_for_pattern(self, 'udhcpc eth0',
  744. 'udhcpc: lease of 10.0.2.15 obtained')
  745. exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
  746. '3 packets transmitted, 3 packets received, 0% packet loss')
  747. exec_command_and_wait_for_pattern(self, 'reboot',
  748. 'reboot: Restarting system')
  749. # Wait for VM to shut down gracefully
  750. self.vm.wait()
  751. @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
  752. def test_arm_orangepi_bionic_20_08(self):
  753. """
  754. :avocado: tags=arch:arm
  755. :avocado: tags=machine:orangepi-pc
  756. :avocado: tags=device:sd
  757. """
  758. # This test download a 275 MiB compressed image and expand it
  759. # to 1036 MiB, but the underlying filesystem is 1552 MiB...
  760. # As we expand it to 2 GiB we are safe.
  761. image_url = ('https://archive.armbian.com/orangepipc/archive/'
  762. 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
  763. image_hash = ('b4d6775f5673486329e45a0586bf06b6'
  764. 'dbe792199fd182ac6b9c7bb6c7d3e6dd')
  765. image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
  766. algorithm='sha256')
  767. image_path = archive.extract(image_path_xz, self.workdir)
  768. image_pow2ceil_expand(image_path)
  769. self.vm.set_console()
  770. self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
  771. '-nic', 'user',
  772. '-no-reboot')
  773. self.vm.launch()
  774. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  775. 'console=ttyS0,115200 '
  776. 'loglevel=7 '
  777. 'nosmp '
  778. 'systemd.default_timeout_start_sec=9000 '
  779. 'systemd.mask=armbian-zram-config.service '
  780. 'systemd.mask=armbian-ramlog.service')
  781. self.wait_for_console_pattern('U-Boot SPL')
  782. self.wait_for_console_pattern('Autoboot in ')
  783. exec_command_and_wait_for_pattern(self, ' ', '=>')
  784. exec_command_and_wait_for_pattern(self, "setenv extraargs '" +
  785. kernel_command_line + "'", '=>')
  786. exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...');
  787. self.wait_for_console_pattern('systemd[1]: Set hostname ' +
  788. 'to <orangepipc>')
  789. self.wait_for_console_pattern('Starting Load Kernel Modules...')
  790. @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
  791. def test_arm_orangepi_uboot_netbsd9(self):
  792. """
  793. :avocado: tags=arch:arm
  794. :avocado: tags=machine:orangepi-pc
  795. :avocado: tags=device:sd
  796. :avocado: tags=os:netbsd
  797. """
  798. # This test download a 304MB compressed image and expand it to 2GB
  799. deb_url = ('http://snapshot.debian.org/archive/debian/'
  800. '20200108T145233Z/pool/main/u/u-boot/'
  801. 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
  802. deb_hash = 'f67f404a80753ca3d1258f13e38f2b060e13db99'
  803. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  804. # We use the common OrangePi PC 'plus' build of U-Boot for our secondary
  805. # program loader (SPL). We will then set the path to the more specific
  806. # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt,
  807. # before to boot NetBSD.
  808. uboot_path = '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin'
  809. uboot_path = self.extract_from_deb(deb_path, uboot_path)
  810. image_url = ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/'
  811. 'evbarm-earmv7hf/binary/gzimg/armv7.img.gz')
  812. image_hash = '2babb29d36d8360adcb39c09e31060945259917a'
  813. image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash)
  814. image_path = os.path.join(self.workdir, 'armv7.img')
  815. archive.gzip_uncompress(image_path_gz, image_path)
  816. image_pow2ceil_expand(image_path)
  817. image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path
  818. # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc
  819. with open(uboot_path, 'rb') as f_in:
  820. with open(image_path, 'r+b') as f_out:
  821. f_out.seek(8 * 1024)
  822. shutil.copyfileobj(f_in, f_out)
  823. self.vm.set_console()
  824. self.vm.add_args('-nic', 'user',
  825. '-drive', image_drive_args,
  826. '-global', 'allwinner-rtc.base-year=2000',
  827. '-no-reboot')
  828. self.vm.launch()
  829. wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1')
  830. interrupt_interactive_console_until_pattern(self,
  831. 'Hit any key to stop autoboot:',
  832. 'switch to partitions #0, OK')
  833. exec_command_and_wait_for_pattern(self, '', '=>')
  834. cmd = 'setenv bootargs root=ld0a'
  835. exec_command_and_wait_for_pattern(self, cmd, '=>')
  836. cmd = 'setenv kernel netbsd-GENERIC.ub'
  837. exec_command_and_wait_for_pattern(self, cmd, '=>')
  838. cmd = 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb'
  839. exec_command_and_wait_for_pattern(self, cmd, '=>')
  840. cmd = ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; "
  841. "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; "
  842. "fdt addr ${fdt_addr_r}; "
  843. "bootm ${kernel_addr_r} - ${fdt_addr_r}'")
  844. exec_command_and_wait_for_pattern(self, cmd, '=>')
  845. exec_command_and_wait_for_pattern(self, 'boot',
  846. 'Booting kernel from Legacy Image')
  847. wait_for_console_pattern(self, 'Starting kernel ...')
  848. wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)')
  849. # Wait for user-space
  850. wait_for_console_pattern(self, 'Starting root file system check')
  851. def test_aarch64_raspi3_atf(self):
  852. """
  853. :avocado: tags=arch:aarch64
  854. :avocado: tags=machine:raspi3b
  855. :avocado: tags=cpu:cortex-a53
  856. :avocado: tags=device:pl011
  857. :avocado: tags=atf
  858. """
  859. zip_url = ('https://github.com/pbatard/RPi3/releases/download/'
  860. 'v1.15/RPi3_UEFI_Firmware_v1.15.zip')
  861. zip_hash = '74b3bd0de92683cadb14e008a7575e1d0c3cafb9'
  862. zip_path = self.fetch_asset(zip_url, asset_hash=zip_hash)
  863. archive.extract(zip_path, self.workdir)
  864. efi_fd = os.path.join(self.workdir, 'RPI_EFI.fd')
  865. self.vm.set_console(console_index=1)
  866. self.vm.add_args('-nodefaults',
  867. '-device', 'loader,file=%s,force-raw=true' % efi_fd)
  868. self.vm.launch()
  869. self.wait_for_console_pattern('version UEFI Firmware v1.15')
  870. def test_s390x_s390_ccw_virtio(self):
  871. """
  872. :avocado: tags=arch:s390x
  873. :avocado: tags=machine:s390-ccw-virtio
  874. """
  875. kernel_url = ('https://archives.fedoraproject.org/pub/archive'
  876. '/fedora-secondary/releases/29/Everything/s390x/os/images'
  877. '/kernel.img')
  878. kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
  879. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  880. self.vm.set_console()
  881. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
  882. self.vm.add_args('-nodefaults',
  883. '-kernel', kernel_path,
  884. '-append', kernel_command_line)
  885. self.vm.launch()
  886. console_pattern = 'Kernel command line: %s' % kernel_command_line
  887. self.wait_for_console_pattern(console_pattern)
  888. def test_alpha_clipper(self):
  889. """
  890. :avocado: tags=arch:alpha
  891. :avocado: tags=machine:clipper
  892. """
  893. kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/'
  894. 'installer-alpha/20090123lenny10/images/cdrom/vmlinuz')
  895. kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3'
  896. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  897. uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
  898. self.vm.set_console()
  899. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
  900. self.vm.add_args('-nodefaults',
  901. '-kernel', uncompressed_kernel,
  902. '-append', kernel_command_line)
  903. self.vm.launch()
  904. console_pattern = 'Kernel command line: %s' % kernel_command_line
  905. self.wait_for_console_pattern(console_pattern)
  906. def test_m68k_q800(self):
  907. """
  908. :avocado: tags=arch:m68k
  909. :avocado: tags=machine:q800
  910. """
  911. deb_url = ('https://snapshot.debian.org/archive/debian-ports'
  912. '/20191021T083923Z/pool-m68k/main'
  913. '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
  914. deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
  915. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  916. kernel_path = self.extract_from_deb(deb_path,
  917. '/boot/vmlinux-5.3.0-1-m68k')
  918. self.vm.set_console()
  919. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  920. 'console=ttyS0 vga=off')
  921. self.vm.add_args('-kernel', kernel_path,
  922. '-append', kernel_command_line)
  923. self.vm.launch()
  924. console_pattern = 'Kernel command line: %s' % kernel_command_line
  925. self.wait_for_console_pattern(console_pattern)
  926. console_pattern = 'No filesystem could mount root'
  927. self.wait_for_console_pattern(console_pattern)
  928. def do_test_advcal_2018(self, day, tar_hash, kernel_name, console=0):
  929. tar_url = ('https://www.qemu-advent-calendar.org'
  930. '/2018/download/day' + day + '.tar.xz')
  931. file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
  932. archive.extract(file_path, self.workdir)
  933. self.vm.set_console(console_index=console)
  934. self.vm.add_args('-kernel',
  935. self.workdir + '/day' + day + '/' + kernel_name)
  936. self.vm.launch()
  937. self.wait_for_console_pattern('QEMU advent calendar')
  938. def test_arm_vexpressa9(self):
  939. """
  940. :avocado: tags=arch:arm
  941. :avocado: tags=machine:vexpress-a9
  942. """
  943. tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b'
  944. self.vm.add_args('-dtb', self.workdir + '/day16/vexpress-v2p-ca9.dtb')
  945. self.do_test_advcal_2018('16', tar_hash, 'winter.zImage')
  946. def test_arm_ast2400_palmetto_openbmc_v2_9_0(self):
  947. """
  948. :avocado: tags=arch:arm
  949. :avocado: tags=machine:palmetto-bmc
  950. """
  951. image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
  952. 'obmc-phosphor-image-palmetto.static.mtd')
  953. image_hash = ('3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d')
  954. image_path = self.fetch_asset(image_url, asset_hash=image_hash,
  955. algorithm='sha256')
  956. self.do_test_arm_aspeed(image_path)
  957. def test_arm_ast2500_romulus_openbmc_v2_9_0(self):
  958. """
  959. :avocado: tags=arch:arm
  960. :avocado: tags=machine:romulus-bmc
  961. """
  962. image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
  963. 'obmc-phosphor-image-romulus.static.mtd')
  964. image_hash = ('820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25')
  965. image_path = self.fetch_asset(image_url, asset_hash=image_hash,
  966. algorithm='sha256')
  967. self.do_test_arm_aspeed(image_path)
  968. def do_test_arm_aspeed(self, image):
  969. self.vm.set_console()
  970. self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
  971. '-net', 'nic')
  972. self.vm.launch()
  973. self.wait_for_console_pattern("U-Boot 2016.07")
  974. self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000")
  975. self.wait_for_console_pattern("Starting kernel ...")
  976. self.wait_for_console_pattern("Booting Linux on physical CPU 0x0")
  977. self.wait_for_console_pattern(
  978. "aspeed-smc 1e620000.spi: read control register: 203b0641")
  979. self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ")
  980. self.wait_for_console_pattern("systemd[1]: Set hostname to")
  981. def test_arm_ast2600_debian(self):
  982. """
  983. :avocado: tags=arch:arm
  984. :avocado: tags=machine:tacoma-bmc
  985. """
  986. deb_url = ('http://snapshot.debian.org/archive/debian/'
  987. '20210302T203551Z/'
  988. 'pool/main/l/linux/'
  989. 'linux-image-5.10.0-3-armmp_5.10.13-1_armhf.deb')
  990. deb_hash = 'db40d32fe39255d05482bea48d72467b67d6225bb2a2a4d6f618cb8976f1e09e'
  991. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash,
  992. algorithm='sha256')
  993. kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.10.0-3-armmp')
  994. dtb_path = self.extract_from_deb(deb_path,
  995. '/usr/lib/linux-image-5.10.0-3-armmp/aspeed-bmc-opp-tacoma.dtb')
  996. self.vm.set_console()
  997. self.vm.add_args('-kernel', kernel_path,
  998. '-dtb', dtb_path,
  999. '-net', 'nic')
  1000. self.vm.launch()
  1001. self.wait_for_console_pattern("Booting Linux on physical CPU 0xf00")
  1002. self.wait_for_console_pattern("SMP: Total of 2 processors activated")
  1003. self.wait_for_console_pattern("No filesystem could mount root")
  1004. def test_m68k_mcf5208evb(self):
  1005. """
  1006. :avocado: tags=arch:m68k
  1007. :avocado: tags=machine:mcf5208evb
  1008. """
  1009. tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
  1010. self.do_test_advcal_2018('07', tar_hash, 'sanity-clause.elf')
  1011. def test_or1k_sim(self):
  1012. """
  1013. :avocado: tags=arch:or1k
  1014. :avocado: tags=machine:or1k-sim
  1015. """
  1016. tar_hash = '20334cdaf386108c530ff0badaecc955693027dd'
  1017. self.do_test_advcal_2018('20', tar_hash, 'vmlinux')
  1018. def test_nios2_10m50(self):
  1019. """
  1020. :avocado: tags=arch:nios2
  1021. :avocado: tags=machine:10m50-ghrd
  1022. """
  1023. tar_hash = 'e4251141726c412ac0407c5a6bceefbbff018918'
  1024. self.do_test_advcal_2018('14', tar_hash, 'vmlinux.elf')
  1025. def test_ppc64_e500(self):
  1026. """
  1027. :avocado: tags=arch:ppc64
  1028. :avocado: tags=machine:ppce500
  1029. :avocado: tags=cpu:e5500
  1030. :avocado: tags=accel:tcg
  1031. """
  1032. self.require_accelerator("tcg")
  1033. tar_hash = '6951d86d644b302898da2fd701739c9406527fe1'
  1034. self.do_test_advcal_2018('19', tar_hash, 'uImage')
  1035. def do_test_ppc64_powernv(self, proc):
  1036. self.require_accelerator("tcg")
  1037. images_url = ('https://github.com/open-power/op-build/releases/download/v2.7/')
  1038. kernel_url = images_url + 'zImage.epapr'
  1039. kernel_hash = '0ab237df661727e5392cee97460e8674057a883c5f74381a128fa772588d45cd'
  1040. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash,
  1041. algorithm='sha256')
  1042. self.vm.set_console()
  1043. self.vm.add_args('-kernel', kernel_path,
  1044. '-append', 'console=tty0 console=hvc0',
  1045. '-device', 'pcie-pci-bridge,id=bridge1,bus=pcie.1,addr=0x0',
  1046. '-device', 'nvme,bus=pcie.2,addr=0x0,serial=1234',
  1047. '-device', 'e1000e,bus=bridge1,addr=0x3',
  1048. '-device', 'nec-usb-xhci,bus=bridge1,addr=0x2')
  1049. self.vm.launch()
  1050. self.wait_for_console_pattern("CPU: " + proc + " generation processor")
  1051. self.wait_for_console_pattern("zImage starting: loaded")
  1052. self.wait_for_console_pattern("Run /init as init process")
  1053. self.wait_for_console_pattern("Creating 1 MTD partitions")
  1054. def test_ppc_powernv8(self):
  1055. """
  1056. :avocado: tags=arch:ppc64
  1057. :avocado: tags=machine:powernv8
  1058. :avocado: tags=accel:tcg
  1059. """
  1060. self.do_test_ppc64_powernv('P8')
  1061. def test_ppc_powernv9(self):
  1062. """
  1063. :avocado: tags=arch:ppc64
  1064. :avocado: tags=machine:powernv9
  1065. :avocado: tags=accel:tcg
  1066. """
  1067. self.do_test_ppc64_powernv('P9')
  1068. def test_ppc_g3beige(self):
  1069. """
  1070. :avocado: tags=arch:ppc
  1071. :avocado: tags=machine:g3beige
  1072. :avocado: tags=accel:tcg
  1073. """
  1074. # TODO: g3beige works with kvm_pr but we don't have a
  1075. # reliable way ATM (e.g. looking at /proc/modules) to detect
  1076. # whether we're running kvm_hv or kvm_pr. For now let's
  1077. # disable this test if we don't have TCG support.
  1078. self.require_accelerator("tcg")
  1079. tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
  1080. self.vm.add_args('-M', 'graphics=off')
  1081. self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
  1082. def test_ppc_mac99(self):
  1083. """
  1084. :avocado: tags=arch:ppc
  1085. :avocado: tags=machine:mac99
  1086. :avocado: tags=accel:tcg
  1087. """
  1088. # TODO: mac99 works with kvm_pr but we don't have a
  1089. # reliable way ATM (e.g. looking at /proc/modules) to detect
  1090. # whether we're running kvm_hv or kvm_pr. For now let's
  1091. # disable this test if we don't have TCG support.
  1092. self.require_accelerator("tcg")
  1093. tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
  1094. self.vm.add_args('-M', 'graphics=off')
  1095. self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')
  1096. def test_sh4_r2d(self):
  1097. """
  1098. :avocado: tags=arch:sh4
  1099. :avocado: tags=machine:r2d
  1100. """
  1101. tar_hash = 'fe06a4fd8ccbf2e27928d64472939d47829d4c7e'
  1102. self.vm.add_args('-append', 'console=ttySC1')
  1103. self.do_test_advcal_2018('09', tar_hash, 'zImage', console=1)
  1104. def test_sparc_ss20(self):
  1105. """
  1106. :avocado: tags=arch:sparc
  1107. :avocado: tags=machine:SS-20
  1108. """
  1109. tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
  1110. self.do_test_advcal_2018('11', tar_hash, 'zImage.elf')
  1111. def test_xtensa_lx60(self):
  1112. """
  1113. :avocado: tags=arch:xtensa
  1114. :avocado: tags=machine:lx60
  1115. :avocado: tags=cpu:dc233c
  1116. """
  1117. tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34'
  1118. self.do_test_advcal_2018('02', tar_hash, 'santas-sleigh-ride.elf')