boot_linux_console.py 70 KB

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