boot_linux_console.py 56 KB

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