From 392556f0efa0129c51b08378b2e52b6667424a56 Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Wed, 19 Feb 2020 12:03:31 -0500 Subject: [PATCH] ZTS: Avoid nonportable cmp flag FreeBSD doesn't have the -n flag for cmp. Read the area for the first four labels from the disk to a separate file to compare instead of using the special flag to limit the size. Reviewed-by: George Melikov Reviewed-by: Brian Behlendorf Signed-off-by: Ryan Moeller Closes #10024 --- .../cli_root/zpool_labelclear/zpool_labelclear_valid.ksh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_valid.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_valid.ksh index 211829d512..31af9fd3f8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_valid.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_valid.ksh @@ -39,13 +39,15 @@ verify_runnable "global" function cleanup { poolexists $TESTPOOL && destroy_pool $TESTPOOL - rm -f $PATTERN_FILE $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4 + rm -f $PATTERN_FILE $DISK_PATTERN_FILE \ + $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4 } log_onexit cleanup log_assert "zpool labelclear will only clear valid labels" PATTERN_FILE=$TEST_BASE_DIR/pattern +DISK_PATTERN_FILE=$TEST_BASE_DIR/disk-pattern DEVICE1="$TEST_BASE_DIR/device-1" DEVICE2="$TEST_BASE_DIR/device-2" @@ -79,7 +81,8 @@ log_mustnot eval "zpool import -d $TEST_BASE_DIR | grep $TESTPOOL" # Verify the original pattern over the first two labels is intact for dev in $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4; do - log_must cmp -n $((4 * 1048576)) $dev $PATTERN_FILE + log_must dd if=$dev of=$DISK_PATTERN_FILE bs=1048576 count=4 + log_must cmp $DISK_PATTERN_FILE $PATTERN_FILE log_mustnot zdb -lq $dev done