1*3f1bde29Sjruoho# $NetBSD: t_stdethers.sh,v 1.1 2020/06/24 09:47:18 jruoho Exp $ 2*3f1bde29Sjruoho# 3*3f1bde29Sjruoho# Copyright (c) 2020 The NetBSD Foundation, Inc. 4*3f1bde29Sjruoho# All rights reserved. 5*3f1bde29Sjruoho# 6*3f1bde29Sjruoho# This code is derived from software contributed to The NetBSD Foundation 7*3f1bde29Sjruoho# by Jukka Ruohonen. 8*3f1bde29Sjruoho# 9*3f1bde29Sjruoho# Redistribution and use in source and binary forms, with or without 10*3f1bde29Sjruoho# modification, are permitted provided that the following conditions 11*3f1bde29Sjruoho# are met: 12*3f1bde29Sjruoho# 1. Redistributions of source code must retain the above copyright 13*3f1bde29Sjruoho# notice, this list of conditions and the following disclaimer. 14*3f1bde29Sjruoho# 2. Redistributions in binary form must reproduce the above copyright 15*3f1bde29Sjruoho# notice, this list of conditions and the following disclaimer in the 16*3f1bde29Sjruoho# documentation and/or other materials provided with the distribution. 17*3f1bde29Sjruoho# 18*3f1bde29Sjruoho# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19*3f1bde29Sjruoho# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20*3f1bde29Sjruoho# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21*3f1bde29Sjruoho# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22*3f1bde29Sjruoho# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*3f1bde29Sjruoho# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*3f1bde29Sjruoho# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*3f1bde29Sjruoho# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*3f1bde29Sjruoho# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*3f1bde29Sjruoho# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*3f1bde29Sjruoho# POSSIBILITY OF SUCH DAMAGE. 29*3f1bde29Sjruoho# 30*3f1bde29Sjruohotmp="/tmp/stdethers" 31*3f1bde29Sjruoho 32*3f1bde29Sjruohocheck() { 33*3f1bde29Sjruoho 34*3f1bde29Sjruoho stdethers $1 1>/dev/null 2>$tmp 35*3f1bde29Sjruoho 36*3f1bde29Sjruoho if [ ! $? -eq 0 ]; then 37*3f1bde29Sjruoho atf_fail "failed to parse $1" 38*3f1bde29Sjruoho fi 39*3f1bde29Sjruoho 40*3f1bde29Sjruoho if [ -s $tmp ]; then 41*3f1bde29Sjruoho strerror=$(cat $tmp) 42*3f1bde29Sjruoho atf_fail "$strerror" 43*3f1bde29Sjruoho fi 44*3f1bde29Sjruoho} 45*3f1bde29Sjruoho 46*3f1bde29Sjruohoclean() { 47*3f1bde29Sjruoho 48*3f1bde29Sjruoho if [ -f $tmp ]; then 49*3f1bde29Sjruoho rm $tmp 50*3f1bde29Sjruoho fi 51*3f1bde29Sjruoho} 52*3f1bde29Sjruoho 53*3f1bde29Sjruohoatf_test_case default cleanup 54*3f1bde29Sjruohodefault_head() { 55*3f1bde29Sjruoho atf_require_prog stdethers 56*3f1bde29Sjruoho atf_set "descr" "Test the system ethers(3) with stdethers(8)" 57*3f1bde29Sjruoho} 58*3f1bde29Sjruoho 59*3f1bde29Sjruohodefault_body() { 60*3f1bde29Sjruoho 61*3f1bde29Sjruoho if [ -f "/etc/ethers" ]; then 62*3f1bde29Sjruoho check "/etc/ethers" 63*3f1bde29Sjruoho fi 64*3f1bde29Sjruoho} 65*3f1bde29Sjruoho 66*3f1bde29Sjruohodefault_cleanup() { 67*3f1bde29Sjruoho clean 68*3f1bde29Sjruoho} 69*3f1bde29Sjruoho 70*3f1bde29Sjruohoatf_test_case valid cleanup 71*3f1bde29Sjruohovalid_head() { 72*3f1bde29Sjruoho atf_require_prog stdethers 73*3f1bde29Sjruoho atf_set "descr" "Test valid addresses with stdethers(8)" 74*3f1bde29Sjruoho} 75*3f1bde29Sjruoho 76*3f1bde29Sjruohovalid_body() { 77*3f1bde29Sjruoho check "$(atf_get_srcdir)/d_valid.in" 78*3f1bde29Sjruoho} 79*3f1bde29Sjruoho 80*3f1bde29Sjruohovalid_cleanup() { 81*3f1bde29Sjruoho clean 82*3f1bde29Sjruoho} 83*3f1bde29Sjruoho 84*3f1bde29Sjruohoatf_init_test_cases() { 85*3f1bde29Sjruoho atf_add_test_case default 86*3f1bde29Sjruoho atf_add_test_case valid 87*3f1bde29Sjruoho} 88