[Midnightbsd-cvs] src [11497] trunk/usr.bin/limits: sync, add tests

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jul 7 13:35:43 EDT 2018


Revision: 11497
          http://svnweb.midnightbsd.org/src/?rev=11497
Author:   laffer1
Date:     2018-07-07 13:35:43 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
sync, add tests

Modified Paths:
--------------
    trunk/usr.bin/limits/Makefile
    trunk/usr.bin/limits/limits.1
    trunk/usr.bin/limits/limits.c

Added Paths:
-----------
    trunk/usr.bin/limits/tests/
    trunk/usr.bin/limits/tests/Makefile
    trunk/usr.bin/limits/tests/limits_test.sh

Property Changed:
----------------
    trunk/usr.bin/limits/limits.1

Modified: trunk/usr.bin/limits/Makefile
===================================================================
--- trunk/usr.bin/limits/Makefile	2018-07-07 17:34:04 UTC (rev 11496)
+++ trunk/usr.bin/limits/Makefile	2018-07-07 17:35:43 UTC (rev 11497)
@@ -1,7 +1,14 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/limits/Makefile 290898 2015-11-16 00:58:31Z ngie $
 
+.include <bsd.own.mk>
+
 PROG=	limits
 DPADD=	${LIBUTIL}
 LDADD=	-lutil
 
+.if ${MK_TESTS} != "no"
+SUBDIR+=	tests
+.endif
+
 .include <bsd.prog.mk>

Modified: trunk/usr.bin/limits/limits.1
===================================================================
--- trunk/usr.bin/limits/limits.1	2018-07-07 17:34:04 UTC (rev 11496)
+++ trunk/usr.bin/limits/limits.1	2018-07-07 17:35:43 UTC (rev 11497)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 1996 David Nugent <davidn at blaze.net.au>
 .\" All rights reserved.
 .\"
@@ -17,7 +18,7 @@
 .\" 5. Modifications may be freely made to this file providing the above
 .\"    conditions are met.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/limits/limits.1 235211 2012-05-10 02:07:00Z gjb $
 .\"
 .Dd January 23, 2012
 .Dt LIMITS 1


Property changes on: trunk/usr.bin/limits/limits.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/limits/limits.c
===================================================================
--- trunk/usr.bin/limits/limits.c	2018-07-07 17:34:04 UTC (rev 11496)
+++ trunk/usr.bin/limits/limits.c	2018-07-07 17:35:43 UTC (rev 11497)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1997 by
  * David L. Nugent <davidn at blaze.net.au>
@@ -22,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/limits/limits.c 319256 2017-05-30 21:58:53Z asomers $");
 
 #include <err.h>
 #include <stdio.h>
@@ -89,8 +90,7 @@
 	  { "  sbsize%-4s           %8s", " bytes\n", 1    },
 	  { "  vmemoryuse%-4s       %8s", " kB\n",    1024 },
 	  { "  pseudo-terminals%-4s %8s", "\n",       1    },
-	  { "  swapuse%-4s          %8s", " kB\n",    1024 },
-	  { "  kqueues%-4s          %8s", "\n",       1    },
+	  { "  swapuse%-4s          %8s", " kB\n",    1024 }
       }
     },
     { "sh", "unlimited", "", " -H", " -S", "",
@@ -107,8 +107,7 @@
 	  { "ulimit%s -b %s", ";\n",  1    },
 	  { "ulimit%s -v %s", ";\n",  1024 },
 	  { "ulimit%s -p %s", ";\n",  1    },
-	  { "ulimit%s -w %s", ";\n",  1024 },
-	  { "ulimit%s -k %s", ";\n",  1    },
+	  { "ulimit%s -w %s", ";\n",  1024 }
       }
     },
     { "csh", "unlimited", "", " -h", "", NULL,
@@ -125,8 +124,7 @@
 	  { "limit%s sbsize %s",          ";\n",  1    },
 	  { "limit%s vmemoryuse %s",      ";\n",  1024 },
 	  { "limit%s pseudoterminals %s", ";\n",  1    },
-	  { "limit%s swapuse %s",         ";\n",  1024 },
-	  { "limit%s kqueues %s",         ";\n",  1    },
+	  { "limit%s swapuse %s",         ";\n",  1024 }
       }
     },
     { "bash|bash2", "unlimited", "", " -H", " -S", "",
@@ -160,8 +158,7 @@
 	  { "limit%s sbsize %s",          ";\n",  1    },
 	  { "limit%s vmemoryuse %s",      ";\n",  1024 },
 	  { "limit%s pseudoterminals %s", ";\n",  1    },
-	  { "limit%s swapuse %s",         ";\n",  1024 },
-	  { "limit%s kqueues %s",         ";\n",  1    },
+	  { "limit%s swapuse %s",         ";\n",  1024 }
       }
     },
     { "ksh|pdksh", "unlimited", "", " -H", " -S", "",
@@ -236,13 +233,12 @@
     { "sbsize",		login_getcapsize },
     { "vmemoryuse",	login_getcapsize },
     { "pseudoterminals",login_getcapnum  },
-    { "swapuse",	login_getcapsize },
-    { "kqueues",	login_getcapnum  },
+    { "swapuse",	login_getcapsize }
 };
 
 /*
  * One letter for each resource levels.
- * NOTE: There is a dependancy on the corresponding
+ * NOTE: There is a dependency on the corresponding
  * letter index being equal to the resource number.
  * If sys/resource.h defines are changed, this needs
  * to be modified accordingly!
@@ -554,7 +550,7 @@
     char numbr[64];
 
     if (limit == RLIM_INFINITY)
-	strcpy(numbr, inf);
+	strlcpy(numbr, inf, sizeof(numbr));
     else
 	sprintf(numbr, "%jd", (intmax_t)((limit + divisor/2) / divisor));
     printf(pfx, which, numbr);
@@ -652,7 +648,6 @@
 	case RLIMIT_NPROC:
 	case RLIMIT_NOFILE:
 	case RLIMIT_NPTS:
-	case RLIMIT_KQUEUES:
 	    res = strtoq(s, &e, 0);
 	    s = e;
 	    break;

Added: trunk/usr.bin/limits/tests/Makefile
===================================================================
--- trunk/usr.bin/limits/tests/Makefile	                        (rev 0)
+++ trunk/usr.bin/limits/tests/Makefile	2018-07-07 17:35:43 UTC (rev 11497)
@@ -0,0 +1,8 @@
+# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/limits/tests/Makefile 290898 2015-11-16 00:58:31Z ngie $
+
+TESTSDIR=	${TESTSBASE}/usr.bin/limits
+
+ATF_TESTS_SH+=	limits_test
+
+.include <bsd.test.mk>


Property changes on: trunk/usr.bin/limits/tests/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/usr.bin/limits/tests/limits_test.sh
===================================================================
--- trunk/usr.bin/limits/tests/limits_test.sh	                        (rev 0)
+++ trunk/usr.bin/limits/tests/limits_test.sh	2018-07-07 17:35:43 UTC (rev 11497)
@@ -0,0 +1,65 @@
+#
+# Copyright 2015 EMC Corp.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD: stable/10/usr.bin/limits/tests/limits_test.sh 290567 2015-11-09 01:05:31Z ngie $
+# $MidnightBSD$
+
+# Make sure time(1) is consistent with the FreeBSD time command and not the
+# shell interpretation of time(1)
+TIME=/usr/bin/time
+
+atf_test_case cputime_hard_flag
+cputime_hard_flag_body()
+{
+
+	atf_check -e empty -o match:'cputime[[:space:]]+3 secs' -s exit:0 \
+	    limits -H -t 3 limits -H
+	atf_check -e empty -o match:'cputime[[:space:]]+3 secs' -s exit:0 \
+	    limits -H -t 3 limits -S
+	atf_check -e match:'real[[:space:]]+[34]\.[0-9][0-9]' -o empty -s signal:sigkill \
+	    limits -H -t 3 $TIME -p sh -c 'while : ; do : ; done'
+}
+
+SIGXCPU=24 # atf_check doesn't know sigxcpu
+
+atf_test_case cputime_soft_flag
+cputime_soft_flag_body()
+{
+
+	atf_check -e empty -o match:'cputime-max[[:space:]]+infinity secs' -s exit:0 \
+	    limits -S -t 3 limits -H
+	atf_check -e empty -o match:'cputime-cur[[:space:]]+3 secs' -s exit:0 \
+	    limits -S -t 3 limits -S
+	atf_check -e match:'real[[:space:]]+[34]\.[0-9][0-9]' -o empty -s signal:$SIGXCPU \
+	    limits -S -t 3 $TIME -p sh -c 'while : ; do : ; done'
+}
+
+atf_init_test_cases()
+{
+
+	atf_add_test_case cputime_hard_flag
+	atf_add_test_case cputime_soft_flag
+}


Property changes on: trunk/usr.bin/limits/tests/limits_test.sh
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list