]> git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zdb/zdb_005_pos.ksh
60bbb5615602be68d30b74ce96fb3d2828e9f54c
[mirror_zfs-debian.git] / tests / zfs-tests / tests / functional / cli_root / zdb / zdb_005_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 -l exit codes are correct
23 #
24 # Strategy:
25 # 1. Create a pool
26 # 2. Overwrite label 0 on vdev[1] with dd
27 # 3. Create an empty file
28 # 3. Run zdb -l on vdev[0] and verify exit value 0
29 # 4. Run zdb -l on vdev[1] and verify exit value 1
30 # 5. Run zdb -l on the empty file and verify exit value 2
31 #
32
33 log_assert "Verify zdb -l exit codes are correct"
34 log_onexit cleanup
35
36 function cleanup
37 {
38 datasetexists $TESTPOOL && destroy_pool $TESTPOOL
39 }
40
41 verify_runnable "global"
42 verify_disk_count "$DISKS" 2
43
44 set -A DISK $DISKS
45
46 default_mirror_setup_noexit $DISKS
47 log_must dd if=/dev/zero of=$DEV_RDSKDIR/${DISK[1]} bs=1K count=256 conv=notrunc
48 log_must truncate -s 0 $TEMPFILE
49
50 zdb -l $DEV_RDSKDIR/${DISK[0]}
51 [[ $? -ne 0 ]] &&
52 log_fail "zdb -l exit codes are incorrect."
53
54 zdb -l $DEV_RDSKDIR/${DISK[1]}
55 [[ $? -ne 1 ]] &&
56 log_fail "zdb -l exit codes are incorrect."
57
58 zdb -l $TEMPFILE
59 [[ $? -ne 2 ]] &&
60 log_fail "zdb -l exit codes are incorrect."
61
62 cleanup
63
64 log_pass "zdb -l exit codes are correct."