Module Name:    src
Committed By:   jruoho
Date:           Fri Jul  8 06:38:04 UTC 2011

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/tests/lib/libc/stdio: Makefile
Added Files:
        src/tests/lib/libc/stdio: t_printf.c t_scanf.c
Removed Files:
        src/tests/lib/libc/stdio: t_format.c

Log Message:
Split out 't_printf' and 't_scanf' from 't_format' to gain the common
"functional scope" for the test files.


To generate a diff of this commit:
cvs rdiff -u -r1.372 -r1.373 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/stdio/Makefile
cvs rdiff -u -r1.5 -r0 src/tests/lib/libc/stdio/t_format.c
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/stdio/t_printf.c \
    src/tests/lib/libc/stdio/t_scanf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.372 src/distrib/sets/lists/tests/mi:1.373
--- src/distrib/sets/lists/tests/mi:1.372	Thu Jul  7 15:53:27 2011
+++ src/distrib/sets/lists/tests/mi	Fri Jul  8 06:38:03 2011
@@ -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

Index: src/tests/lib/libc/stdio/Makefile
diff -u src/tests/lib/libc/stdio/Makefile:1.4 src/tests/lib/libc/stdio/Makefile:1.5
--- src/tests/lib/libc/stdio/Makefile:1.4	Sun May  1 16:36:37 2011
+++ src/tests/lib/libc/stdio/Makefile	Fri Jul  8 06:38:04 2011
@@ -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 @@
 
 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>

Added files:

Index: src/tests/lib/libc/stdio/t_printf.c
diff -u /dev/null src/tests/lib/libc/stdio/t_printf.c:1.1
--- /dev/null	Fri Jul  8 06:38:05 2011
+++ src/tests/lib/libc/stdio/t_printf.c	Fri Jul  8 06:38:04 2011
@@ -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();
+}
Index: src/tests/lib/libc/stdio/t_scanf.c
diff -u /dev/null src/tests/lib/libc/stdio/t_scanf.c:1.1
--- /dev/null	Fri Jul  8 06:38:05 2011
+++ src/tests/lib/libc/stdio/t_scanf.c	Fri Jul  8 06:38:04 2011
@@ -0,0 +1,82 @@
+/* $NetBSD: t_scanf.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>
+
+#define NUM     -0x1234
+#define STRNUM  ___STRING(NUM)
+
+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_neghex, tc)
+{
+        int i;
+
+        sscanf(STRNUM, "%i", &i);
+	ATF_REQUIRE(i == NUM);
+
+        sscanf(STRNUM, "%x", &i);
+	ATF_REQUIRE(i == NUM);
+}
+
+ATF_TC(sscanf_whitespace);
+ATF_TC_HEAD(sscanf_whitespace, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr", "verify sscanf skips all whitespace");
+}
+
+ATF_TC_BODY(sscanf_whitespace, tc)
+{
+	const char str[] = "\f\n\r\t\v%z";
+	char c;
+
+        /* set of "white space" symbols from isspace(3) */
+        c = 0;
+        (void)sscanf(str, "%%%c", &c);
+	ATF_REQUIRE(c == 'z');
+}
+
+
+ATF_TP_ADD_TCS(tp)
+{
+
+	ATF_TP_ADD_TC(tp, sscanf_neghex);
+	ATF_TP_ADD_TC(tp, sscanf_whitespace);
+
+	return atf_no_error();
+}

Reply via email to