Source-Changes-HG archive

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

[src/trunk]: src Atf-ify test for mktime(3)



details:   https://anonhg.NetBSD.org/src/rev/0bf45bb64ab9
branches:  trunk
changeset: 760521:0bf45bb64ab9
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Jan 06 17:20:48 2011 +0000

description:
Atf-ify test for mktime(3)

diffstat:

 distrib/sets/lists/tests/mi |   4 ++-
 tests/lib/libc/Makefile     |   3 +-
 tests/lib/libc/t_mktime.c   |  65 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 2 deletions(-)

diffs (111 lines):

diff -r 8284fa201fb9 -r 0bf45bb64ab9 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Thu Jan 06 16:37:35 2011 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Jan 06 17:20:48 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.213 2011/01/06 15:19:09 njoly Exp $
+# $NetBSD: mi,v 1.214 2011/01/06 17:20:48 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -388,6 +388,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/t_gdtoa.debug                   tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/t_hsearch.debug                 tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/t_inet.debug                    tests-lib-debug         debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/t_mktime.debug                  tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/t_ptm.debug                     tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/t_randomid.debug                        tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/t_strptime.debug                        tests-lib-debug         debug,atf
@@ -1684,6 +1685,7 @@
 ./usr/tests/lib/libc/t_gdtoa                   tests-lib-tests         atf
 ./usr/tests/lib/libc/t_hsearch                 tests-lib-tests         atf
 ./usr/tests/lib/libc/t_inet                    tests-lib-tests         atf
+./usr/tests/lib/libc/t_mktime                  tests-lib-tests         atf
 ./usr/tests/lib/libc/t_nsdispatch              tests-lib-tests         atf
 ./usr/tests/lib/libc/t_protoent                        tests-lib-tests         atf
 ./usr/tests/lib/libc/t_ptm                     tests-lib-tests         atf
diff -r 8284fa201fb9 -r 0bf45bb64ab9 tests/lib/libc/Makefile
--- a/tests/lib/libc/Makefile   Thu Jan 06 16:37:35 2011 +0000
+++ b/tests/lib/libc/Makefile   Thu Jan 06 17:20:48 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.21 2011/01/05 21:17:04 pgoyette Exp $
+# $NetBSD: Makefile,v 1.22 2011/01/06 17:20:48 pgoyette Exp $
 
 .include <bsd.own.mk>
 .include <bsd.sys.mk>
@@ -17,6 +17,7 @@
 TESTS_C+=      t_gdtoa
 TESTS_C+=      t_hsearch
 TESTS_C+=      t_inet
+TESTS_C+=      t_mktime
 TESTS_C+=      t_ptm
 TESTS_C+=      t_randomid
 TESTS_C+=      t_strptime
diff -r 8284fa201fb9 -r 0bf45bb64ab9 tests/lib/libc/t_mktime.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/t_mktime.c Thu Jan 06 17:20:48 2011 +0000
@@ -0,0 +1,65 @@
+/* $NetBSD: t_mktime.c,v 1.1 2011/01/06 17:20:48 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by 
+ *
+ * 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.
+ */
+
+#include <atf-c.h>
+
+#include <err.h>
+#include <errno.h>
+#include <string.h>
+#include <time.h>
+
+ATF_TC(mktime);
+
+ATF_TC_HEAD(mktime, tc)
+{
+
+       atf_tc_set_md_var(tc, "descr", "Test mktime(3) with negative year");
+}
+
+ATF_TC_BODY(mktime, tc)
+{
+       struct tm tms;
+
+       (void)memset(&tms, 0, sizeof(tms));
+       tms.tm_year = ~0;
+
+       errno = 0;
+
+       ATF_REQUIRE_ERRNO(errno, mktime(&tms) != (time_t)-1);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+       ATF_TP_ADD_TC(tp, mktime);
+
+       return atf_no_error();
+}



Home | Main Index | Thread Index | Old Index