11.1Sjruoho# $NetBSD: t_stdethers.sh,v 1.1 2020/06/24 09:47:18 jruoho Exp $
21.1Sjruoho#
31.1Sjruoho# Copyright (c) 2020 The NetBSD Foundation, Inc.
41.1Sjruoho# All rights reserved.
51.1Sjruoho#
61.1Sjruoho# This code is derived from software contributed to The NetBSD Foundation
71.1Sjruoho# by Jukka Ruohonen.
81.1Sjruoho#
91.1Sjruoho# Redistribution and use in source and binary forms, with or without
101.1Sjruoho# modification, are permitted provided that the following conditions
111.1Sjruoho# are met:
121.1Sjruoho# 1. Redistributions of source code must retain the above copyright
131.1Sjruoho#    notice, this list of conditions and the following disclaimer.
141.1Sjruoho# 2. Redistributions in binary form must reproduce the above copyright
151.1Sjruoho#    notice, this list of conditions and the following disclaimer in the
161.1Sjruoho#    documentation and/or other materials provided with the distribution.
171.1Sjruoho#
181.1Sjruoho# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
191.1Sjruoho# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
201.1Sjruoho# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
211.1Sjruoho# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
221.1Sjruoho# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
231.1Sjruoho# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
241.1Sjruoho# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
251.1Sjruoho# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
261.1Sjruoho# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
271.1Sjruoho# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
281.1Sjruoho# POSSIBILITY OF SUCH DAMAGE.
291.1Sjruoho#
301.1Sjruohotmp="/tmp/stdethers"
311.1Sjruoho
321.1Sjruohocheck() {
331.1Sjruoho
341.1Sjruoho	stdethers $1 1>/dev/null 2>$tmp
351.1Sjruoho
361.1Sjruoho	if [ ! $? -eq 0 ]; then
371.1Sjruoho		atf_fail "failed to parse $1"
381.1Sjruoho	fi
391.1Sjruoho
401.1Sjruoho	if [ -s $tmp ]; then
411.1Sjruoho		strerror=$(cat $tmp)
421.1Sjruoho		atf_fail "$strerror"
431.1Sjruoho	fi
441.1Sjruoho}
451.1Sjruoho
461.1Sjruohoclean() {
471.1Sjruoho
481.1Sjruoho	if [ -f $tmp ]; then
491.1Sjruoho		rm $tmp
501.1Sjruoho	fi
511.1Sjruoho}
521.1Sjruoho
531.1Sjruohoatf_test_case default cleanup
541.1Sjruohodefault_head() {
551.1Sjruoho	atf_require_prog stdethers
561.1Sjruoho	atf_set "descr" "Test the system ethers(3) with stdethers(8)"
571.1Sjruoho}
581.1Sjruoho
591.1Sjruohodefault_body() {
601.1Sjruoho
611.1Sjruoho	if [ -f "/etc/ethers" ]; then
621.1Sjruoho		check "/etc/ethers"
631.1Sjruoho	fi
641.1Sjruoho}
651.1Sjruoho
661.1Sjruohodefault_cleanup() {
671.1Sjruoho	clean
681.1Sjruoho}
691.1Sjruoho
701.1Sjruohoatf_test_case valid cleanup
711.1Sjruohovalid_head() {
721.1Sjruoho	atf_require_prog stdethers
731.1Sjruoho	atf_set "descr" "Test valid addresses with stdethers(8)"
741.1Sjruoho}
751.1Sjruoho
761.1Sjruohovalid_body() {
771.1Sjruoho	check "$(atf_get_srcdir)/d_valid.in"
781.1Sjruoho}
791.1Sjruoho
801.1Sjruohovalid_cleanup() {
811.1Sjruoho	clean
821.1Sjruoho}
831.1Sjruoho
841.1Sjruohoatf_init_test_cases() {
851.1Sjruoho	atf_add_test_case default
861.1Sjruoho	atf_add_test_case valid
871.1Sjruoho}
88