1 1.7 gson # $NetBSD: t_intr.sh,v 1.7 2024/05/01 11:40:25 gson Exp $ 2 1.1 christos # 3 1.1 christos # Copyright (c) 2021 The NetBSD Foundation, Inc. 4 1.1 christos # All rights reserved. 5 1.1 christos # 6 1.1 christos # This code is derived from software contributed to The NetBSD Foundation 7 1.1 christos # by Christos Zoulas. 8 1.1 christos # 9 1.1 christos # Redistribution and use in source and binary forms, with or without 10 1.1 christos # modification, are permitted provided that the following conditions 11 1.1 christos # are met: 12 1.1 christos # 1. Redistributions of source code must retain the above copyright 13 1.1 christos # notice, this list of conditions and the following disclaimer. 14 1.1 christos # 2. Redistributions in binary form must reproduce the above copyright 15 1.1 christos # notice, this list of conditions and the following disclaimer in the 16 1.1 christos # documentation and/or other materials provided with the distribution. 17 1.1 christos # 18 1.1 christos # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 1.1 christos # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 1.1 christos # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 1.1 christos # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 1.1 christos # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 1.1 christos # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 1.1 christos # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 1.1 christos # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 1.1 christos # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 1.1 christos # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 1.1 christos # POSSIBILITY OF SUCH DAMAGE. 29 1.1 christos # 30 1.1 christos 31 1.1 christos DIR=$(atf_get_srcdir) 32 1.1 christos MAX=10000000 33 1.1 christos LMAX=1000000 34 1.1 christos BSIZE=128000 35 1.1 christos SSIZE=256000 36 1.1 christos TMOUT=20 37 1.1 christos 38 1.1 christos h_test() { 39 1.6 gson local avail=$( df -m . | awk '{if (int($4) > 0) print $4}' ) 40 1.7 gson # The test data are stored in triplicate: numbers.in, numbers.out, 41 1.7 gson # and a temporary "stdout" file created by ATF. Each line consists 42 1.7 gson # of up to 7 digits and a newline for a total of 8 bytes. 43 1.7 gson local need=$(( 3 * $MAX * 8 / 1000000 )) 44 1.6 gson if [ $avail -lt $need ]; then 45 1.6 gson atf_skip "not enough free space in working directory" 46 1.6 gson fi 47 1.6 gson 48 1.1 christos "${DIR}/h_makenumbers" "$1" > numbers.in 49 1.1 christos "${DIR}/h_intr" \ 50 1.2 christos -p "$2" -a ${SSIZE} -b ${BSIZE} -t ${TMOUT} \ 51 1.1 christos -c "dd of=numbers.out msgfmt=quiet" numbers.in 52 1.4 rillig atf_check -o "file:numbers.in" cat numbers.out 53 1.1 christos } 54 1.1 christos 55 1.1 christos atf_test_case stdio_intr_ionbf 56 1.1 christos stdio_intr_ionbf_head() 57 1.1 christos { 58 1.1 christos atf_set "descr" "Checks stdio EINTR _IONBF" 59 1.1 christos } 60 1.1 christos stdio_intr_ionbf_body() 61 1.1 christos { 62 1.1 christos h_test ${MAX} IONBF 63 1.1 christos } 64 1.1 christos 65 1.1 christos atf_test_case stdio_intr_iolbf 66 1.1 christos stdio_intr_iolbf_head() 67 1.1 christos { 68 1.1 christos atf_set "descr" "Checks stdio EINTR _IOLBF" 69 1.1 christos } 70 1.1 christos stdio_intr_iolbf_body() 71 1.1 christos { 72 1.1 christos h_test ${LMAX} IOLBF 73 1.1 christos } 74 1.1 christos 75 1.1 christos atf_test_case stdio_intr_iofbf 76 1.1 christos stdio_intr_iofbf_head() 77 1.1 christos { 78 1.1 christos atf_set "descr" "Checks stdio EINTR _IOFBF" 79 1.1 christos } 80 1.1 christos stdio_intr_iofbf_body() 81 1.1 christos { 82 1.4 rillig h_test ${LMAX} IOFBF 83 1.1 christos } 84 1.1 christos 85 1.1 christos atf_init_test_cases() 86 1.1 christos { 87 1.1 christos atf_add_test_case stdio_intr_ionbf 88 1.1 christos atf_add_test_case stdio_intr_iolbf 89 1.5 rillig # flappy test; see fflush.c 1.19 to 1.24 90 1.5 rillig #atf_add_test_case stdio_intr_iofbf 91 1.1 christos } 92