1*dd76c272SEnji Cooper# 2*dd76c272SEnji Cooper# Copyright 2015 EMC Corp. 3*dd76c272SEnji Cooper# All rights reserved. 4*dd76c272SEnji Cooper# 5*dd76c272SEnji Cooper# Redistribution and use in source and binary forms, with or without 6*dd76c272SEnji Cooper# modification, are permitted provided that the following conditions are 7*dd76c272SEnji Cooper# met: 8*dd76c272SEnji Cooper# 9*dd76c272SEnji Cooper# * Redistributions of source code must retain the above copyright 10*dd76c272SEnji Cooper# notice, this list of conditions and the following disclaimer. 11*dd76c272SEnji Cooper# * Redistributions in binary form must reproduce the above copyright 12*dd76c272SEnji Cooper# notice, this list of conditions and the following disclaimer in the 13*dd76c272SEnji Cooper# documentation and/or other materials provided with the distribution. 14*dd76c272SEnji Cooper# 15*dd76c272SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16*dd76c272SEnji Cooper# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17*dd76c272SEnji Cooper# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18*dd76c272SEnji Cooper# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19*dd76c272SEnji Cooper# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20*dd76c272SEnji Cooper# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21*dd76c272SEnji Cooper# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22*dd76c272SEnji Cooper# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23*dd76c272SEnji Cooper# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24*dd76c272SEnji Cooper# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25*dd76c272SEnji Cooper# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26*dd76c272SEnji Cooper# 27*dd76c272SEnji Cooper# $FreeBSD$ 28*dd76c272SEnji Cooper# 29*dd76c272SEnji Cooper 30*dd76c272SEnji Cooper# Make sure time(1) is consistent with the FreeBSD time command and not the 31*dd76c272SEnji Cooper# shell interpretation of time(1) 32*dd76c272SEnji CooperTIME=/usr/bin/time 33*dd76c272SEnji Cooper 34*dd76c272SEnji Cooperatf_test_case cputime_hard_flag 35*dd76c272SEnji Coopercputime_hard_flag_body() 36*dd76c272SEnji Cooper{ 37*dd76c272SEnji Cooper 38*dd76c272SEnji Cooper atf_check -e empty -o match:'cputime[[:space:]]+3 secs' -s exit:0 \ 39*dd76c272SEnji Cooper limits -H -t 3 limits -H 40*dd76c272SEnji Cooper atf_check -e empty -o match:'cputime[[:space:]]+3 secs' -s exit:0 \ 41*dd76c272SEnji Cooper limits -H -t 3 limits -S 42*dd76c272SEnji Cooper atf_check -e match:'real[[:space:]]+[34]\.[0-9][0-9]' -o empty -s signal:sigkill \ 43*dd76c272SEnji Cooper limits -H -t 3 $TIME -p sh -c 'while : ; do : ; done' 44*dd76c272SEnji Cooper} 45*dd76c272SEnji Cooper 46*dd76c272SEnji CooperSIGXCPU=24 # atf_check doesn't know sigxcpu 47*dd76c272SEnji Cooper 48*dd76c272SEnji Cooperatf_test_case cputime_soft_flag 49*dd76c272SEnji Coopercputime_soft_flag_body() 50*dd76c272SEnji Cooper{ 51*dd76c272SEnji Cooper 52*dd76c272SEnji Cooper atf_check -e empty -o match:'cputime-max[[:space:]]+infinity secs' -s exit:0 \ 53*dd76c272SEnji Cooper limits -S -t 3 limits -H 54*dd76c272SEnji Cooper atf_check -e empty -o match:'cputime-cur[[:space:]]+3 secs' -s exit:0 \ 55*dd76c272SEnji Cooper limits -S -t 3 limits -S 56*dd76c272SEnji Cooper atf_check -e match:'real[[:space:]]+[34]\.[0-9][0-9]' -o empty -s signal:$SIGXCPU \ 57*dd76c272SEnji Cooper limits -S -t 3 $TIME -p sh -c 'while : ; do : ; done' 58*dd76c272SEnji Cooper} 59*dd76c272SEnji Cooper 60*dd76c272SEnji Cooperatf_init_test_cases() 61*dd76c272SEnji Cooper{ 62*dd76c272SEnji Cooper 63*dd76c272SEnji Cooper atf_add_test_case cputime_hard_flag 64*dd76c272SEnji Cooper atf_add_test_case cputime_soft_flag 65*dd76c272SEnji Cooper} 66