test_zfs.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import os
  2. import infra.basetest
  3. class TestZfsGlibc(infra.basetest.BRTest):
  4. config = \
  5. """
  6. BR2_x86_64=y
  7. BR2_x86_corei7=y
  8. BR2_TOOLCHAIN_EXTERNAL=y
  9. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_CORE_I7_GLIBC_STABLE=y
  10. BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
  11. BR2_LINUX_KERNEL=y
  12. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  13. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.12.13"
  14. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  15. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config"
  16. BR2_PACKAGE_ZFS=y
  17. BR2_PACKAGE_PYTHON3=y
  18. BR2_PACKAGE_PYTHON_CFFI=y
  19. BR2_PACKAGE_PYTHON_SETUPTOOLS=y
  20. BR2_PACKAGE_ZLIB_NG=y
  21. BR2_PACKAGE_LIBRESSL=y
  22. BR2_TARGET_ROOTFS_CPIO=y
  23. # BR2_TARGET_ROOTFS_TAR is not set
  24. """
  25. def test_run(self):
  26. kernel = os.path.join(self.builddir, "images", "bzImage")
  27. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  28. self.emulator.boot(
  29. arch="x86_64",
  30. kernel=kernel,
  31. kernel_cmdline=["console=ttyS0"],
  32. options=["-cpu", "Nehalem", "-m", "320", "-initrd", cpio_file],
  33. )
  34. self.emulator.login()
  35. cmds = [
  36. # Init
  37. "modprobe zfs",
  38. "mount -o remount,size=132M /tmp",
  39. "fallocate -l 64M /tmp/container1.raw",
  40. "fallocate -l 64M /tmp/container2.raw",
  41. "zpool create -m /pool pool raidz /tmp/container1.raw /tmp/container2.raw",
  42. "dd if=/dev/urandom bs=1M count=8 of=/pool/urandom",
  43. "sha256sum /pool/urandom > /tmp/urandom.sha256",
  44. # Check ZFS
  45. "zpool export pool",
  46. "zpool import pool -d /tmp/container1.raw -d /tmp/container2.raw",
  47. "dd conv=notrunc bs=1M count=32 seek=16 if=/dev/urandom of=/tmp/container1.raw",
  48. "zpool scrub -w pool",
  49. "sha256sum -c /tmp/urandom.sha256",
  50. "zpool status -v",
  51. # Check PyZFS
  52. "arc_summary",
  53. ]
  54. for cmd in cmds:
  55. self.assertRunOk(cmd)
  56. class TestZfsUclibc(infra.basetest.BRTest):
  57. config = \
  58. """
  59. BR2_x86_64=y
  60. BR2_x86_corei7=y
  61. BR2_TOOLCHAIN_EXTERNAL=y
  62. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_CORE_I7_UCLIBC_STABLE=y
  63. BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
  64. BR2_LINUX_KERNEL=y
  65. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  66. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.12.13"
  67. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  68. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config"
  69. BR2_PACKAGE_ZFS=y
  70. BR2_PACKAGE_PYTHON3=y
  71. BR2_PACKAGE_PYTHON_CFFI=y
  72. BR2_PACKAGE_PYTHON_SETUPTOOLS=y
  73. BR2_PACKAGE_ZLIB_NG=y
  74. BR2_PACKAGE_LIBRESSL=y
  75. BR2_TARGET_ROOTFS_CPIO=y
  76. # BR2_TARGET_ROOTFS_TAR is not set
  77. """
  78. def test_run(self):
  79. kernel = os.path.join(self.builddir, "images", "bzImage")
  80. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  81. self.emulator.boot(
  82. arch="x86_64",
  83. kernel=kernel,
  84. kernel_cmdline=["console=ttyS0"],
  85. options=["-cpu", "Nehalem", "-m", "320", "-initrd", cpio_file],
  86. )
  87. self.emulator.login()
  88. cmds = [
  89. # Init
  90. "modprobe zfs",
  91. "mount -o remount,size=132M /tmp",
  92. "fallocate -l 64M /tmp/container1.raw",
  93. "fallocate -l 64M /tmp/container2.raw",
  94. "zpool create -m /pool pool raidz /tmp/container1.raw /tmp/container2.raw",
  95. "dd if=/dev/urandom bs=1M count=8 of=/pool/urandom",
  96. "sha256sum /pool/urandom > /tmp/urandom.sha256",
  97. # Check ZFS
  98. "zpool export pool",
  99. "zpool import pool -d /tmp/container1.raw -d /tmp/container2.raw",
  100. "dd conv=notrunc bs=1M count=32 seek=16 if=/dev/urandom of=/tmp/container1.raw",
  101. "zpool scrub -w pool",
  102. "sha256sum -c /tmp/urandom.sha256",
  103. "zpool status -v",
  104. # Check PyZFS
  105. "arc_summary",
  106. ]
  107. for cmd in cmds:
  108. self.assertRunOk(cmd)