Atf-ify test for mktime(3)

This commit is contained in:
pgoyette 2011-01-06 17:20:48 +00:00
parent faebd471be
commit 8659b0cd02
3 changed files with 70 additions and 2 deletions

View File

@ -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

View File

@ -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_convfp
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

65
tests/lib/libc/t_mktime.c Normal file
View File

@ -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();
}