]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh
Make zstreamdump -v more greppable
[mirror_zfs.git] / tests / zfs-tests / tests / functional / rsend / send-c_zstreamdump.ksh
1 #!/bin/ksh -p
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) 2015 by Delphix. All rights reserved.
16 #
17
18 . $STF_SUITE/tests/functional/rsend/rsend.kshlib
19 . $STF_SUITE/include/math.shlib
20
21 #
22 # Description:
23 # Verify compression features show up in zstreamdump
24 #
25 # Strategy:
26 # 1. Create a full compressed send stream
27 # 2. Verify zstreamdump shows this stream has the relevant features
28 # 3. Verify zstreamdump's accounting of logical and compressed size is correct
29 #
30
31 verify_runnable "both"
32
33 log_assert "Verify zstreamdump correctly interprets compressed send streams."
34 log_onexit cleanup_pool $POOL2
35
36 typeset sendfs=$POOL2/fs
37
38 log_must zfs create -o compress=lz4 $sendfs
39 typeset dir=$(get_prop mountpoint $sendfs)
40 write_compressible $dir 16m
41 log_must zfs snapshot $sendfs@full
42
43 log_must eval "zfs send -c $sendfs@full >$BACKDIR/full"
44 log_must stream_has_features $BACKDIR/full lz4 compressed
45 cat $BACKDIR/full | zstreamdump -v > $BACKDIR/dump.out
46
47 lsize=$(awk '/^WRITE [^0]/ {lsize += $24} END {printf("%d", lsize)}' \
48 $BACKDIR/dump.out)
49 lsize_prop=$(get_prop logicalused $sendfs)
50 within_percent $lsize $lsize_prop 90 || log_fail \
51 "$lsize and $lsize_prop differed by too much"
52
53 csize=$(awk '/^WRITE [^0]/ {csize += $27} END {printf("%d", csize)}' \
54 $BACKDIR/dump.out)
55 csize_prop=$(get_prop used $sendfs)
56 within_percent $csize $csize_prop 90 || log_fail \
57 "$csize and $csize_prop differed by too much"
58
59 log_pass "zstreamdump correctly interprets compressed send streams."