test_iso9660.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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-2015.05-496-g85945aa.tar.bz2"
  10. BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=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_INET_RPC=y
  15. BR2_TOOLCHAIN_EXTERNAL_CXX=y
  16. BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
  17. BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
  18. BR2_LINUX_KERNEL=y
  19. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  20. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.0"
  21. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  22. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="{}"
  23. # BR2_TARGET_ROOTFS_TAR is not set
  24. """.format(infra.filepath("conf/minimal-x86-qemu-kernel.config"))
  25. def test_mount_internal_external(emulator, builddir, internal=True):
  26. img = os.path.join(builddir, "images", "rootfs.iso9660")
  27. emulator.boot(arch="i386", options=["-cdrom", img])
  28. emulator.login()
  29. if internal:
  30. cmd = "mount | grep 'rootfs on / type rootfs'"
  31. else:
  32. cmd = "mount | grep '/dev/root on / type iso9660'"
  33. _, exit_code = emulator.run(cmd)
  34. return exit_code
  35. def test_touch_file(emulator):
  36. _, exit_code = emulator.run("touch test")
  37. return exit_code
  38. #
  39. # Grub 2
  40. #
  41. class TestIso9660Grub2External(infra.basetest.BRTest):
  42. config = BASIC_CONFIG + \
  43. """
  44. BR2_TARGET_ROOTFS_ISO9660=y
  45. # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
  46. BR2_TARGET_GRUB2=y
  47. BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
  48. BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
  49. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  50. """.format(infra.filepath("conf/grub2.cfg"))
  51. def test_run(self):
  52. exit_code = test_mount_internal_external(self.emulator,
  53. self.builddir, internal=False)
  54. self.assertEqual(exit_code, 0)
  55. exit_code = test_touch_file(self.emulator)
  56. self.assertEqual(exit_code, 1)
  57. class TestIso9660Grub2Internal(infra.basetest.BRTest):
  58. config = BASIC_CONFIG + \
  59. """
  60. BR2_TARGET_ROOTFS_ISO9660=y
  61. BR2_TARGET_ROOTFS_ISO9660_INITRD=y
  62. BR2_TARGET_GRUB2=y
  63. BR2_TARGET_GRUB2_BOOT_PARTITION="cd"
  64. BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660"
  65. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  66. """.format(infra.filepath("conf/grub2.cfg"))
  67. def test_run(self):
  68. exit_code = test_mount_internal_external(self.emulator,
  69. self.builddir, internal=True)
  70. self.assertEqual(exit_code, 0)
  71. exit_code = test_touch_file(self.emulator)
  72. self.assertEqual(exit_code, 0)
  73. #
  74. # Syslinux
  75. #
  76. class TestIso9660SyslinuxExternal(infra.basetest.BRTest):
  77. config = BASIC_CONFIG + \
  78. """
  79. BR2_TARGET_ROOTFS_ISO9660=y
  80. # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set
  81. BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
  82. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  83. BR2_TARGET_SYSLINUX=y
  84. """.format(infra.filepath("conf/isolinux.cfg"))
  85. def test_run(self):
  86. exit_code = test_mount_internal_external(self.emulator,
  87. self.builddir, internal=False)
  88. self.assertEqual(exit_code, 0)
  89. exit_code = test_touch_file(self.emulator)
  90. self.assertEqual(exit_code, 1)
  91. class TestIso9660SyslinuxInternal(infra.basetest.BRTest):
  92. config = BASIC_CONFIG + \
  93. """
  94. BR2_TARGET_ROOTFS_ISO9660=y
  95. BR2_TARGET_ROOTFS_ISO9660_INITRD=y
  96. BR2_TARGET_ROOTFS_ISO9660_HYBRID=y
  97. BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}"
  98. BR2_TARGET_SYSLINUX=y
  99. """.format(infra.filepath("conf/isolinux.cfg"))
  100. def test_run(self):
  101. exit_code = test_mount_internal_external(self.emulator,
  102. self.builddir, internal=True)
  103. self.assertEqual(exit_code, 0)
  104. exit_code = test_touch_file(self.emulator)
  105. self.assertEqual(exit_code, 0)