Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/bin/date Add a check for the overflow noted in PR lib/...



details:   https://anonhg.NetBSD.org/src/rev/d19385688b97
branches:  trunk
changeset: 935439:d19385688b97
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Fri Jul 03 03:59:18 2020 +0000

description:
Add a check for the overflow noted in PR lib/46542.

diffstat:

 distrib/sets/lists/tests/mi |   6 ++++-
 etc/mtree/NetBSD.dist.tests |   3 +-
 tests/bin/Makefile          |   4 +-
 tests/bin/date/Makefile     |   8 ++++++
 tests/bin/date/t_date.sh    |  56 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 73 insertions(+), 4 deletions(-)

diffs (124 lines):

diff -r 9f39649215e9 -r d19385688b97 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Fri Jul 03 03:13:10 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Fri Jul 03 03:59:18 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.870 2020/07/01 13:49:26 jruoho Exp $
+# $NetBSD: mi,v 1.871 2020/07/03 03:59:18 jruoho Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -840,6 +840,10 @@
 ./usr/tests/bin/cp/Atffile                                             tests-bin-tests         compattestfile,atf
 ./usr/tests/bin/cp/Kyuafile                                            tests-bin-tests         compattestfile,atf,kyua
 ./usr/tests/bin/cp/t_cp                                                        tests-bin-tests         compattestfile,atf
+./usr/tests/bin/date                                                   tests-bin-tests         compattestfile,atf
+./usr/tests/bin/date/Atffile                                           tests-bin-tests         compattestfile,atf
+./usr/tests/bin/date/Kyuafile                                          tests-bin-tests         compattestfile,atf,kyua
+./usr/tests/bin/date/t_date                                            tests-bin-tests         compattestfile,atf
 ./usr/tests/bin/dd                                                     tests-bin-tests         compattestfile,atf
 ./usr/tests/bin/dd/Atffile                                             tests-bin-tests         compattestfile,atf
 ./usr/tests/bin/dd/Kyuafile                                            tests-bin-tests         compattestfile,atf,kyua
diff -r 9f39649215e9 -r d19385688b97 etc/mtree/NetBSD.dist.tests
--- a/etc/mtree/NetBSD.dist.tests       Fri Jul 03 03:13:10 2020 +0000
+++ b/etc/mtree/NetBSD.dist.tests       Fri Jul 03 03:59:18 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: NetBSD.dist.tests,v 1.171 2020/06/30 20:32:11 riastradh Exp $
+#      $NetBSD: NetBSD.dist.tests,v 1.172 2020/07/03 03:59:18 jruoho Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -186,6 +186,7 @@
 ./usr/tests/bin
 ./usr/tests/bin/cat
 ./usr/tests/bin/cp
+./usr/tests/bin/date
 ./usr/tests/bin/dd
 ./usr/tests/bin/df
 ./usr/tests/bin/expr
diff -r 9f39649215e9 -r d19385688b97 tests/bin/Makefile
--- a/tests/bin/Makefile        Fri Jul 03 03:13:10 2020 +0000
+++ b/tests/bin/Makefile        Fri Jul 03 03:59:18 2020 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.3 2012/03/30 15:49:24 njoly Exp $
+# $NetBSD: Makefile,v 1.4 2020/07/03 03:59:18 jruoho Exp $
 
 .include <bsd.own.mk>
 
 TESTSDIR=       ${TESTSBASE}/bin
 
-TESTS_SUBDIRS= cat cp dd df expr pax ps sh sleep tar
+TESTS_SUBDIRS= cat cp date dd df expr pax ps sh sleep tar
 
 .include <bsd.test.mk>
diff -r 9f39649215e9 -r d19385688b97 tests/bin/date/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/bin/date/Makefile   Fri Jul 03 03:59:18 2020 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2020/07/03 03:59:18 jruoho Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/bin/date
+TESTS_SH=      t_date
+
+.include <bsd.test.mk>
diff -r 9f39649215e9 -r d19385688b97 tests/bin/date/t_date.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/bin/date/t_date.sh  Fri Jul 03 03:59:18 2020 +0000
@@ -0,0 +1,56 @@
+# $NetBSD: t_date.sh,v 1.1 2020/07/03 03:59:18 jruoho Exp $
+#
+# Copyright (c) 2020 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Jukka Ruohonen.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+atf_test_case overflow
+overflow_head() {
+       atf_set "descr" "Check that date(1) does not overflow (PR lib/46542)"
+}
+
+overflow_body() {
+
+       atf_expect_fail "PR lib/46542"
+
+       years="1 10 100 1000 10000 100000 1000000 10000000 \
+             100000000 1000000000 10000000000 100000000000"
+
+       for year in $years; do
+
+               y=$(date +%Y)
+               yy=$(expr $y + $year)
+               yyy=$(date -d "$year years" +%Y)
+
+               if [ ! $yy -eq $yyy ]; then
+                       atf_fail "$yy vs. $yyy"
+               fi
+       done
+}
+
+atf_init_test_cases() {
+       atf_add_test_case overflow
+}



Home | Main Index | Thread Index | Old Index