xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh (revision e82490700e19f1b8a2cef6102f4726144d281988)
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
31log_assert "Verify zdb does not produce redundant dumps of configurations"
32log_onexit cleanup
33
34function cleanup
35{
36	datasetexists $TESTPOOL && destroy_pool $TESTPOOL
37}
38
39verify_runnable "global"
40verify_disk_count "$DISKS" 2
41
42config_count=(1 2)
43set -A DISK $DISKS
44
45default_mirror_setup_noexit $DISKS
46log_must dd if=${DEV_DSKDIR}/${DISK[0]}s0 of=${DEV_DSKDIR}/${DISK[1]}s0 bs=1024 count=256 conv=notrunc
47
48for x in 0 1 ; do
49	config_count=$(zdb -l $DEV_RDSKDIR/${DISK[$x]}s0 | grep -c features_for_read)
50	(( $? != 0)) && log_fail "failed to get config_count from DISK[$x]"
51	log_note "vdev $x: message_count $config_count"
52	[ $config_count -ne ${config_count[$x]} ] && \
53		log_fail "zdb produces an incorrect number of configuration dumps."
54done
55
56cleanup
57
58log_pass "zdb produces unique dumps of configurations."
59