test_zfs.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import os
  2. import infra.basetest
  3. class TestZfsBase(infra.basetest.BRTest):
  4. config = \
  5. """
  6. BR2_x86_64=y
  7. BR2_x86_corei7=y
  8. BR2_TOOLCHAIN_EXTERNAL=y
  9. BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
  10. BR2_LINUX_KERNEL=y
  11. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  12. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.15.35"
  13. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  14. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config"
  15. BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
  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 base_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 TestZfsGlibc(TestZfsBase):
  57. config = TestZfsBase.config + \
  58. """
  59. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_CORE_I7_GLIBC_STABLE=y
  60. """
  61. def test_run(self):
  62. TestZfsBase.base_test_run(self)
  63. class TestZfsUclibc(TestZfsBase):
  64. config = TestZfsBase.config + \
  65. """
  66. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_CORE_I7_UCLIBC_STABLE=y
  67. """
  68. def test_run(self):
  69. TestZfsBase.base_test_run(self)
  70. class TestZfsMusl(TestZfsBase):
  71. config = TestZfsBase.config + \
  72. """
  73. BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_MUSL_STABLE=y
  74. """
  75. def test_run(self):
  76. TestZfsBase.base_test_run(self)