2
0

replay_kernel.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. # Record/replay test that boots a Linux kernel
  2. #
  3. # Copyright (c) 2020 ISP RAS
  4. #
  5. # Author:
  6. # Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
  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 shutil
  13. import logging
  14. import time
  15. import subprocess
  16. from avocado import skip
  17. from avocado import skipUnless
  18. from avocado import skipUnless
  19. from avocado_qemu import wait_for_console_pattern
  20. from avocado.utils import archive
  21. from avocado.utils import process
  22. from boot_linux_console import LinuxKernelTest
  23. class ReplayKernelBase(LinuxKernelTest):
  24. """
  25. Boots a Linux kernel in record mode and checks that the console
  26. is operational and the kernel command line is properly passed
  27. from QEMU to the kernel.
  28. Then replays the same scenario and verifies, that QEMU correctly
  29. terminates.
  30. """
  31. timeout = 180
  32. KERNEL_COMMON_COMMAND_LINE = 'printk.time=1 panic=-1 '
  33. def run_vm(self, kernel_path, kernel_command_line, console_pattern,
  34. record, shift, args, replay_path):
  35. # icount requires TCG to be available
  36. self.require_accelerator('tcg')
  37. logger = logging.getLogger('replay')
  38. start_time = time.time()
  39. vm = self.get_vm()
  40. vm.set_console()
  41. if record:
  42. logger.info('recording the execution...')
  43. mode = 'record'
  44. else:
  45. logger.info('replaying the execution...')
  46. mode = 'replay'
  47. vm.add_args('-icount', 'shift=%s,rr=%s,rrfile=%s' %
  48. (shift, mode, replay_path),
  49. '-kernel', kernel_path,
  50. '-append', kernel_command_line,
  51. '-net', 'none',
  52. '-no-reboot')
  53. if args:
  54. vm.add_args(*args)
  55. vm.launch()
  56. self.wait_for_console_pattern(console_pattern, vm)
  57. if record:
  58. vm.shutdown()
  59. logger.info('finished the recording with log size %s bytes'
  60. % os.path.getsize(replay_path))
  61. self.run_replay_dump(replay_path)
  62. logger.info('successfully tested replay-dump.py')
  63. else:
  64. vm.wait()
  65. logger.info('successfully finished the replay')
  66. elapsed = time.time() - start_time
  67. logger.info('elapsed time %.2f sec' % elapsed)
  68. return elapsed
  69. def run_replay_dump(self, replay_path):
  70. try:
  71. subprocess.check_call(["./scripts/replay-dump.py",
  72. "-f", replay_path],
  73. stdout=subprocess.DEVNULL)
  74. except subprocess.CalledProcessError:
  75. self.fail('replay-dump.py failed')
  76. def run_rr(self, kernel_path, kernel_command_line, console_pattern,
  77. shift=7, args=None):
  78. replay_path = os.path.join(self.workdir, 'replay.bin')
  79. t1 = self.run_vm(kernel_path, kernel_command_line, console_pattern,
  80. True, shift, args, replay_path)
  81. t2 = self.run_vm(kernel_path, kernel_command_line, console_pattern,
  82. False, shift, args, replay_path)
  83. logger = logging.getLogger('replay')
  84. logger.info('replay overhead {:.2%}'.format(t2 / t1 - 1))
  85. class ReplayKernelNormal(ReplayKernelBase):
  86. def test_i386_pc(self):
  87. """
  88. :avocado: tags=arch:i386
  89. :avocado: tags=machine:pc
  90. """
  91. kernel_url = ('https://storage.tuxboot.com/20230331/i386/bzImage')
  92. kernel_hash = 'a3e5b32a354729e65910f5a1ffcda7c14a6c12a55e8213fb86e277f1b76ed956'
  93. kernel_path = self.fetch_asset(kernel_url,
  94. asset_hash=kernel_hash,
  95. algorithm = "sha256")
  96. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
  97. console_pattern = 'VFS: Cannot open root device'
  98. self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
  99. # See https://gitlab.com/qemu-project/qemu/-/issues/2094
  100. @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test sometimes gets stuck')
  101. def test_x86_64_pc(self):
  102. """
  103. :avocado: tags=arch:x86_64
  104. :avocado: tags=machine:pc
  105. :avocado: tags=flaky
  106. """
  107. kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
  108. '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
  109. '/vmlinuz')
  110. kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
  111. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  112. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
  113. console_pattern = 'VFS: Cannot open root device'
  114. self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
  115. def test_mips_malta(self):
  116. """
  117. :avocado: tags=arch:mips
  118. :avocado: tags=machine:malta
  119. :avocado: tags=endian:big
  120. """
  121. deb_url = ('http://snapshot.debian.org/archive/debian/'
  122. '20130217T032700Z/pool/main/l/linux-2.6/'
  123. 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
  124. deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
  125. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  126. kernel_path = self.extract_from_deb(deb_path,
  127. '/boot/vmlinux-2.6.32-5-4kc-malta')
  128. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
  129. console_pattern = 'Kernel command line: %s' % kernel_command_line
  130. self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
  131. def test_mips64el_malta(self):
  132. """
  133. This test requires the ar tool to extract "data.tar.gz" from
  134. the Debian package.
  135. The kernel can be rebuilt using this Debian kernel source [1] and
  136. following the instructions on [2].
  137. [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
  138. #linux-source-2.6.32_2.6.32-48
  139. [2] https://kernel-team.pages.debian.net/kernel-handbook/
  140. ch-common-tasks.html#s-common-official
  141. :avocado: tags=arch:mips64el
  142. :avocado: tags=machine:malta
  143. """
  144. deb_url = ('http://snapshot.debian.org/archive/debian/'
  145. '20130217T032700Z/pool/main/l/linux-2.6/'
  146. 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
  147. deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
  148. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  149. kernel_path = self.extract_from_deb(deb_path,
  150. '/boot/vmlinux-2.6.32-5-5kc-malta')
  151. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
  152. console_pattern = 'Kernel command line: %s' % kernel_command_line
  153. self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
  154. def test_aarch64_virt(self):
  155. """
  156. :avocado: tags=arch:aarch64
  157. :avocado: tags=machine:virt
  158. :avocado: tags=cpu:cortex-a53
  159. """
  160. kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
  161. '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
  162. '/vmlinuz')
  163. kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'
  164. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  165. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  166. 'console=ttyAMA0')
  167. console_pattern = 'VFS: Cannot open root device'
  168. self.run_rr(kernel_path, kernel_command_line, console_pattern)
  169. def test_arm_virt(self):
  170. """
  171. :avocado: tags=arch:arm
  172. :avocado: tags=machine:virt
  173. """
  174. kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
  175. '/linux/releases/29/Everything/armhfp/os/images/pxeboot'
  176. '/vmlinuz')
  177. kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
  178. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  179. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  180. 'console=ttyAMA0')
  181. console_pattern = 'VFS: Cannot open root device'
  182. self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1)
  183. def test_arm_cubieboard_initrd(self):
  184. """
  185. :avocado: tags=arch:arm
  186. :avocado: tags=machine:cubieboard
  187. """
  188. deb_url = ('https://apt.armbian.com/pool/main/l/'
  189. 'linux-6.6.16/linux-image-current-sunxi_24.2.1_armhf__6.6.16-Seb3e-D6b4a-P2359-Ce96bHfe66-HK01ba-V014b-B067e-R448a.deb')
  190. deb_hash = 'f7c3c8c5432f765445dc6e7eab02f3bbe668256b'
  191. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  192. kernel_path = self.extract_from_deb(deb_path,
  193. '/boot/vmlinuz-6.6.16-current-sunxi')
  194. dtb_path = '/usr/lib/linux-image-6.6.16-current-sunxi/sun4i-a10-cubieboard.dtb'
  195. dtb_path = self.extract_from_deb(deb_path, dtb_path)
  196. initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
  197. '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
  198. 'arm/rootfs-armv5.cpio.gz')
  199. initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b'
  200. initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
  201. initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
  202. archive.gzip_uncompress(initrd_path_gz, initrd_path)
  203. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  204. 'console=ttyS0,115200 '
  205. 'usbcore.nousb '
  206. 'panic=-1 noreboot')
  207. console_pattern = 'Boot successful.'
  208. self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1,
  209. args=('-dtb', dtb_path,
  210. '-initrd', initrd_path,
  211. '-no-reboot'))
  212. def test_s390x_s390_ccw_virtio(self):
  213. """
  214. :avocado: tags=arch:s390x
  215. :avocado: tags=machine:s390-ccw-virtio
  216. """
  217. kernel_url = ('https://archives.fedoraproject.org/pub/archive'
  218. '/fedora-secondary/releases/29/Everything/s390x/os/images'
  219. '/kernel.img')
  220. kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
  221. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  222. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
  223. console_pattern = 'Kernel command line: %s' % kernel_command_line
  224. self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=9)
  225. def test_alpha_clipper(self):
  226. """
  227. :avocado: tags=arch:alpha
  228. :avocado: tags=machine:clipper
  229. """
  230. kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/'
  231. 'installer-alpha/20090123lenny10/images/cdrom/vmlinuz')
  232. kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3'
  233. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  234. uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
  235. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
  236. console_pattern = 'Kernel command line: %s' % kernel_command_line
  237. self.run_rr(uncompressed_kernel, kernel_command_line, console_pattern, shift=9,
  238. args=('-nodefaults', ))
  239. def test_ppc64_pseries(self):
  240. """
  241. :avocado: tags=arch:ppc64
  242. :avocado: tags=machine:pseries
  243. :avocado: tags=accel:tcg
  244. """
  245. kernel_url = ('https://archives.fedoraproject.org/pub/archive'
  246. '/fedora-secondary/releases/29/Everything/ppc64le/os'
  247. '/ppc/ppc64/vmlinuz')
  248. kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
  249. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  250. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0'
  251. console_pattern = 'VFS: Cannot open root device'
  252. self.run_rr(kernel_path, kernel_command_line, console_pattern)
  253. def test_ppc64_powernv(self):
  254. """
  255. :avocado: tags=arch:ppc64
  256. :avocado: tags=machine:powernv
  257. :avocado: tags=accel:tcg
  258. """
  259. kernel_url = ('https://archives.fedoraproject.org/pub/archive'
  260. '/fedora-secondary/releases/29/Everything/ppc64le/os'
  261. '/ppc/ppc64/vmlinuz')
  262. kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
  263. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  264. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + \
  265. 'console=tty0 console=hvc0'
  266. console_pattern = 'VFS: Cannot open root device'
  267. self.run_rr(kernel_path, kernel_command_line, console_pattern)
  268. def test_m68k_q800(self):
  269. """
  270. :avocado: tags=arch:m68k
  271. :avocado: tags=machine:q800
  272. """
  273. deb_url = ('https://snapshot.debian.org/archive/debian-ports'
  274. '/20191021T083923Z/pool-m68k/main'
  275. '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb')
  276. deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1'
  277. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  278. kernel_path = self.extract_from_deb(deb_path,
  279. '/boot/vmlinux-5.3.0-1-m68k')
  280. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  281. 'console=ttyS0 vga=off')
  282. console_pattern = 'No filesystem could mount root'
  283. self.run_rr(kernel_path, kernel_command_line, console_pattern)
  284. def do_test_advcal_2018(self, file_path, kernel_name, args=None):
  285. archive.extract(file_path, self.workdir)
  286. for entry in os.scandir(self.workdir):
  287. if entry.name.startswith('day') and entry.is_dir():
  288. kernel_path = os.path.join(entry.path, kernel_name)
  289. break
  290. kernel_command_line = ''
  291. console_pattern = 'QEMU advent calendar'
  292. self.run_rr(kernel_path, kernel_command_line, console_pattern,
  293. args=args)
  294. def test_arm_vexpressa9(self):
  295. """
  296. :avocado: tags=arch:arm
  297. :avocado: tags=machine:vexpress-a9
  298. """
  299. tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b'
  300. tar_url = ('https://qemu-advcal.gitlab.io'
  301. '/qac-best-of-multiarch/download/day16.tar.xz')
  302. file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
  303. dtb_path = self.workdir + '/day16/vexpress-v2p-ca9.dtb'
  304. self.do_test_advcal_2018(file_path, 'winter.zImage',
  305. args=('-dtb', dtb_path))
  306. def test_m68k_mcf5208evb(self):
  307. """
  308. :avocado: tags=arch:m68k
  309. :avocado: tags=machine:mcf5208evb
  310. """
  311. tar_hash = 'ac688fd00561a2b6ce1359f9ff6aa2b98c9a570c'
  312. tar_url = ('https://qemu-advcal.gitlab.io'
  313. '/qac-best-of-multiarch/download/day07.tar.xz')
  314. file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
  315. self.do_test_advcal_2018(file_path, 'sanity-clause.elf')
  316. def test_microblaze_s3adsp1800(self):
  317. """
  318. :avocado: tags=arch:microblaze
  319. :avocado: tags=machine:petalogix-s3adsp1800
  320. """
  321. tar_hash = '08bf3e3bfb6b6c7ce1e54ab65d54e189f2caf13f'
  322. tar_url = ('https://qemu-advcal.gitlab.io'
  323. '/qac-best-of-multiarch/download/day17.tar.xz')
  324. file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
  325. self.do_test_advcal_2018(file_path, 'ballerina.bin')
  326. def test_ppc64_e500(self):
  327. """
  328. :avocado: tags=arch:ppc64
  329. :avocado: tags=machine:ppce500
  330. :avocado: tags=cpu:e5500
  331. """
  332. tar_hash = '6951d86d644b302898da2fd701739c9406527fe1'
  333. tar_url = ('https://qemu-advcal.gitlab.io'
  334. '/qac-best-of-multiarch/download/day19.tar.xz')
  335. file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
  336. self.do_test_advcal_2018(file_path, 'uImage')
  337. def test_or1k_sim(self):
  338. """
  339. :avocado: tags=arch:or1k
  340. :avocado: tags=machine:or1k-sim
  341. """
  342. tar_hash = '20334cdaf386108c530ff0badaecc955693027dd'
  343. tar_url = ('https://qemu-advcal.gitlab.io'
  344. '/qac-best-of-multiarch/download/day20.tar.xz')
  345. file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
  346. self.do_test_advcal_2018(file_path, 'vmlinux')
  347. def test_ppc_g3beige(self):
  348. """
  349. :avocado: tags=arch:ppc
  350. :avocado: tags=machine:g3beige
  351. """
  352. tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
  353. tar_url = ('https://qemu-advcal.gitlab.io'
  354. '/qac-best-of-multiarch/download/day15.tar.xz')
  355. file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
  356. self.do_test_advcal_2018(file_path, 'invaders.elf',
  357. args=('-M', 'graphics=off'))
  358. def test_ppc_mac99(self):
  359. """
  360. :avocado: tags=arch:ppc
  361. :avocado: tags=machine:mac99
  362. """
  363. tar_hash = 'e0b872a5eb8fdc5bed19bd43ffe863900ebcedfc'
  364. tar_url = ('https://qemu-advcal.gitlab.io'
  365. '/qac-best-of-multiarch/download/day15.tar.xz')
  366. file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
  367. self.do_test_advcal_2018(file_path, 'invaders.elf',
  368. args=('-M', 'graphics=off'))
  369. def test_sparc_ss20(self):
  370. """
  371. :avocado: tags=arch:sparc
  372. :avocado: tags=machine:SS-20
  373. """
  374. tar_hash = 'b18550d5d61c7615d989a06edace051017726a9f'
  375. tar_url = ('https://qemu-advcal.gitlab.io'
  376. '/qac-best-of-multiarch/download/day11.tar.xz')
  377. file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
  378. self.do_test_advcal_2018(file_path, 'zImage.elf')
  379. def test_xtensa_lx60(self):
  380. """
  381. :avocado: tags=arch:xtensa
  382. :avocado: tags=machine:lx60
  383. :avocado: tags=cpu:dc233c
  384. """
  385. tar_hash = '49e88d9933742f0164b60839886c9739cb7a0d34'
  386. tar_url = ('https://qemu-advcal.gitlab.io'
  387. '/qac-best-of-multiarch/download/day02.tar.xz')
  388. file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
  389. self.do_test_advcal_2018(file_path, 'santas-sleigh-ride.elf')
  390. @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
  391. class ReplayKernelSlow(ReplayKernelBase):
  392. # Override the timeout, because this kernel includes an inner
  393. # loop which is executed with TB recompilings during replay,
  394. # making it very slow.
  395. timeout = 180
  396. def test_mips_malta_cpio(self):
  397. """
  398. :avocado: tags=arch:mips
  399. :avocado: tags=machine:malta
  400. :avocado: tags=endian:big
  401. :avocado: tags=slowness:high
  402. """
  403. deb_url = ('http://snapshot.debian.org/archive/debian/'
  404. '20160601T041800Z/pool/main/l/linux/'
  405. 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
  406. deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
  407. deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
  408. kernel_path = self.extract_from_deb(deb_path,
  409. '/boot/vmlinux-4.5.0-2-4kc-malta')
  410. initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
  411. '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
  412. 'mips/rootfs.cpio.gz')
  413. initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'
  414. initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
  415. initrd_path = self.workdir + "rootfs.cpio"
  416. archive.gzip_uncompress(initrd_path_gz, initrd_path)
  417. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  418. 'console=ttyS0 console=tty '
  419. 'rdinit=/sbin/init noreboot')
  420. console_pattern = 'Boot successful.'
  421. self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5,
  422. args=('-initrd', initrd_path))
  423. @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
  424. def test_mips64el_malta_5KEc_cpio(self):
  425. """
  426. :avocado: tags=arch:mips64el
  427. :avocado: tags=machine:malta
  428. :avocado: tags=endian:little
  429. :avocado: tags=slowness:high
  430. :avocado: tags=cpu:5KEc
  431. """
  432. kernel_url = ('https://github.com/philmd/qemu-testing-blob/'
  433. 'raw/9ad2df38/mips/malta/mips64el/'
  434. 'vmlinux-3.19.3.mtoman.20150408')
  435. kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
  436. kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  437. initrd_url = ('https://github.com/groeck/linux-build-test/'
  438. 'raw/8584a59e/rootfs/'
  439. 'mipsel64/rootfs.mipsel64r1.cpio.gz')
  440. initrd_hash = '1dbb8a396e916847325284dbe2151167'
  441. initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5',
  442. asset_hash=initrd_hash)
  443. initrd_path = self.workdir + "rootfs.cpio"
  444. archive.gzip_uncompress(initrd_path_gz, initrd_path)
  445. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  446. 'console=ttyS0 console=tty '
  447. 'rdinit=/sbin/init noreboot')
  448. console_pattern = 'Boot successful.'
  449. self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5,
  450. args=('-initrd', initrd_path))
  451. def do_test_mips_malta32el_nanomips(self, kernel_path_xz):
  452. kernel_path = self.workdir + "kernel"
  453. with lzma.open(kernel_path_xz, 'rb') as f_in:
  454. with open(kernel_path, 'wb') as f_out:
  455. shutil.copyfileobj(f_in, f_out)
  456. kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
  457. 'mem=256m@@0x0 '
  458. 'console=ttyS0')
  459. console_pattern = 'Kernel command line: %s' % kernel_command_line
  460. self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
  461. def test_mips_malta32el_nanomips_4k(self):
  462. """
  463. :avocado: tags=arch:mipsel
  464. :avocado: tags=machine:malta
  465. :avocado: tags=endian:little
  466. :avocado: tags=cpu:I7200
  467. """
  468. kernel_url = ('http://mipsdistros.mips.com/LinuxDistro/nanomips/'
  469. 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
  470. 'generic_nano32r6el_page4k.xz')
  471. kernel_hash = '477456aafd2a0f1ddc9482727f20fe9575565dd6'
  472. kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  473. self.do_test_mips_malta32el_nanomips(kernel_path_xz)
  474. def test_mips_malta32el_nanomips_16k_up(self):
  475. """
  476. :avocado: tags=arch:mipsel
  477. :avocado: tags=machine:malta
  478. :avocado: tags=endian:little
  479. :avocado: tags=cpu:I7200
  480. """
  481. kernel_url = ('http://mipsdistros.mips.com/LinuxDistro/nanomips/'
  482. 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
  483. 'generic_nano32r6el_page16k_up.xz')
  484. kernel_hash = 'e882868f944c71c816e832e2303b7874d044a7bc'
  485. kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  486. self.do_test_mips_malta32el_nanomips(kernel_path_xz)
  487. def test_mips_malta32el_nanomips_64k_dbg(self):
  488. """
  489. :avocado: tags=arch:mipsel
  490. :avocado: tags=machine:malta
  491. :avocado: tags=endian:little
  492. :avocado: tags=cpu:I7200
  493. """
  494. kernel_url = ('http://mipsdistros.mips.com/LinuxDistro/nanomips/'
  495. 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/'
  496. 'generic_nano32r6el_page64k_dbg.xz')
  497. kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
  498. kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
  499. self.do_test_mips_malta32el_nanomips(kernel_path_xz)