Path: blob/main/tests/sys/geom/class/multipath/failloop.sh
39635 views
#!/bin/sh1# Copyright (c) 2019 Axcient2#3# Redistribution and use in source and binary forms, with or without4# modification, are permitted provided that the following conditions5# are met:6# 1. Redistributions of source code must retain the above copyright7# notice, this list of conditions and the following disclaimer.8# 2. Redistributions in binary form must reproduce the above copyright9# notice, this list of conditions and the following disclaimer in the10# documentation and/or other materials provided with the distribution.11#12# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND13# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE14# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE15# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE16# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL17# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS18# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)19# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT20# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY21# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF22# SUCH DAMAGE.23#2425. $(atf_get_srcdir)/conf.sh2627# See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=17847328atf_test_case failloop cleanup29failloop_head()30{31atf_set "descr" "A persistent failure in the provider should not cause an infinite loop, nor restore any providers that were faulted by the same bio"32atf_set "require.user" "root"33atf_set "require.config" "allow_sysctl_side_effects"34}35failloop_body()36{37sysctl -n kern.geom.notaste > kern.geom.notaste.txt38load_gnop39load_gmultipath40load_dtrace4142md0=$(alloc_md)43md1=$(alloc_md)44name=$(mkname)45atf_check gnop create /dev/${md0}46atf_check gnop create /dev/${md1}47atf_check -s exit:0 gmultipath create "$name" ${md0}.nop ${md1}.nop48sysctl kern.geom.notaste=14950atf_check gnop configure -r 100 -w 100 ${md0}.nop51atf_check gnop configure -r 100 -w 100 ${md1}.nop52dd_status=`dtrace \53-o restore_count \54-i 'geom:multipath:config:restore {@restore = count()}' \55-c "dd if=/dev/zero of=/dev/multipath/"$name" bs=4096 count=1" \562>&1 | awk '/exited with status/ {print $NF}'`57if [ ! -f restore_count ]; then58atf_skip "dtrace didn't execute successfully"59fi60# The dd command should've failed ...61atf_check_equal 1 $dd_status62# and triggered 1 or 2 path restores63if [ `cat restore_count` -gt 2 ]; then64atf_fail "gmultipath restored paths too many times"65fi66}67failloop_cleanup()68{69if [ -f kern.geom.notaste.txt ]; then70sysctl kern.geom.notaste=`cat kern.geom.notaste.txt`71fi72common_cleanup73}7475atf_init_test_cases()76{77atf_add_test_case failloop78}798081