1#!/bin/ksh 2 3# 4# This file and its contents are supplied under the terms of the 5# Common Development and Distribution License ("CDDL"), version 1.0. 6# You may only use this file in accordance with the terms of version 7# 1.0 of the CDDL. 8# 9# A full copy of the text of the CDDL should have accompanied this 10# source. A copy of the CDDL is also available via the Internet at 11# http://www.illumos.org/license/CDDL. 12# 13 14# 15# Copyright (c) 2019 by Datto, Inc. All rights reserved. 16# 17 18. $STF_SUITE/include/libtest.shlib 19 20# 21# Description: 22# zdb -c will display the same checksum as -ddddddbbbbbb 23# 24# Strategy: 25# 1. Create a pool 26# 2. Write some data to a file 27# 3. Run zdb -ddddddbbbbbb against the file 28# 4. Record the checksum and DVA of L0 block 0 29# 5. Run zdb -R with :c flag and match the checksum 30 31 32function cleanup 33{ 34 datasetexists $TESTPOOL && destroy_pool $TESTPOOL 35} 36 37log_assert "Verify zdb -R generates the correct checksum." 38log_onexit cleanup 39init_data=$TESTDIR/file1 40write_count=8 41blksize=131072 42verify_runnable "global" 43verify_disk_count "$DISKS" 2 44 45default_mirror_setup_noexit $DISKS 46file_write -o create -w -f $init_data -b $blksize -c $write_count 47 48# get object number of file 49listing=$(ls -i $init_data) 50set -A array $listing 51obj=${array[0]} 52log_note "file $init_data has object number $obj" 53sync_pool $TESTPOOL 54 55output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ 56 | grep -m 1 "L0 DVA") 57dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") 58log_note "block 0 of $init_data has a DVA of $dva" 59cksum_expected=$(sed -Ene 's/^.+ cksum=([a-z0-9:]+)$/\1/p' <<< "$output") 60log_note "expecting cksum $cksum_expected" 61output=$(zdb -R $TESTPOOL $dva:c 2> /dev/null) 62grep -q $cksum_expected <<<"$output" || 63 log_fail "zdb -R failed to print the correct checksum" 64 65log_pass "zdb -R generates the correct checksum" 66