test_iso9660.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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.11"
  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):
  25. img = os.path.join(builddir, "images", "rootfs.iso9660")
  26. emulator.boot(arch="i386", options=["-cdrom", img])
  27. emulator.login()
  28. if internal:
  29. cmd = "mount | grep 'rootfs on / type rootfs'"
  30. else:
  31. cmd = "mount | grep '/dev/root on / type iso9660'"
  32. _, exit_code = emulator.run(cmd)
  33. return exit_code
  34. def test_touch_file(emulator):
  35. _, exit_code = emulator.run("touch test")
  36. return exit_code
  37. #
  38. # Grub 2
  39. #
  40. class TestIso9660Grub2External(infra.basetest.BRTest):
  41. config = BASIC_CONFIG + \
  42. """
  43. BR2_TARGET_ROOTFS_ISO9660=y
  44. # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
  45. BR2_TARGET_GRUB2=y
  46. BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
  47. BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
  48. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  49. """.format(infra.filepath("conf/grub2.cfg"))
  50. def test_run(self):
  51. exit_code = test_mount_internal_external(self.emulator,
  52. self.builddir, internal=False)
  53. self.assertEqual(exit_code, 0)
  54. exit_code = test_touch_file(self.emulator)
  55. self.assertEqual(exit_code, 1)
  56. class TestIso9660Grub2Internal(infra.basetest.BRTest):
  57. config = BASIC_CONFIG + \
  58. """
  59. BR2_TARGET_ROOTFS_ISO9660=y
  60. BR2_TARGET_ROOTFS_ISO9660_INITRD=y
  61. BR2_TARGET_GRUB2=y
  62. BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
  63. BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
  64. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  65. """.format(infra.filepath("conf/grub2.cfg"))
  66. def test_run(self):
  67. exit_code = test_mount_internal_external(self.emulator,
  68. self.builddir, internal=True)
  69. self.assertEqual(exit_code, 0)
  70. exit_code = test_touch_file(self.emulator)
  71. self.assertEqual(exit_code, 0)
  72. #
  73. # Grub
  74. #
  75. class TestIso9660GrubExternal(infra.basetest.BRTest):
  76. config = BASIC_CONFIG + \
  77. """
  78. BR2_TARGET_ROOTFS_ISO9660=y
  79. # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
  80. BR2_TARGET_GRUB=y
  81. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  82. """.format(infra.filepath("conf/grub-menu.lst"))
  83. def test_run(self):
  84. exit_code = test_mount_internal_external(self.emulator,
  85. self.builddir, internal=False)
  86. self.assertEqual(exit_code, 0)
  87. exit_code = test_touch_file(self.emulator)
  88. self.assertEqual(exit_code, 1)
  89. class TestIso9660GrubInternal(infra.basetest.BRTest):
  90. config = BASIC_CONFIG + \
  91. """
  92. BR2_TARGET_ROOTFS_ISO9660=y
  93. BR2_TARGET_GRUB=y
  94. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  95. """.format(infra.filepath("conf/grub-menu.lst"))
  96. def test_run(self):
  97. exit_code = test_mount_internal_external(self.emulator,
  98. self.builddir, internal=True)
  99. self.assertEqual(exit_code, 0)
  100. exit_code = test_touch_file(self.emulator)
  101. self.assertEqual(exit_code, 0)
  102. #
  103. # Syslinux
  104. #
  105. class TestIso9660SyslinuxExternal(infra.basetest.BRTest):
  106. config = BASIC_CONFIG + \
  107. """
  108. BR2_TARGET_ROOTFS_ISO9660=y
  109. # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
  110. BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
  111. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  112. BR2_TARGET_SYSLINUX=y
  113. """.format(infra.filepath("conf/isolinux.cfg"))
  114. def test_run(self):
  115. exit_code = test_mount_internal_external(self.emulator,
  116. self.builddir, internal=False)
  117. self.assertEqual(exit_code, 0)
  118. exit_code = test_touch_file(self.emulator)
  119. self.assertEqual(exit_code, 1)
  120. class TestIso9660SyslinuxInternal(infra.basetest.BRTest):
  121. config = BASIC_CONFIG + \
  122. """
  123. BR2_TARGET_ROOTFS_ISO9660=y
  124. BR2_TARGET_ROOTFS_ISO9660_INITRD=y
  125. BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
  126. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  127. BR2_TARGET_SYSLINUX=y
  128. """.format(infra.filepath("conf/isolinux.cfg"))
  129. def test_run(self):
  130. exit_code = test_mount_internal_external(self.emulator,
  131. self.builddir, internal=True)
  132. self.assertEqual(exit_code, 0)
  133. exit_code = test_touch_file(self.emulator)
  134. self.assertEqual(exit_code, 0)