#!/bin/ksh # # This file and its contents are supplied under the terms of the # Common Development and Distribution License ("CDDL"), version 1.0. # You may only use this file in accordance with the terms of version # 1.0 of the CDDL. # # A full copy of the text of the CDDL should have accompanied this # source. A copy of the CDDL is also available via the Internet at # http://www.illumos.org/license/CDDL. # # # Copyright (c) 2017 by Lawrence Livermore National Security, LLC. # . $STF_SUITE/include/libtest.shlib # # Description: # zdb -l exit codes are correct # # Strategy: # 1. Create a pool # 2. Overwrite label 0 on vdev[1] with dd # 3. Create an empty file # 3. Run zdb -l on vdev[0] and verify exit value 0 # 4. Run zdb -l on vdev[1] and verify exit value 1 # 5. Run zdb -l on the empty file and verify exit value 2 # log_assert "Verify zdb -l exit codes are correct" log_onexit cleanup function cleanup { datasetexists $TESTPOOL && destroy_pool $TESTPOOL rm -f $TEMPFILE } verify_runnable "global" verify_disk_count "$DISKS" 2 set -A DISK $DISKS default_mirror_setup_noexit $DISKS log_must dd if=/dev/zero of=$DEV_DSKDIR/${DISK[1]}s0 bs=1024 count=256 conv=notrunc log_must truncate -s 0 $TEMPFILE zdb -l $DEV_RDSKDIR/${DISK[0]}s0 [[ $? -ne 0 ]] && log_fail "zdb -l exit codes are incorrect." zdb -l $DEV_RDSKDIR/${DISK[1]}s0 [[ $? -ne 1 ]] && log_fail "zdb -l exit codes are incorrect." zdb -l $TEMPFILE [[ $? -ne 2 ]] && log_fail "zdb -l exit codes are incorrect." cleanup log_pass "zdb -l exit codes are correct."