Split out 't_printf' and 't_scanf' from 't_format' to gain the common

"functional scope" for the test files.
This commit is contained in:
jruoho 2011-07-08 06:38:03 +00:00
parent 729b0b87d7
commit aa3f9890b8
4 changed files with 98 additions and 58 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.372 2011/07/07 15:53:27 jruoho Exp $
# $NetBSD: mi,v 1.373 2011/07/08 06:38:03 jruoho Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -434,8 +434,10 @@
./usr/libdata/debug/usr/tests/lib/libc/stdio tests-lib-debug
./usr/libdata/debug/usr/tests/lib/libc/stdio/t_clearerr.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_format.debug tests-obsolete obsolete
./usr/libdata/debug/usr/tests/lib/libc/stdio/t_popen.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/stdio/t_printf.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/stdio/t_scanf.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/h_atexit.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libc/stdlib/h_getopt.debug tests-lib-debug debug,atf
@ -2010,8 +2012,10 @@
./usr/tests/lib/libc/stdio/Atffile tests-lib-tests atf
./usr/tests/lib/libc/stdio/t_clearerr 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_format tests-obsolete obsolete
./usr/tests/lib/libc/stdio/t_popen tests-lib-tests atf
./usr/tests/lib/libc/stdio/t_printf tests-lib-tests atf
./usr/tests/lib/libc/stdio/t_scanf 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/h_atexit tests-lib-tests atf

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.4 2011/05/01 16:36:37 jruoho Exp $
# $NetBSD: Makefile,v 1.5 2011/07/08 06:38:04 jruoho Exp $
.include <bsd.own.mk>
@ -6,7 +6,8 @@ TESTSDIR= ${TESTSBASE}/lib/libc/stdio
TESTS_C+= t_clearerr
TESTS_C+= t_fmemopen
TESTS_C+= t_format
TESTS_C+= t_popen
TESTS_C+= t_printf
TESTS_C+= t_scanf
.include <bsd.test.mk>

View File

@ -0,0 +1,81 @@
/* $NetBSD: t_printf.c,v 1.1 2011/07/08 06:38:04 jruoho Exp $ */
/*-
* Copyright (c) 2010 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 <math.h>
#include <stdio.h>
#include <string.h>
ATF_TC(sprintf_dotzero);
ATF_TC_HEAD(sprintf_dotzero, tc)
{
atf_tc_set_md_var(tc, "descr", \
"PR lib/32951: %.0f formats (0.0,0.5] to \"0.\"");
}
ATF_TC_BODY(sprintf_dotzero, tc)
{
char s[4];
ATF_CHECK(snprintf(s, sizeof(s), "%.0f", 0.1) == 1);
ATF_REQUIRE_STREQ(s, "0");
}
ATF_TC(sprintf_zeropad);
ATF_TC_HEAD(sprintf_zeropad, tc)
{
atf_tc_set_md_var(tc, "descr", "output format zero padding");
}
ATF_TC_BODY(sprintf_zeropad, tc)
{
char str[1024];
ATF_CHECK(sprintf(str, "%010f", 0.0) == 10);
ATF_REQUIRE_STREQ(str, "000.000000");
/* ieeefp */
#ifndef __vax__
/* PR/44113: printf(3) should ignore zero padding for nan/inf */
ATF_CHECK(sprintf(str, "%010f", NAN) == 10);
ATF_REQUIRE_STREQ(str, " nan");
ATF_CHECK(sprintf(str, "%010f", INFINITY) == 10);
ATF_REQUIRE_STREQ(str, " inf");
#endif
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, sprintf_dotzero);
ATF_TP_ADD_TC(tp, sprintf_zeropad);
return atf_no_error();
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_format.c,v 1.5 2010/12/23 13:34:46 pgoyette Exp $ */
/* $NetBSD: t_scanf.c,v 1.1 2011/07/08 06:38:04 jruoho Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@ -31,62 +31,19 @@
#include <stdio.h>
#include <string.h>
ATF_TC(zero_padding);
#define NUM -0x1234
#define STRNUM ___STRING(NUM)
ATF_TC_HEAD(zero_padding, tc)
{
atf_tc_set_md_var(tc, "descr", "output format zero padding");
}
ATF_TC_BODY(zero_padding, tc)
{
char str[1024];
ATF_CHECK(sprintf(str, "%010f", 0.0) == 10);
ATF_REQUIRE_STREQ(str, "000.000000");
/* ieeefp */
#ifndef __vax__
/* PR/44113: printf(3) should ignore zero padding for nan/inf */
ATF_CHECK(sprintf(str, "%010f", NAN) == 10);
ATF_REQUIRE_STREQ(str, " nan");
ATF_CHECK(sprintf(str, "%010f", INFINITY) == 10);
ATF_REQUIRE_STREQ(str, " inf");
#endif
}
ATF_TC(dot_zero_f);
ATF_TC_HEAD(dot_zero_f, tc)
{
atf_tc_set_md_var(tc, "descr", \
"PR lib/32951: %.0f formats (0.0,0.5] to \"0.\"");
}
ATF_TC_BODY(dot_zero_f, tc)
{
char s[4];
ATF_CHECK(snprintf(s, sizeof(s), "%.0f", 0.1) == 1);
ATF_REQUIRE_STREQ(s, "0");
}
ATF_TC(sscanf_neg_hex);
ATF_TC_HEAD(sscanf_neg_hex, tc)
ATF_TC(sscanf_neghex);
ATF_TC_HEAD(sscanf_neghex, tc)
{
atf_tc_set_md_var(tc, "descr", \
"PR lib/21691: %i and %x fail with negative hex numbers");
}
ATF_TC_BODY(sscanf_neg_hex, tc)
ATF_TC_BODY(sscanf_neghex, tc)
{
#define NUM -0x1234
#define STRNUM ___STRING(NUM)
int i;
sscanf(STRNUM, "%i", &i);
@ -97,7 +54,6 @@ ATF_TC_BODY(sscanf_neg_hex, tc)
}
ATF_TC(sscanf_whitespace);
ATF_TC_HEAD(sscanf_whitespace, tc)
{
@ -119,9 +75,7 @@ ATF_TC_BODY(sscanf_whitespace, tc)
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, zero_padding);
ATF_TP_ADD_TC(tp, dot_zero_f);
ATF_TP_ADD_TC(tp, sscanf_neg_hex);
ATF_TP_ADD_TC(tp, sscanf_neghex);
ATF_TP_ADD_TC(tp, sscanf_whitespace);
return atf_no_error();