2
1

test_iso9660.py 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. import os
  2. import infra.basetest
  3. BASIC_CONFIG = \
  4. """
  5. BR2_x86_pentium4=y
  6. BR2_TOOLCHAIN_EXTERNAL=y
  7. BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
  8. BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
  9. BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-i386-pentium4-full-2017.05-1078-g95b1dae.tar.bz2"
  10. BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
  11. BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_2=y
  12. BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
  13. # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
  14. BR2_TOOLCHAIN_EXTERNAL_CXX=y
  15. BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
  16. BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
  17. BR2_LINUX_KERNEL=y
  18. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  19. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.204"
  20. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  21. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="{}"
  22. # BR2_TARGET_ROOTFS_TAR is not set
  23. """.format(infra.filepath("conf/minimal-x86-qemu-kernel.config"))
  24. def test_mount_internal_external(emulator, builddir, internal=True, efi=False):
  25. img = os.path.join(builddir, "images", "rootfs.iso9660")
  26. if efi:
  27. efi_img = os.path.join(builddir, "images", "OVMF.fd")
  28. emulator.boot(arch="i386", options=["-cdrom", img, "-bios", efi_img])
  29. else:
  30. emulator.boot(arch="i386", options=["-cdrom", img])
  31. emulator.login()
  32. if internal:
  33. cmd = "mount | grep 'rootfs on / type rootfs'"
  34. else:
  35. cmd = "mount | grep '/dev/root on / type iso9660'"
  36. _, exit_code = emulator.run(cmd)
  37. return exit_code
  38. def test_touch_file(emulator):
  39. _, exit_code = emulator.run("touch test")
  40. return exit_code
  41. #
  42. # Grub 2
  43. class TestIso9660Grub2External(infra.basetest.BRTest):
  44. config = BASIC_CONFIG + \
  45. """
  46. BR2_TARGET_ROOTFS_ISO9660=y
  47. # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
  48. BR2_TARGET_GRUB2=y
  49. BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
  50. BR2_TARGET_GRUB2_BUILTIN_MODULES_PC="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
  51. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  52. """.format(infra.filepath("conf/grub2.cfg"))
  53. def test_run(self):
  54. exit_code = test_mount_internal_external(self.emulator,
  55. self.builddir, internal=False)
  56. self.assertEqual(exit_code, 0)
  57. exit_code = test_touch_file(self.emulator)
  58. self.assertEqual(exit_code, 1)
  59. class TestIso9660Grub2ExternalCompress(infra.basetest.BRTest):
  60. config = BASIC_CONFIG + \
  61. """
  62. BR2_TARGET_ROOTFS_ISO9660=y
  63. # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
  64. BR2_TARGET_ROOTFS_ISO9660_TRANSPARENT_COMPRESSION=y
  65. BR2_TARGET_GRUB2=y
  66. BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
  67. BR2_TARGET_GRUB2_BUILTIN_MODULES_PC="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
  68. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  69. """.format(infra.filepath("conf/grub2.cfg"))
  70. def test_run(self):
  71. exit_code = test_mount_internal_external(self.emulator,
  72. self.builddir, internal=False)
  73. self.assertEqual(exit_code, 0)
  74. exit_code = test_touch_file(self.emulator)
  75. self.assertEqual(exit_code, 1)
  76. class TestIso9660Grub2Internal(infra.basetest.BRTest):
  77. config = BASIC_CONFIG + \
  78. """
  79. BR2_TARGET_ROOTFS_ISO9660=y
  80. BR2_TARGET_ROOTFS_ISO9660_INITRD=y
  81. BR2_TARGET_GRUB2=y
  82. BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
  83. BR2_TARGET_GRUB2_BUILTIN_MODULES_PC="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
  84. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  85. """.format(infra.filepath("conf/grub2.cfg"))
  86. def test_run(self):
  87. exit_code = test_mount_internal_external(self.emulator,
  88. self.builddir, internal=True)
  89. self.assertEqual(exit_code, 0)
  90. exit_code = test_touch_file(self.emulator)
  91. self.assertEqual(exit_code, 0)
  92. class TestIso9660Grub2EFI(infra.basetest.BRTest):
  93. config = BASIC_CONFIG + \
  94. """
  95. BR2_TARGET_ROOTFS_ISO9660=y
  96. BR2_TARGET_ROOTFS_ISO9660_INITRD=y
  97. BR2_TARGET_GRUB2=y
  98. BR2_TARGET_GRUB2_I386_EFI=y
  99. BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI="boot linux ext2 fat part_msdos part_gpt normal iso9660"
  100. BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI="{}"
  101. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  102. BR2_TARGET_EDK2=y
  103. """.format(infra.filepath("conf/grub2-efi.cfg"),
  104. infra.filepath("conf/grub2.cfg"))
  105. def test_run(self):
  106. exit_code = test_mount_internal_external(self.emulator,
  107. self.builddir, internal=True,
  108. efi=True)
  109. self.assertEqual(exit_code, 0)
  110. exit_code = test_touch_file(self.emulator)
  111. self.assertEqual(exit_code, 0)
  112. class TestIso9660Grub2Hybrid(infra.basetest.BRTest):
  113. config = BASIC_CONFIG + \
  114. """
  115. BR2_TARGET_ROOTFS_ISO9660=y
  116. BR2_TARGET_ROOTFS_ISO9660_INITRD=y
  117. BR2_TARGET_GRUB2=y
  118. BR2_TARGET_GRUB2_I386_PC=y
  119. BR2_TARGET_GRUB2_I386_EFI=y
  120. BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
  121. BR2_TARGET_GRUB2_BUILTIN_MODULES_PC="boot linux ext2 fat squash4 part_msdos part_gpt normal iso9660 biosdisk"
  122. BR2_TARGET_GRUB2_BUILTIN_CONFIG_PC=""
  123. BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI="boot linux ext2 fat squash4 part_msdos part_gpt normal iso9660 efi_gop"
  124. BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI="{}"
  125. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  126. BR2_TARGET_EDK2=y
  127. """.format(infra.filepath("conf/grub2-efi.cfg"),
  128. infra.filepath("conf/grub2.cfg"))
  129. def test_run(self):
  130. exit_code = test_mount_internal_external(self.emulator,
  131. self.builddir, internal=True,
  132. efi=False)
  133. self.assertEqual(exit_code, 0)
  134. exit_code = test_touch_file(self.emulator)
  135. self.assertEqual(exit_code, 0)
  136. self.emulator.stop()
  137. exit_code = test_mount_internal_external(self.emulator,
  138. self.builddir, internal=True,
  139. efi=True)
  140. self.assertEqual(exit_code, 0)
  141. exit_code = test_touch_file(self.emulator)
  142. self.assertEqual(exit_code, 0)
  143. #
  144. # Syslinux
  145. class TestIso9660SyslinuxExternal(infra.basetest.BRTest):
  146. config = BASIC_CONFIG + \
  147. """
  148. BR2_TARGET_ROOTFS_ISO9660=y
  149. # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
  150. BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
  151. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  152. BR2_TARGET_SYSLINUX=y
  153. """.format(infra.filepath("conf/isolinux.cfg"))
  154. def test_run(self):
  155. exit_code = test_mount_internal_external(self.emulator,
  156. self.builddir, internal=False)
  157. self.assertEqual(exit_code, 0)
  158. exit_code = test_touch_file(self.emulator)
  159. self.assertEqual(exit_code, 1)
  160. class TestIso9660SyslinuxExternalCompress(infra.basetest.BRTest):
  161. config = BASIC_CONFIG + \
  162. """
  163. BR2_TARGET_ROOTFS_ISO9660=y
  164. # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
  165. BR2_TARGET_ROOTFS_ISO9660_TRANSPARENT_COMPRESSION=y
  166. BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
  167. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  168. BR2_TARGET_SYSLINUX=y
  169. """.format(infra.filepath("conf/isolinux.cfg"))
  170. def test_run(self):
  171. exit_code = test_mount_internal_external(self.emulator,
  172. self.builddir, internal=False)
  173. self.assertEqual(exit_code, 0)
  174. exit_code = test_touch_file(self.emulator)
  175. self.assertEqual(exit_code, 1)
  176. class TestIso9660SyslinuxInternal(infra.basetest.BRTest):
  177. config = BASIC_CONFIG + \
  178. """
  179. BR2_TARGET_ROOTFS_ISO9660=y
  180. BR2_TARGET_ROOTFS_ISO9660_INITRD=y
  181. BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
  182. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  183. BR2_TARGET_SYSLINUX=y
  184. """.format(infra.filepath("conf/isolinux.cfg"))
  185. def test_run(self):
  186. exit_code = test_mount_internal_external(self.emulator,
  187. self.builddir, internal=True)
  188. self.assertEqual(exit_code, 0)
  189. exit_code = test_touch_file(self.emulator)
  190. self.assertEqual(exit_code, 0)