test_zfs.py 2.9 KB

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