1#!/bin/sh 2# Copyright (c) 2019 Axcient 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions 6# are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. 9# 2. Redistributions in binary form must reproduce the above copyright 10# notice, this list of conditions and the following disclaimer in the 11# documentation and/or other materials provided with the distribution. 12# 13# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23# SUCH DAMAGE. 24# 25# $FreeBSD$ 26 27. $(atf_get_srcdir)/conf.sh 28 29# See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=178473 30atf_test_case failloop cleanup 31failloop_head() 32{ 33 atf_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" 34 atf_set "require.user" "root" 35 atf_set "require.config" "allow_sysctl_side_effects" 36} 37failloop_body() 38{ 39 if [ "$(atf_config_get ci false)" = "true" ]; then 40 atf_skip "https://bugs.freebsd.org/244053" 41 fi 42 43 sysctl -n kern.geom.notaste > kern.geom.notaste.txt 44 load_gnop 45 load_gmultipath 46 load_dtrace 47 48 md0=$(alloc_md) 49 md1=$(alloc_md) 50 name=$(mkname) 51 atf_check gnop create /dev/${md0} 52 atf_check gnop create /dev/${md1} 53 atf_check -s exit:0 gmultipath create "$name" ${md0}.nop ${md1}.nop 54 sysctl kern.geom.notaste=1 55 56 atf_check gnop configure -r 100 -w 100 ${md0}.nop 57 atf_check gnop configure -r 100 -w 100 ${md1}.nop 58 dd_status=`dtrace \ 59 -o restore_count \ 60 -i 'geom:multipath:config:restore {@restore = count()}' \ 61 -c "dd if=/dev/zero of=/dev/multipath/"$name" bs=4096 count=1" \ 62 2>&1 | awk '/exited with status/ {print $NF}'` 63 # The dd command should've failed ... 64 atf_check_equal 1 $dd_status 65 # and triggered 1 or 2 path restores 66 if [ `cat restore_count` -gt 2 ]; then 67 atf_fail "gmultipath restored paths too many times" 68 fi 69} 70failloop_cleanup() 71{ 72 if [ -f kern.geom.notaste.txt ]; then 73 sysctl kern.geom.notaste=`cat kern.geom.notaste.txt` 74 fi 75 common_cleanup 76} 77 78atf_init_test_cases() 79{ 80 atf_add_test_case failloop 81} 82