Moving more tests out of regress and into atf mainstream

This commit is contained in:
pgoyette 2010-12-31 14:36:10 +00:00
parent 8aaffbf4e9
commit b9bd4f1954
8 changed files with 1157 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.198 2010/12/31 04:08:32 pgoyette Exp $
# $NetBSD: mi,v 1.199 2010/12/31 14:36:10 pgoyette Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -367,9 +367,15 @@
./usr/libdata/debug/usr/tests/lib/libc/string/t_string.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/string/t_stresep.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/string/t_swab.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/t_clone.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/t_context.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/t_convfp.debug tests-lib-debug debug,atf
./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_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
./usr/libdata/debug/usr/tests/lib/libdes tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libdes/t_des.debug tests-lib-debug debug,atf,crypto
./usr/libdata/debug/usr/tests/lib/semaphore tests-lib-debug
@ -1629,9 +1635,15 @@
./usr/tests/lib/libc/string/t_string tests-lib-tests atf
./usr/tests/lib/libc/string/t_stresep tests-lib-tests atf
./usr/tests/lib/libc/string/t_swab tests-lib-tests atf
./usr/tests/lib/libc/t_clone tests-lib-tests atf
./usr/tests/lib/libc/t_context tests-lib-tests atf
./usr/tests/lib/libc/t_convfp tests-lib-tests atf
./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_ptm tests-lib-tests atf
./usr/tests/lib/libc/t_randomid tests-lib-tests atf
./usr/tests/lib/libc/t_strptime tests-lib-tests atf
./usr/tests/lib/libdes tests-lib-tests
./usr/tests/lib/libdes/Atffile tests-lib-tests atf,crypto
./usr/tests/lib/libdes/t_des tests-lib-tests atf,crypto

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.14 2010/12/31 05:05:43 pgoyette Exp $
# $NetBSD: Makefile,v 1.15 2010/12/31 14:36:11 pgoyette Exp $
.include <bsd.own.mk>
.include <bsd.sys.mk>
@ -11,8 +11,14 @@ TESTS_SUBDIRS+= ssp
TESTSDIR= ${TESTSBASE}/lib/libc
TESTS_C+= t_clone
TESTS_C+= t_context
TESTS_C+= t_convfp
TESTS_C+= t_gdtoa
TESTS_C+= t_hsearch
TESTS_C+= t_inet
TESTS_C+= t_ptm
TESTS_C+= t_randomid
TESTS_C+= t_strptime
.include <bsd.test.mk>

262
tests/lib/libc/t_clone.c Normal file
View File

@ -0,0 +1,262 @@
/* $NetBSD: t_clone.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_clone.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $");
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <atf-c.h>
#define STACKSIZE (8 * 1024)
#define FROBVAL 41973
#define CHILDEXIT 0xa5
/*
* return 1 if the stack grows down, 0 if it grows up.
*/
static int
stackdir(void *p)
{
int val;
void *q = &val;
return p < q ? 0 : 1;
}
static int
dummy(void *arg)
{
return 0;
}
ATF_TC(clone);
ATF_TC_HEAD(clone, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks clone(2)");
}
static int
clone_func(void *arg)
{
long *frobp = arg, diff;
printf("child: stack ~= %p, frobme = %p\n", &frobp, frobp);
fflush(stdout);
if (frobp[0] != getppid())
return 1;
if (frobp[0] == getpid())
return 2;
diff = labs(frobp[1] - (long) &frobp);
if (diff > 1024)
return 3;
frobp[1] = FROBVAL;
return (CHILDEXIT);
}
ATF_TC_BODY(clone, tc)
{
sigset_t mask;
void *allocstack, *stack;
pid_t pid;
volatile long frobme[2];
int stat;
allocstack = mmap(NULL, STACKSIZE, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_ANON, -1, (off_t) 0);
ATF_REQUIRE_ERRNO(errno, allocstack != MAP_FAILED);
stack = (caddr_t) allocstack + STACKSIZE * stackdir(&stat);
printf("parent: stack = %p, frobme = %p\n", stack, frobme);
fflush(stdout);
frobme[0] = (long)getpid();
frobme[1] = (long)stack;
sigemptyset(&mask);
sigaddset(&mask, SIGUSR1);
ATF_REQUIRE_ERRNO(errno, sigprocmask(SIG_BLOCK, &mask, NULL) != -1);
switch (pid = __clone(clone_func, stack,
CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|SIGUSR1,
__UNVOLATILE(frobme))) {
case 0:
atf_tc_fail("clone() returned 0");
/*NOTREACHED*/
case -1:
atf_tc_fail("clone() failed: %s", strerror(errno));
/*NOTREACHED*/
default:
while (waitpid(pid, &stat, __WCLONE) != pid)
continue;
}
ATF_REQUIRE_MSG(WIFEXITED(stat) != 0, "child didn't exit");
printf("parent: childexit = 0x%x, frobme = %ld\n",
WEXITSTATUS(stat), frobme[1]);
switch (WEXITSTATUS(stat)) {
case CHILDEXIT:
ATF_REQUIRE_EQ(frobme[1], FROBVAL);
break;
case 1:
atf_tc_fail("child: argument does not contain parent's pid");
/*NOTREACHED*/
case 2:
atf_tc_fail("child: called in parent's pid");
/*NOTREACHED*/
case 3:
atf_tc_fail("child: called with bad stack");
/*NOTREACHED*/
default:
atf_tc_fail("child returned unknown code: %d",
WEXITSTATUS(stat));
/*NOTREACHED*/
}
ATF_REQUIRE_ERRNO(errno, munmap(allocstack, STACKSIZE) != -1);
}
ATF_TC(null_stack);
ATF_TC_HEAD(null_stack, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks that clone(2) fails when stack pointer is NULL");
}
ATF_TC_BODY(null_stack, tc)
{
int rv;
rv = __clone(dummy, NULL,
CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|SIGCHLD, NULL);
ATF_REQUIRE_EQ(rv, -1);
ATF_REQUIRE_EQ(errno, EINVAL);
}
ATF_TC(null_func);
ATF_TC_HEAD(null_func, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks that clone(2) fails when function pointer is NULL");
}
ATF_TC_BODY(null_func, tc)
{
void *allocstack, *stack;
int rv, stat;
allocstack = mmap(NULL, STACKSIZE, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_ANON, -1, (off_t) 0);
ATF_REQUIRE_ERRNO(errno, allocstack != MAP_FAILED);
stack = (caddr_t) allocstack + STACKSIZE * stackdir(&stat);
errno = 0;
rv = __clone(0, stack,
CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|SIGCHLD, NULL);
ATF_REQUIRE_EQ(rv, -1);
ATF_REQUIRE_EQ(errno, EINVAL);
ATF_REQUIRE_ERRNO(errno, munmap(allocstack, STACKSIZE) != -1);
}
ATF_TC(out_of_proc);
ATF_TC_HEAD(out_of_proc, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks that clone(2) fails when running out of processes");
atf_tc_set_md_var(tc, "require.user", "unprivileged");
}
ATF_TC_BODY(out_of_proc, tc)
{
struct rlimit rl;
int rv;
ATF_REQUIRE_ERRNO(errno, getrlimit(RLIMIT_NPROC, &rl) != -1);
rl.rlim_cur = 0;
rl.rlim_max = 0;
ATF_REQUIRE_ERRNO(errno, setrlimit(RLIMIT_NPROC, &rl) != -1);
errno = 0;
rv = __clone(dummy, malloc(10240),
CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|SIGCHLD, (void *)&rl);
ATF_REQUIRE_EQ(rv, -1);
ATF_REQUIRE_EQ(errno, EAGAIN);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, clone);
ATF_TP_ADD_TC(tp, null_stack);
ATF_TP_ADD_TC(tp, null_func);
ATF_TP_ADD_TC(tp, out_of_proc);
return atf_no_error();
}

102
tests/lib/libc/t_context.c Normal file
View File

@ -0,0 +1,102 @@
/* $NetBSD: t_context.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* 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 <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_context.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $");
#include <ucontext.h>
#include <stdarg.h>
#include <stdlib.h>
#include <atf-c.h>
#define STACKSZ (10*1024)
#define DEPTH 3
static int calls;
static void
run(int n, ...)
{
va_list va;
int i, ia;
ATF_REQUIRE_EQ(n, DEPTH - calls - 1);
va_start(va, n);
for (i = 0; i < 9; i++) {
ia = va_arg(va, int);
ATF_REQUIRE_EQ(i, ia);
}
va_end(va);
calls++;
}
ATF_TC(context);
ATF_TC_HEAD(context, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks get/make/setcontext(), context linking via uc_link(), "
"and argument passing to the new context");
}
ATF_TC_BODY(context, tc)
{
ucontext_t uc[DEPTH];
ucontext_t save;
volatile int i = 0; /* avoid longjmp clobbering */
for (i = 0; i < DEPTH; ++i) {
ATF_REQUIRE_EQ(getcontext(&uc[i]), 0);
uc[i].uc_stack.ss_sp = malloc(STACKSZ);
uc[i].uc_stack.ss_size = STACKSZ;
uc[i].uc_link = (i > 0) ? &uc[i - 1] : &save;
makecontext(&uc[i], (void *)run, 10, i,
0, 1, 2, 3, 4, 5, 6, 7, 8);
}
ATF_REQUIRE_EQ(getcontext(&save), 0);
if (calls == 0)
ATF_REQUIRE_EQ(setcontext(&uc[DEPTH-1]), 0);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, context);
return atf_no_error();
}

249
tests/lib/libc/t_hsearch.c Normal file
View File

@ -0,0 +1,249 @@
/* $NetBSD: t_hsearch.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* 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.
*/
/*
* Copyright (c) 2001 Christopher G. Demetriou
* All rights reserved.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the
* NetBSD Project. See http://www.NetBSD.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_hsearch.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $");
#include <errno.h>
#include <search.h>
#include <string.h>
#include <stdio.h>
#include <atf-c.h>
#define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno))
ATF_TC(basic);
ATF_TC_HEAD(basic, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks basic insertions and searching");
}
ATF_TC_BODY(basic, tc)
{
ENTRY e, *ep;
char ch[2];
int i;
REQUIRE_ERRNO(hcreate(16) != 0);
/* ch[1] should be constant from here on down. */
ch[1] = '\0';
/* Basic insertions. Check enough that there'll be collisions. */
for (i = 0; i < 26; i++) {
ch[0] = 'a' + i;
e.key = strdup(ch); /* ptr to provided key is kept! */
ATF_REQUIRE(e.key != NULL);
e.data = (void *)(long)i;
ep = hsearch(e, ENTER);
ATF_REQUIRE(ep != NULL);
ATF_REQUIRE_STREQ(ep->key, ch);
ATF_REQUIRE_EQ((long)ep->data, i);
}
/* e.key should be constant from here on down. */
e.key = ch;
/* Basic lookups. */
for (i = 0; i < 26; i++) {
ch[0] = 'a' + i;
ep = hsearch(e, FIND);
ATF_REQUIRE(ep != NULL);
ATF_REQUIRE_STREQ(ep->key, ch);
ATF_REQUIRE_EQ((long)ep->data, i);
}
hdestroy();
}
ATF_TC(duplicate);
ATF_TC_HEAD(duplicate, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks that inserting duplicate "
"doesn't overwrite existing data");
}
ATF_TC_BODY(duplicate, tc)
{
ENTRY e, *ep;
REQUIRE_ERRNO(hcreate(16));
e.key = strdup("a");
ATF_REQUIRE(e.key != NULL);
e.data = (void *)(long) 0;
ep = hsearch(e, ENTER);
ATF_REQUIRE(ep != NULL);
ATF_REQUIRE_STREQ(ep->key, "a");
ATF_REQUIRE_EQ((long)ep->data, 0);
e.data = (void *)(long)12345;
ep = hsearch(e, ENTER);
ep = hsearch(e, FIND);
ATF_REQUIRE(ep != NULL);
ATF_REQUIRE_STREQ(ep->key, "a");
ATF_REQUIRE_EQ((long)ep->data, 0);
hdestroy();
}
ATF_TC(nonexistent);
ATF_TC_HEAD(nonexistent, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks searching for non-existent entry");
}
ATF_TC_BODY(nonexistent, tc)
{
ENTRY e, *ep;
REQUIRE_ERRNO(hcreate(16));
e.key = strdup("A");
ep = hsearch(e, FIND);
ATF_REQUIRE_EQ(ep, NULL);
hdestroy();
}
ATF_TC(two);
ATF_TC_HEAD(two, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks that searching doesn't overwrite previous search results");
}
ATF_TC_BODY(two, tc)
{
ENTRY e, *ep, *ep2;
char *sa, *sb;
ATF_REQUIRE((sa = strdup("a")) != NULL);
ATF_REQUIRE((sb = strdup("b")) != NULL);
REQUIRE_ERRNO(hcreate(16));
e.key = sa;
e.data = (void*)(long)0;
ep = hsearch(e, ENTER);
ATF_REQUIRE(ep != NULL);
ATF_REQUIRE_STREQ(ep->key, "a");
ATF_REQUIRE_EQ((long)ep->data, 0);
e.key = sb;
e.data = (void*)(long)1;
ep = hsearch(e, ENTER);
ATF_REQUIRE(ep != NULL);
ATF_REQUIRE_STREQ(ep->key, "b");
ATF_REQUIRE_EQ((long)ep->data, 1);
e.key = sa;
ep = hsearch(e, FIND);
e.key = sb;
ep2 = hsearch(e, FIND);
ATF_REQUIRE(ep != NULL);
ATF_REQUIRE_STREQ(ep->key, "a");
ATF_REQUIRE_EQ((long)ep->data, 0);
ATF_REQUIRE(ep2 != NULL);
ATF_REQUIRE_STREQ(ep2->key, "b");
ATF_REQUIRE_EQ((long)ep2->data, 1);
hdestroy();
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, basic);
ATF_TP_ADD_TC(tp, duplicate);
ATF_TP_ADD_TC(tp, nonexistent);
ATF_TP_ADD_TC(tp, two);
return atf_no_error();
}

98
tests/lib/libc/t_inet.c Normal file
View File

@ -0,0 +1,98 @@
/* $NetBSD: t_inet.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Brian Ginsbach.
*
* 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 <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_inet.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $");
#include <arpa/inet.h>
#include <atf-c.h>
#define H_REQUIRE(input, expected) \
ATF_REQUIRE_EQ_MSG(inet_network(input), (in_addr_t) expected, \
"inet_network(%s) returned: 0x%08X, expected: %s", #input, \
inet_network(input), #expected)
ATF_TC(inet_network);
ATF_TC_HEAD(inet_network, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks inet_network(3)");
}
ATF_TC_BODY(inet_network, tc)
{
H_REQUIRE("0x12", 0x00000012);
H_REQUIRE("127.1", 0x00007f01);
H_REQUIRE("127.1.2.3", 0x7f010203);
H_REQUIRE("0X12", 0x00000012);
H_REQUIRE("0", 0x0);
H_REQUIRE("01.02.07.077", 0x0102073f);
H_REQUIRE("0x1.23.045.0", 0x01172500);
H_REQUIRE("0x12.0x34", 0x00001234);
/* yes, this is valid (because of the trailing space after the digit) */
H_REQUIRE("1 bar", 0x00000001);
/* malformed requests */
H_REQUIRE("4.2.3.1.", 0xffffffff);
H_REQUIRE("0x123456", 0xffffffff);
H_REQUIRE("0x12.0x345", 0xffffffff);
H_REQUIRE("1.2.3.4.5", 0xffffffff);
H_REQUIRE("1..3.4", 0xffffffff);
H_REQUIRE(".", 0xffffffff);
H_REQUIRE("1.", 0xffffffff);
H_REQUIRE(".1", 0xffffffff);
H_REQUIRE("0x", 0xffffffff);
H_REQUIRE("", 0xffffffff);
H_REQUIRE(" ", 0xffffffff);
H_REQUIRE("bar", 0xffffffff);
H_REQUIRE("1.2bar", 0xffffffff);
H_REQUIRE("1.", 0xffffffff);
H_REQUIRE("\xc3\x8a\xc3\x83\xc3\x95\xc3\x8b\xc3\x85\xc3\x8e",
0xffffffff);
H_REQUIRE("255.255.255.255", 0xffffffff);
H_REQUIRE("x", 0xffffffff);
H_REQUIRE("078", 0xffffffff);
H_REQUIRE("127.0xfff", 0xffffffff);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, inet_network);
return atf_no_error();
}

174
tests/lib/libc/t_ptm.c Normal file
View File

@ -0,0 +1,174 @@
/* $NetBSD: t_ptm.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $ */
/*
* Copyright (c) 2004, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* 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 <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_ptm.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $");
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <atf-c.h>
#define REQUIRE_ERRNO(x, v) \
ATF_REQUIRE_MSG(x != v, "%s: %s", #x, strerror(errno))
ATF_TC(ptm);
ATF_TC_HEAD(ptm, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks /dev/ptm device");
}
ATF_TC_BODY(ptm, tc)
{
struct stat stm, sts;
struct ptmget ptm;
int fdm;
struct group *gp;
if ((fdm = open("/dev/ptm", O_RDWR)) == -1) {
if (errno == ENOENT || errno == ENODEV)
atf_tc_skip("/dev/ptm: %s", strerror(errno));
atf_tc_fail("/dev/ptm: %s", strerror(errno));
}
REQUIRE_ERRNO(fstat(fdm, &stm), -1);
ATF_REQUIRE_EQ(major(stm.st_rdev), 165);
REQUIRE_ERRNO(ioctl(fdm, TIOCPTMGET, &ptm), -1);
ATF_REQUIRE_MSG(strncmp(ptm.cn, "/dev/pty", 8) == 0
|| strncmp(ptm.cn, "/dev/null", 9) == 0,
"bad master name: %s", ptm.cn);
ATF_REQUIRE_MSG(strncmp(ptm.sn, "/dev/tty", 8) == 0
|| strncmp(ptm.sn, "/dev/pts/", 9) == 0,
"bad slave name: %s", ptm.sn);
if (strncmp(ptm.cn, "/dev/null", 9) != 0) {
REQUIRE_ERRNO(fstat(ptm.cfd, &stm), -1);
REQUIRE_ERRNO(stat(ptm.cn, &sts), -1);
ATF_REQUIRE_EQ(stm.st_rdev, sts.st_rdev);
}
REQUIRE_ERRNO(fstat(ptm.sfd, &stm), -1);
REQUIRE_ERRNO(stat(ptm.sn, &sts), -1);
ATF_REQUIRE_EQ(stm.st_rdev, sts.st_rdev);
ATF_REQUIRE_EQ_MSG(sts.st_uid, getuid(), "bad slave uid");
ATF_REQUIRE_MSG((gp = getgrnam("tty")) != NULL,
"cannot find `tty' group");
ATF_REQUIRE_EQ_MSG(sts.st_gid, gp->gr_gid, "bad slave grid");
(void)close(ptm.sfd);
(void)close(ptm.cfd);
(void)close(fdm);
}
/*
* On NetBSD /dev/ptyp0 == /dev/pts/0 so we can check for major
* and minor device numbers. This check is non-portable. This
* check is now disabled because we might not have /dev/ptyp0
* at all.
*/
/*
* #define PTY_DEVNO_CHECK
*/
ATF_TC(ptmx);
ATF_TC_HEAD(ptmx, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks /dev/ptmx device");
}
ATF_TC_BODY(ptmx, tc)
{
struct stat stm, sts;
char *pty;
int fdm, fds;
struct group *gp;
if ((fdm = posix_openpt(O_RDWR|O_NOCTTY)) == -1) {
if (errno == ENOENT || errno == ENODEV)
atf_tc_skip("/dev/ptmx: %s", strerror(errno));
atf_tc_fail("/dev/ptmx: %s", strerror(errno));
}
REQUIRE_ERRNO(fstat(fdm, &stm), -1);
#ifdef PTY_DEVNO_CHECK
REQUIRE_ERRNO(stat("/dev/ptyp0", &sts), -1);
ATF_REQUIRE_EQ_MSG(major(stm.st_rdev), major(sts.st_rdev),
"bad master major number");
#endif
REQUIRE_ERRNO(grantpt(fdm), -1);
REQUIRE_ERRNO(unlockpt(fdm), -1);
REQUIRE_ERRNO((pty = ptsname(fdm)), NULL);
REQUIRE_ERRNO((fds = open(pty, O_RDWR|O_NOCTTY)), -1);
REQUIRE_ERRNO(fstat(fds, &sts), -1);
#ifdef PTY_DEVNO_CHECK
ATF_REQUIRE_EQ_MSG(minor(stm.st_rdev), minor(sts.st_rdev),
"bad slave minor number");
#endif
ATF_REQUIRE_EQ_MSG(sts.st_uid, getuid(), "bad slave uid");
ATF_REQUIRE_MSG((gp = getgrnam("tty")) != NULL,
"cannot find `tty' group");
ATF_REQUIRE_EQ_MSG(sts.st_gid, gp->gr_gid, "bad slave gid");
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, ptm);
ATF_TP_ADD_TC(tp, ptmx);
return atf_no_error();
}

252
tests/lib/libc/t_strptime.c Normal file
View File

@ -0,0 +1,252 @@
/* $NetBSD: t_strptime.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $ */
/*-
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by David Laight.
*
* 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 <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_strptime.c,v 1.1 2010/12/31 14:36:11 pgoyette Exp $");
#include <time.h>
#include <atf-c.h>
static void
h_pass(const char *buf, const char *fmt, int len,
int tm_sec, int tm_min, int tm_hour, int tm_mday,
int tm_mon, int tm_year, int tm_wday, int tm_yday)
{
struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
const char *ret, *exp;
exp = buf + len;
ret = strptime(buf, fmt, &tm);
ATF_REQUIRE_MSG(ret == exp,
"strptime(\"%s\", \"%s\", tm): incorrect return code: "
"expected: %p, got: %p", buf, fmt, exp, ret);
#define H_REQUIRE_FIELD(field) \
ATF_REQUIRE_MSG(tm.field == field, \
"strptime(\"%s\", \"%s\", tm): incorrect %s: " \
"expected: %d, but got: %d", buf, fmt, \
___STRING(field), field, tm.field)
H_REQUIRE_FIELD(tm_sec);
H_REQUIRE_FIELD(tm_min);
H_REQUIRE_FIELD(tm_hour);
H_REQUIRE_FIELD(tm_mday);
H_REQUIRE_FIELD(tm_mon);
H_REQUIRE_FIELD(tm_year);
H_REQUIRE_FIELD(tm_wday);
H_REQUIRE_FIELD(tm_yday);
#undef H_REQUIRE_FIELD
}
static void
h_fail(const char *buf, const char *fmt)
{
struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
ATF_REQUIRE_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", "
"\"%s\", &tm) should fail, but it didn't", buf, fmt);
}
ATF_TC(common);
ATF_TC_HEAD(common, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks strptime(3): various checks");
}
ATF_TC_BODY(common, tc)
{
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y",
24, 46, 27, 23, 20, 0, 98, 2, -1);
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y",
24, 46, 27, 23, 20, 0, 98, 2, -1);
h_pass("Tue Jan 20 23:27:46 1998", "%c",
24, 46, 27, 23, 20, 0, 98, 2, -1);
h_pass("Fri Mar 4 20:05:34 2005", "%a %b %e %H:%M:%S %Y",
24, 34, 5, 20, 4, 2, 105, 5, -1);
h_pass("5\t3 4 8pm:05:34 2005", "%w%n%m%t%d%n%k%p:%M:%S %Y",
21, 34, 5, 20, 4, 2, 105, 5, -1);
h_pass("Fri Mar 4 20:05:34 2005", "%c",
24, 34, 5, 20, 4, 2, 105, 5, -1);
h_pass("x20y", "x%Cy", 4, -1, -1, -1, -1, -1, 100, -1, -1);
h_pass("x84y", "x%yy", 4, -1, -1, -1, -1, -1, 84, -1, -1);
h_pass("x2084y", "x%C%yy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
h_pass("x8420y", "x%y%Cy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
h_pass("%20845", "%%%C%y5", 6, -1, -1, -1, -1, -1, 184, -1, -1);
h_fail("%", "%E%");
h_pass("1980", "%Y", 4, -1, -1, -1, -1, -1, 80, -1, -1);
h_pass("1980", "%EY", 4, -1, -1, -1, -1, -1, 80, -1, -1);
h_pass("0", "%S", 1, 0, -1, -1, -1, -1, -1, -1, -1);
h_pass("59", "%S", 2, 59, -1, -1, -1, -1, -1, -1, -1);
h_pass("60", "%S", 2, 60, -1, -1, -1, -1, -1, -1, -1);
h_pass("61", "%S", 2, 61, -1, -1, -1, -1, -1, -1, -1);
h_fail("62", "%S");
}
ATF_TC(day);
ATF_TC_HEAD(day, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks strptime(3): day names");
}
ATF_TC_BODY(day, tc)
{
h_pass("Sun", "%a", 3, -1, -1, -1, -1, -1, -1, 0, -1);
h_pass("Sunday", "%a", 6, -1, -1, -1, -1, -1, -1, 0, -1);
h_pass("Mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1);
h_pass("Monday", "%a", 6, -1, -1, -1, -1, -1, -1, 1, -1);
h_pass("Tue", "%a", 3, -1, -1, -1, -1, -1, -1, 2, -1);
h_pass("Tuesday", "%a", 7, -1, -1, -1, -1, -1, -1, 2, -1);
h_pass("Wed", "%a", 3, -1, -1, -1, -1, -1, -1, 3, -1);
h_pass("Wednesday", "%a", 9, -1, -1, -1, -1, -1, -1, 3, -1);
h_pass("Thu", "%a", 3, -1, -1, -1, -1, -1, -1, 4, -1);
h_pass("Thursday", "%a", 8, -1, -1, -1, -1, -1, -1, 4, -1);
h_pass("Fri", "%a", 3, -1, -1, -1, -1, -1, -1, 5, -1);
h_pass("Friday", "%a", 6, -1, -1, -1, -1, -1, -1, 5, -1);
h_pass("Sat", "%a", 3, -1, -1, -1, -1, -1, -1, 6, -1);
h_pass("Saturday", "%a", 8, -1, -1, -1, -1, -1, -1, 6, -1);
h_pass("Saturn", "%a", 3, -1, -1, -1, -1, -1, -1, 6, -1);
h_fail("Moon", "%a");
h_pass("Sun", "%A", 3, -1, -1, -1, -1, -1, -1, 0, -1);
h_pass("Sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1);
h_pass("Mon", "%A", 3, -1, -1, -1, -1, -1, -1, 1, -1);
h_pass("Monday", "%A", 6, -1, -1, -1, -1, -1, -1, 1, -1);
h_pass("Tue", "%A", 3, -1, -1, -1, -1, -1, -1, 2, -1);
h_pass("Tuesday", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1);
h_pass("Wed", "%A", 3, -1, -1, -1, -1, -1, -1, 3, -1);
h_pass("Wednesday", "%A", 9, -1, -1, -1, -1, -1, -1, 3, -1);
h_pass("Thu", "%A", 3, -1, -1, -1, -1, -1, -1, 4, -1);
h_pass("Thursday", "%A", 8, -1, -1, -1, -1, -1, -1, 4, -1);
h_pass("Fri", "%A", 3, -1, -1, -1, -1, -1, -1, 5, -1);
h_pass("Friday", "%A", 6, -1, -1, -1, -1, -1, -1, 5, -1);
h_pass("Sat", "%A", 3, -1, -1, -1, -1, -1, -1, 6, -1);
h_pass("Saturday", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1);
h_pass("Saturn", "%A", 3, -1, -1, -1, -1, -1, -1, 6, -1);
h_fail("Moon", "%A");
h_pass("mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1);
h_pass("tueSDay", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1);
h_pass("sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1);
h_fail("sunday", "%EA");
h_pass("SaturDay", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1);
h_fail("SaturDay", "%OA");
}
ATF_TC(month);
ATF_TC_HEAD(month, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks strptime(3): month names");
}
ATF_TC_BODY(month, tc)
{
h_pass("Jan", "%b", 3, -1, -1, -1, -1, 0, -1, -1, -1);
h_pass("January", "%b", 7, -1, -1, -1, -1, 0, -1, -1, -1);
h_pass("Feb", "%b", 3, -1, -1, -1, -1, 1, -1, -1, -1);
h_pass("February", "%b", 8, -1, -1, -1, -1, 1, -1, -1, -1);
h_pass("Mar", "%b", 3, -1, -1, -1, -1, 2, -1, -1, -1);
h_pass("March", "%b", 5, -1, -1, -1, -1, 2, -1, -1, -1);
h_pass("Apr", "%b", 3, -1, -1, -1, -1, 3, -1, -1, -1);
h_pass("April", "%b", 5, -1, -1, -1, -1, 3, -1, -1, -1);
h_pass("May", "%b", 3, -1, -1, -1, -1, 4, -1, -1, -1);
h_pass("Jun", "%b", 3, -1, -1, -1, -1, 5, -1, -1, -1);
h_pass("June", "%b", 4, -1, -1, -1, -1, 5, -1, -1, -1);
h_pass("Jul", "%b", 3, -1, -1, -1, -1, 6, -1, -1, -1);
h_pass("July", "%b", 4, -1, -1, -1, -1, 6, -1, -1, -1);
h_pass("Aug", "%b", 3, -1, -1, -1, -1, 7, -1, -1, -1);
h_pass("August", "%b", 6, -1, -1, -1, -1, 7, -1, -1, -1);
h_pass("Sep", "%b", 3, -1, -1, -1, -1, 8, -1, -1, -1);
h_pass("September", "%b", 9, -1, -1, -1, -1, 8, -1, -1, -1);
h_pass("Oct", "%b", 3, -1, -1, -1, -1, 9, -1, -1, -1);
h_pass("October", "%b", 7, -1, -1, -1, -1, 9, -1, -1, -1);
h_pass("Nov", "%b", 3, -1, -1, -1, -1, 10, -1, -1, -1);
h_pass("November", "%b", 8, -1, -1, -1, -1, 10, -1, -1, -1);
h_pass("Dec", "%b", 3, -1, -1, -1, -1, 11, -1, -1, -1);
h_pass("December", "%b", 8, -1, -1, -1, -1, 11, -1, -1, -1);
h_pass("Mayor", "%b", 3, -1, -1, -1, -1, 4, -1, -1, -1);
h_pass("Mars", "%b", 3, -1, -1, -1, -1, 2, -1, -1, -1);
h_fail("Rover", "%b");
h_pass("Jan", "%B", 3, -1, -1, -1, -1, 0, -1, -1, -1);
h_pass("January", "%B", 7, -1, -1, -1, -1, 0, -1, -1, -1);
h_pass("Feb", "%B", 3, -1, -1, -1, -1, 1, -1, -1, -1);
h_pass("February", "%B", 8, -1, -1, -1, -1, 1, -1, -1, -1);
h_pass("Mar", "%B", 3, -1, -1, -1, -1, 2, -1, -1, -1);
h_pass("March", "%B", 5, -1, -1, -1, -1, 2, -1, -1, -1);
h_pass("Apr", "%B", 3, -1, -1, -1, -1, 3, -1, -1, -1);
h_pass("April", "%B", 5, -1, -1, -1, -1, 3, -1, -1, -1);
h_pass("May", "%B", 3, -1, -1, -1, -1, 4, -1, -1, -1);
h_pass("Jun", "%B", 3, -1, -1, -1, -1, 5, -1, -1, -1);
h_pass("June", "%B", 4, -1, -1, -1, -1, 5, -1, -1, -1);
h_pass("Jul", "%B", 3, -1, -1, -1, -1, 6, -1, -1, -1);
h_pass("July", "%B", 4, -1, -1, -1, -1, 6, -1, -1, -1);
h_pass("Aug", "%B", 3, -1, -1, -1, -1, 7, -1, -1, -1);
h_pass("August", "%B", 6, -1, -1, -1, -1, 7, -1, -1, -1);
h_pass("Sep", "%B", 3, -1, -1, -1, -1, 8, -1, -1, -1);
h_pass("September", "%B", 9, -1, -1, -1, -1, 8, -1, -1, -1);
h_pass("Oct", "%B", 3, -1, -1, -1, -1, 9, -1, -1, -1);
h_pass("October", "%B", 7, -1, -1, -1, -1, 9, -1, -1, -1);
h_pass("Nov", "%B", 3, -1, -1, -1, -1, 10, -1, -1, -1);
h_pass("November", "%B", 8, -1, -1, -1, -1, 10, -1, -1, -1);
h_pass("Dec", "%B", 3, -1, -1, -1, -1, 11, -1, -1, -1);
h_pass("December", "%B", 8, -1, -1, -1, -1, 11, -1, -1, -1);
h_pass("Mayor", "%B", 3, -1, -1, -1, -1, 4, -1, -1, -1);
h_pass("Mars", "%B", 3, -1, -1, -1, -1, 2, -1, -1, -1);
h_fail("Rover", "%B");
h_pass("september", "%b", 9, -1, -1, -1, -1, 8, -1, -1, -1);
h_pass("septembe", "%B", 3, -1, -1, -1, -1, 8, -1, -1, -1);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, common);
ATF_TP_ADD_TC(tp, day);
ATF_TP_ADD_TC(tp, month);
return atf_no_error();
}