1290567Sngie#
2290567Sngie# Copyright 2015 EMC Corp.
3290567Sngie# All rights reserved.
4290567Sngie#
5290567Sngie# Redistribution and use in source and binary forms, with or without
6290567Sngie# modification, are permitted provided that the following conditions are
7290567Sngie# met:
8290567Sngie#
9290567Sngie# * Redistributions of source code must retain the above copyright
10290567Sngie#   notice, this list of conditions and the following disclaimer.
11290567Sngie# * Redistributions in binary form must reproduce the above copyright
12290567Sngie#   notice, this list of conditions and the following disclaimer in the
13290567Sngie#   documentation and/or other materials provided with the distribution.
14290567Sngie#
15290567Sngie# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16290567Sngie# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17290567Sngie# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18290567Sngie# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19290567Sngie# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20290567Sngie# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21290567Sngie# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22290567Sngie# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23290567Sngie# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24290567Sngie# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25290567Sngie# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26290567Sngie#
27290567Sngie# $FreeBSD: releng/11.0/usr.bin/limits/tests/limits_test.sh 290567 2015-11-09 01:05:31Z ngie $
28290567Sngie#
29290567Sngie
30290567Sngie# Make sure time(1) is consistent with the FreeBSD time command and not the
31290567Sngie# shell interpretation of time(1)
32290567SngieTIME=/usr/bin/time
33290567Sngie
34290567Sngieatf_test_case cputime_hard_flag
35290567Sngiecputime_hard_flag_body()
36290567Sngie{
37290567Sngie
38290567Sngie	atf_check -e empty -o match:'cputime[[:space:]]+3 secs' -s exit:0 \
39290567Sngie	    limits -H -t 3 limits -H
40290567Sngie	atf_check -e empty -o match:'cputime[[:space:]]+3 secs' -s exit:0 \
41290567Sngie	    limits -H -t 3 limits -S
42290567Sngie	atf_check -e match:'real[[:space:]]+[34]\.[0-9][0-9]' -o empty -s signal:sigkill \
43290567Sngie	    limits -H -t 3 $TIME -p sh -c 'while : ; do : ; done'
44290567Sngie}
45290567Sngie
46290567SngieSIGXCPU=24 # atf_check doesn't know sigxcpu
47290567Sngie
48290567Sngieatf_test_case cputime_soft_flag
49290567Sngiecputime_soft_flag_body()
50290567Sngie{
51290567Sngie
52290567Sngie	atf_check -e empty -o match:'cputime-max[[:space:]]+infinity secs' -s exit:0 \
53290567Sngie	    limits -S -t 3 limits -H
54290567Sngie	atf_check -e empty -o match:'cputime-cur[[:space:]]+3 secs' -s exit:0 \
55290567Sngie	    limits -S -t 3 limits -S
56290567Sngie	atf_check -e match:'real[[:space:]]+[34]\.[0-9][0-9]' -o empty -s signal:$SIGXCPU \
57290567Sngie	    limits -S -t 3 $TIME -p sh -c 'while : ; do : ; done'
58290567Sngie}
59290567Sngie
60290567Sngieatf_init_test_cases()
61290567Sngie{
62290567Sngie
63290567Sngie	atf_add_test_case cputime_hard_flag
64290567Sngie	atf_add_test_case cputime_soft_flag
65290567Sngie}
66