test_zfs.py 2.7 KB

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