]> git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh
New upstream version 0.7.9
[mirror_zfs-debian.git] / tests / zfs-tests / tests / functional / cli_root / zdb / zdb_003_pos.ksh
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) 2017 by Lawrence Livermore National Security, LLC.
16 #
17
18 . $STF_SUITE/include/libtest.shlib
19
20 #
21 # Description:
22 # zdb will not produce redundant dumps of configurations
23 #
24 # Strategy:
25 # 1. Create a pool with two vdevs
26 # 2. Copy label 1 from the first vdev to the second vdev
27 # 3. Collect zdb -l output for both vdevs
28 # 4. Verify that the correct number of configs is dumped for each
29 #
30
31 log_assert "Verify zdb does not produce redundant dumps of configurations"
32 log_onexit cleanup
33
34 function cleanup
35 {
36 datasetexists $TESTPOOL && destroy_pool $TESTPOOL
37 }
38
39 verify_runnable "global"
40 verify_disk_count "$DISKS" 2
41
42 config_count=(1 2)
43 set -A DISK $DISKS
44
45 default_mirror_setup_noexit $DISKS
46
47 DEVS=$(get_pool_devices ${TESTPOOL} ${DEV_RDSKDIR})
48 log_note "$DEVS"
49 [[ -n $DEVS ]] && set -A DISK $DEVS
50
51 log_must dd if=/dev/${DISK[0]} of=/dev/${DISK[1]} bs=1K count=256 conv=notrunc
52
53 for x in 0 1 ; do
54 config_count=$(zdb -l $DEV_RDSKDIR/${DISK[$x]} | grep -c features_for_read)
55 (( $? != 0)) && log_fail "failed to get config_count from DISK[$x]"
56 log_note "vdev $x: message_count $config_count"
57 [ $config_count -ne ${config_count[$x]} ] && \
58 log_fail "zdb produces an incorrect number of configuration dumps."
59 done
60
61 cleanup
62
63 log_pass "zdb produces unique dumps of configurations."