t_ulimit.sh revision 1.2
11.2Schristos# $NetBSD: t_ulimit.sh,v 1.2 2015/12/30 22:24:44 christos 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.1Snjoly
281.1Snjoly# ulimit builtin test.
291.1Snjoly
301.1Snjolyatf_test_case limits
311.1Snjolylimits_head() {
321.1Snjoly	atf_set "descr" "Checks for limits flags"
331.1Snjoly}
341.2Schristos
351.2Schristosget_ulimits() {
361.2Schristos	local limits=$(ulimit -a |
371.2Schristos	    sed -e 's/.*\(-[A-Za-z0-9]\)[^A-Za-z0-9].*/\1/' | sort -u)
381.2Schristos	if [ -z "$limits" ]; then
391.2Schristos		# grr ksh
401.2Schristos		limits="-a -b -c -d -f -l -m -n -p -r -s -t -v"
411.2Schristos	fi
421.2Schristos	echo "$limits"
431.2Schristos}
441.2Schristos
451.1Snjolylimits_body() {
461.1Snjoly	atf_check -s eq:0 -o ignore -e empty \
471.1Snjoly	    /bin/sh -c "ulimit -a"
481.2Schristos	for l in $(get_ulimits)
491.1Snjoly	do
501.1Snjoly	    atf_check -s eq:0 -o ignore -e empty \
511.1Snjoly	        /bin/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