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) 2023, Klara Inc.
16#
17
18. $STF_SUITE/include/libtest.shlib
19
20write_count=8
21blksize=131072
22
23tmpfile=$TEST_BASE_DIR/tmpfile
24
25function cleanup
26{
27	datasetexists $TESTPOOL && destroy_pool $TESTPOOL
28	rm $tmpfile.1 $tmpfile.2
29}
30
31log_onexit cleanup
32
33log_assert "Verify that zfs send and zdb -B produce the same stream"
34
35verify_runnable "global"
36verify_disk_count "$DISKS" 2
37
38default_mirror_setup_noexit $DISKS
39file_write -o create -w -f $TESTDIR/file -b $blksize -c $write_count
40
41snap=$TESTPOOL/$TESTFS@snap
42log_must zfs snapshot $snap
43typeset -i objsetid=$(zfs get -Ho value objsetid $snap)
44
45sync_pool $TESTPOOL
46
47log_must eval "zfs send -ecL $snap > $tmpfile.1"
48log_must eval "zdb -B $TESTPOOL/$objsetid ecL > $tmpfile.2"
49
50typeset sum1=$(cat $tmpfile.1 | md5sum)
51typeset sum2=$(cat $tmpfile.2 | md5sum)
52
53log_must test "$sum1" = "$sum2"
54
55log_pass "zfs send and zdb -B produce the same stream"
56