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