2
1

test_zfs.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import os
  2. import infra.basetest
  3. class TestZfsBase(infra.basetest.BRTest):
  4. timeout = 60 * 3
  5. config = \
  6. """
  7. BR2_x86_64=y
  8. BR2_x86_corei7=y
  9. BR2_TOOLCHAIN_EXTERNAL=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.15.35"
  14. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  15. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config"
  16. BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
  17. BR2_PACKAGE_ZFS=y
  18. BR2_PACKAGE_PYTHON3=y
  19. BR2_PACKAGE_PYTHON_CFFI=y
  20. BR2_PACKAGE_PYTHON_SETUPTOOLS=y
  21. BR2_PACKAGE_ZLIB_NG=y
  22. BR2_PACKAGE_LIBRESSL=y
  23. BR2_TARGET_ROOTFS_CPIO=y
  24. # BR2_TARGET_ROOTFS_TAR is not set
  25. """
  26. def base_test_run(self):
  27. kernel = os.path.join(self.builddir, "images", "bzImage")
  28. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  29. self.emulator.boot(
  30. arch="x86_64",
  31. kernel=kernel,
  32. kernel_cmdline=["console=ttyS0"],
  33. options=["-cpu", "Nehalem", "-m", "320", "-initrd", cpio_file],
  34. )
  35. self.emulator.login()
  36. cmds = [
  37. # Init
  38. "modprobe zfs && sleep 2",
  39. "mount -o remount,size=132M /tmp",
  40. "fallocate -l 64M /tmp/container1.raw",
  41. "fallocate -l 64M /tmp/container2.raw",
  42. "zpool create pool raidz /tmp/container1.raw /tmp/container2.raw",
  43. "dd if=/dev/urandom bs=1M count=8 of=/pool/urandom",
  44. "sha256sum /pool/urandom > /tmp/urandom.sha256",
  45. # Check ZFS
  46. "zpool export pool",
  47. "zpool import pool -d /tmp/container1.raw -d /tmp/container2.raw",
  48. "dd conv=notrunc bs=1M count=32 seek=16 if=/dev/urandom of=/tmp/container1.raw",
  49. "zpool scrub -w pool",
  50. "sha256sum -c /tmp/urandom.sha256",
  51. "zpool status -v",
  52. # Check PyZFS
  53. "arc_summary",
  54. ]
  55. for cmd in cmds:
  56. self.assertRunOk(cmd, timeout=self.timeout)
  57. class TestZfsGlibc(TestZfsBase):
  58. config = TestZfsBase.config + \
  59. """
  60. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_CORE_I7_GLIBC_STABLE=y
  61. """
  62. def test_run(self):
  63. TestZfsBase.base_test_run(self)
  64. class TestZfsUclibc(TestZfsBase):
  65. config = TestZfsBase.config + \
  66. """
  67. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_CORE_I7_UCLIBC_STABLE=y
  68. """
  69. def test_run(self):
  70. TestZfsBase.base_test_run(self)
  71. class TestZfsMusl(TestZfsBase):
  72. config = TestZfsBase.config + \
  73. """
  74. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_MUSL_STABLE=y
  75. """
  76. def test_run(self):
  77. TestZfsBase.base_test_run(self)