Migrate a couple more tests to aft
This commit is contained in:
parent
75268cff3f
commit
546ea3ce2c
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.186 2010/12/22 23:45:44 pgoyette Exp $
|
||||
# $NetBSD: mi,v 1.187 2010/12/23 15:27:44 pgoyette Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
@ -324,9 +324,11 @@
|
||||
./usr/libdata/debug/usr/tests/lib/libc/hash tests-lib-debug
|
||||
./usr/libdata/debug/usr/tests/lib/libc/hash/t_sha2.debug tests-lib-debug debug,atf
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdio tests-lib-debug
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdio/t_fmemopen.debug tests-lib-debug debug,atf
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdio/t_format.debug tests-lib-debug debug,atf
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdio/t_fmemopen.debug tests-lib-debug debug,atf
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdio/t_format.debug tests-lib-debug debug,atf
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdio/t_popen.debug tests-lib-debug debug,atf
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdlib tests-lib-debug
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_div.debug tests-lib-debug debug,atf
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_environment.debug tests-lib-debug debug,atf
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_environment_pth.debug tests-lib-debug debug,atf
|
||||
./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_mi_vector_hash.debug tests-lib-debug debug,atf
|
||||
@ -1542,6 +1544,7 @@
|
||||
./usr/tests/lib/libc/hash/t_sha2 tests-lib-tests atf
|
||||
./usr/tests/lib/libc/stdlib tests-lib-tests
|
||||
./usr/tests/lib/libc/stdlib/Atffile tests-lib-tests atf
|
||||
./usr/tests/lib/libc/stdlib/t_div tests-lib-tests atf
|
||||
./usr/tests/lib/libc/stdlib/t_environment tests-lib-tests atf
|
||||
./usr/tests/lib/libc/stdlib/t_environment_pth tests-lib-tests atf
|
||||
./usr/tests/lib/libc/stdlib/t_mi_vector_hash tests-lib-tests atf
|
||||
@ -1550,6 +1553,7 @@
|
||||
./usr/tests/lib/libc/stdio/Atffile tests-lib-tests atf
|
||||
./usr/tests/lib/libc/stdio/t_fmemopen tests-lib-tests atf
|
||||
./usr/tests/lib/libc/stdio/t_format tests-lib-tests atf
|
||||
./usr/tests/lib/libc/stdio/t_popen tests-lib-tests atf
|
||||
./usr/tests/lib/libc/string tests-obsolete obsolete
|
||||
./usr/tests/lib/libc/string/Atffile tests-obsolete obsolete
|
||||
./usr/tests/lib/libc/string/t_popcount tests-obsolete obsolete
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.2 2010/11/19 18:18:53 njoly Exp $
|
||||
# $NetBSD: Makefile,v 1.3 2010/12/23 15:27:44 pgoyette Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
@ -6,5 +6,6 @@ TESTSDIR= ${TESTSBASE}/lib/libc/stdio
|
||||
|
||||
TESTS_C+= t_fmemopen
|
||||
TESTS_C+= t_format
|
||||
TESTS_C+= t_popen
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
130
tests/lib/libc/stdio/t_popen.c
Normal file
130
tests/lib/libc/stdio/t_popen.c
Normal file
@ -0,0 +1,130 @@
|
||||
/* $NetBSD: t_popen.c,v 1.1 2010/12/23 15:27:44 pgoyette Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matthias Scheler.
|
||||
*
|
||||
* 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>
|
||||
#ifndef lint
|
||||
__COPYRIGHT("@(#) Copyright (c) 1999\
|
||||
The NetBSD Foundation, Inc. All rights reserved.");
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: t_popen.c,v 1.1 2010/12/23 15:27:44 pgoyette Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define _PATH_CAT "/bin/cat"
|
||||
#define BUFSIZE (640*1024)
|
||||
/* 640KB ought to be enough for everyone. */
|
||||
#define DATAFILE "popen.data"
|
||||
|
||||
#define TEST_ERROR(a) \
|
||||
do \
|
||||
{ \
|
||||
perror(a); \
|
||||
atf_tc_fail("Check stderr for error details."); \
|
||||
} while ( /*CONSTCOND*/ 0 )
|
||||
|
||||
ATF_TC_WITH_CLEANUP(popen);
|
||||
|
||||
ATF_TC_HEAD(popen, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "output format zero padding");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(popen, tc)
|
||||
{
|
||||
char *buffer, command[MAXPATHLEN];
|
||||
int index, in;
|
||||
FILE *my_pipe;
|
||||
|
||||
if ((buffer = malloc(BUFSIZE*sizeof(char))) == NULL)
|
||||
atf_tc_skip("Unable to allocate buffer.");
|
||||
|
||||
srand ((unsigned int)time(NULL));
|
||||
for (index=0; index<BUFSIZE; index++)
|
||||
buffer[index]=(char)rand();
|
||||
|
||||
(void)snprintf(command, sizeof(command), "%s >%s", _PATH_CAT, DATAFILE);
|
||||
if ((my_pipe = popen(command, "w")) == NULL)
|
||||
TEST_ERROR("popen write");
|
||||
|
||||
if (fwrite(buffer, sizeof(char), BUFSIZE, my_pipe) != BUFSIZE)
|
||||
TEST_ERROR("fwrite");
|
||||
|
||||
if (pclose(my_pipe) == -1)
|
||||
TEST_ERROR("pclose");
|
||||
|
||||
(void)snprintf(command, sizeof(command), "%s %s", _PATH_CAT, DATAFILE);
|
||||
if ((my_pipe = popen(command, "r")) == NULL)
|
||||
TEST_ERROR("popen read");
|
||||
|
||||
index = 0;
|
||||
while ((in = fgetc(my_pipe)) != EOF)
|
||||
if (index == BUFSIZE) {
|
||||
errno = EFBIG;
|
||||
TEST_ERROR("read");
|
||||
}
|
||||
else if ((char)in != buffer[index++]) {
|
||||
errno = EINVAL;
|
||||
TEST_ERROR("read");
|
||||
}
|
||||
|
||||
if (index < BUFSIZE) {
|
||||
errno = EIO;
|
||||
TEST_ERROR("read");
|
||||
}
|
||||
|
||||
if (pclose(my_pipe) == -1)
|
||||
TEST_ERROR("pclose");
|
||||
}
|
||||
|
||||
ATF_TC_CLEANUP(popen, tc)
|
||||
{
|
||||
(void)unlink(DATAFILE);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, popen);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
# $NetBSD: Makefile,v 1.5 2010/12/03 13:11:50 njoly Exp $
|
||||
# $NetBSD: Makefile,v 1.6 2010/12/23 15:27:44 pgoyette Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/libc/stdlib
|
||||
|
||||
TESTS_C+= t_mi_vector_hash t_environment t_environment_pth
|
||||
TESTS_C+= t_div t_mi_vector_hash t_environment t_environment_pth
|
||||
TESTS_C+= t_strtox
|
||||
|
||||
LDADD.t_environment_pth= -pthread
|
||||
|
101
tests/lib/libc/stdlib/t_div.c
Normal file
101
tests/lib/libc/stdlib/t_div.c
Normal file
@ -0,0 +1,101 @@
|
||||
/* $NetBSD: t_div.c,v 1.1 2010/12/23 15:27:44 pgoyette Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 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 <atf-c.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define NUM 1999236
|
||||
#define DENOM 1000000
|
||||
#define QUOT 1
|
||||
#define REM 999236
|
||||
|
||||
ATF_TC(div);
|
||||
|
||||
ATF_TC_HEAD(div, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test div(3) for correctness");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(div, tc)
|
||||
{
|
||||
div_t d;
|
||||
|
||||
d = div(NUM, DENOM);
|
||||
|
||||
ATF_CHECK(d.quot == QUOT);
|
||||
ATF_CHECK(d.rem == REM);
|
||||
}
|
||||
|
||||
ATF_TC(ldiv);
|
||||
|
||||
ATF_TC_HEAD(ldiv, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test ldiv(3) for correctness");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(ldiv, tc)
|
||||
{
|
||||
ldiv_t ld;
|
||||
|
||||
ld = ldiv(NUM, DENOM);
|
||||
|
||||
ATF_CHECK(ld.quot == QUOT);
|
||||
ATF_CHECK(ld.rem == REM);
|
||||
}
|
||||
|
||||
ATF_TC(lldiv);
|
||||
|
||||
ATF_TC_HEAD(lldiv, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test lllldiv(3) for correctness");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(lldiv, tc)
|
||||
{
|
||||
lldiv_t lld;
|
||||
|
||||
lld = lldiv(NUM, DENOM);
|
||||
|
||||
ATF_CHECK(lld.quot == QUOT);
|
||||
ATF_CHECK(lld.rem == REM);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
ATF_TP_ADD_TC(tp, div);
|
||||
ATF_TP_ADD_TC(tp, ldiv);
|
||||
ATF_TP_ADD_TC(tp, lldiv);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
Loading…
Reference in New Issue
Block a user