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 33log_assert "Verify zdb -l exit codes are correct" 34log_onexit cleanup 35 36function cleanup 37{ 38 datasetexists $TESTPOOL && destroy_pool $TESTPOOL 39 rm -f $TEMPFILE 40} 41 42verify_runnable "global" 43verify_disk_count "$DISKS" 2 44 45set -A DISK $DISKS 46 47default_mirror_setup_noexit $DISKS 48log_must dd if=/dev/zero of=$DEV_DSKDIR/${DISK[1]}s0 bs=1024 count=256 conv=notrunc 49log_must truncate -s 0 $TEMPFILE 50 51zdb -l $DEV_RDSKDIR/${DISK[0]}s0 52[[ $? -ne 0 ]] && 53 log_fail "zdb -l exit codes are incorrect." 54 55zdb -l $DEV_RDSKDIR/${DISK[1]}s0 56[[ $? -ne 1 ]] && 57 log_fail "zdb -l exit codes are incorrect." 58 59zdb -l $TEMPFILE 60[[ $? -ne 2 ]] && 61 log_fail "zdb -l exit codes are incorrect." 62 63cleanup 64 65log_pass "zdb -l exit codes are correct." 66