#
# CDDL HEADER START
#
# 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
#
# CDDL HEADER END
#
#
# Copyright (c) 2015, 2016 by Delphix. All rights reserved.
#
set -x
export BITS=64
set +x
eval 'ARCHBITS=${'"${ARCH}_${BITS}"'}'
function usage
{
echo -e "\n$0 [-t <timeout>] [-c <dump directory>]" \
"[ -- [extra ztest parameters]]\n" \
"\n" \
" This script runs ztest repeatedly with randomized arguments.\n" \
" If a crash is encountered, the ztest logs, any associated\n" \
" vdev files, and core file (if one exists) are moved to the\n" \
" after the -- end-of-options marker will be passed to ztest.\n" \
"\n" \
" Options:\n" \
" -t Total time to loop for, in seconds. If not provided,\n" \
" zloop runs forever.\n" \
" -f Specify working directory for ztest vdev files.\n" \
" -c Specify a core dump directory to use.\n" \
" -h Print this help message.\n" \
"" >&2
}
function or_die
{
$@
if [[ $? -ne 0 ]]; then
echo "Command failed: $@"
exit 1
fi
}
function store_core
{
# check for core
if [[ -f core ]]; then
# Dump core + logs to stored directory
# Record info in cores logfile
fi
echo "continuing..."
fi
}
set -x
set +x
# parse arguments
# expected format: zloop [-t timeout] [-c coredir] [-- extra ztest args]
timeout=0
while getopts ":ht:c:f:" opt; do
h ) usage
exit 2
;;
* ) echo "Invalid argument: -$OPTARG";
exit 1
esac
done
# pass remaining arguments on to ztest
if [[ -f core ]]; then
echo "There's a core dump here you might want to look at first."
exit 1
fi
if [[ ! -d $coredir ]]; then
echo "core dump directory ($coredir) does not exist, creating it."
fi
if [[ ! -w $coredir ]]; then
echo "core dump directory ($coredir) is not writable."
exit 1
fi
# if no timeout was specified, loop forever.
zopt="-VVVVV"
# switch between common arrangements & fully randomized
mirrors=2
raidz=0
parity=1
vdevs=2
else
fi
size=128m
ztrc=$?
done
echo "zloop finished, $foundcrashes crashes found"
exit 1
fi