11.4Srillig# $NetBSD: t_ulimit.sh,v 1.4 2024/04/28 07:27:40 rillig Exp $
21.1Snjoly#
31.1Snjoly# Copyright (c) 2012 The NetBSD Foundation, Inc.
41.1Snjoly# All rights reserved.
51.1Snjoly#
61.1Snjoly# Redistribution and use in source and binary forms, with or without
71.1Snjoly# modification, are permitted provided that the following conditions
81.1Snjoly# are met:
91.1Snjoly# 1. Redistributions of source code must retain the above copyright
101.1Snjoly#    notice, this list of conditions and the following disclaimer.
111.1Snjoly# 2. Redistributions in binary form must reproduce the above copyright
121.1Snjoly#    notice, this list of conditions and the following disclaimer in the
131.1Snjoly#    documentation and/or other materials provided with the distribution.
141.1Snjoly#
151.1Snjoly# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
161.1Snjoly# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
171.1Snjoly# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
181.1Snjoly# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
191.1Snjoly# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
201.1Snjoly# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
211.1Snjoly# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
221.1Snjoly# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
231.1Snjoly# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
241.1Snjoly# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
251.1Snjoly# POSSIBILITY OF SUCH DAMAGE.
261.1Snjoly#
271.3Schristos# the implementation of "sh" to test
281.3Schristos: ${TEST_SH:="/bin/sh"}
291.1Snjoly
301.1Snjoly# ulimit builtin test.
311.1Snjoly
321.1Snjolyatf_test_case limits
331.1Snjolylimits_head() {
341.1Snjoly	atf_set "descr" "Checks for limits flags"
351.1Snjoly}
361.2Schristos
371.2Schristosget_ulimits() {
381.3Schristos	local limits=$(${TEST_SH} -c 'ulimit -a' |
391.2Schristos	    sed -e 's/.*\(-[A-Za-z0-9]\)[^A-Za-z0-9].*/\1/' | sort -u)
401.2Schristos	if [ -z "$limits" ]; then
411.2Schristos		# grr ksh
421.2Schristos		limits="-a -b -c -d -f -l -m -n -p -r -s -t -v"
431.2Schristos	fi
441.2Schristos	echo "$limits"
451.2Schristos}
461.2Schristos
471.1Snjolylimits_body() {
481.4Srillig	atf_check -s exit:0 -o ignore -e empty ${TEST_SH} -c "ulimit -a"
491.2Schristos	for l in $(get_ulimits)
501.1Snjoly	do
511.4Srillig	    atf_check -s exit:0 -o ignore -e empty ${TEST_SH} -c "ulimit $l"
521.1Snjoly	done
531.1Snjoly}
541.1Snjoly
551.1Snjolyatf_init_test_cases() {
561.1Snjoly	atf_add_test_case limits
571.1Snjoly}
58