[openssh-commits] [openssh] 02/02: upstream commit

git+noreply at mindrot.org git+noreply at mindrot.org
Sun Feb 19 11:19:23 AEDT 2017


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit d5499190559ebe374bcdfa8805408646ceffad64
Author: djm at openbsd.org <djm at openbsd.org>
Date:   Sun Feb 19 00:11:29 2017 +0000

    upstream commit
    
    add test cases for C locale; ok schwarze@
    
    Upstream-Regress-ID: 783d75de35fbc923d46e2a5e6cee30f8f381ba87
---
 regress/unittests/utf8/tests.c | 65 +++++++++++++++++++++++++++---------------
 1 file changed, 42 insertions(+), 23 deletions(-)

diff --git a/regress/unittests/utf8/tests.c b/regress/unittests/utf8/tests.c
index 31f9fe9..f0bbca5 100644
--- a/regress/unittests/utf8/tests.c
+++ b/regress/unittests/utf8/tests.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: tests.c,v 1.3 2016/12/19 04:55:18 djm Exp $ */
+/*	$OpenBSD: tests.c,v 1.4 2017/02/19 00:11:29 djm Exp $ */
 /*
  * Regress test for the utf8.h *mprintf() API
  *
@@ -15,10 +15,7 @@
 
 #include "utf8.h"
 
-void	 badarg(void);
-void	 one(const char *, const char *, int, int, int, const char *);
-
-void
+static void
 badarg(void)
 {
 	char	 buf[16];
@@ -33,8 +30,8 @@ badarg(void)
 	TEST_DONE();
 }
 
-void
-one(const char *name, const char *mbs, int width,
+static void
+one(int utf8, const char *name, const char *mbs, int width,
     int wantwidth, int wantlen, const char *wants)
 {
 	char	 buf[16];
@@ -43,7 +40,7 @@ one(const char *name, const char *mbs, int width,
 
 	if (wantlen == -2)
 		wantlen = strlen(wants);
-	(void)strlcpy(buf, "utf8_", sizeof(buf));
+	(void)strlcpy(buf, utf8 ? "utf8_" : "c_", sizeof(buf));
 	(void)strlcat(buf, name, sizeof(buf));
 	TEST_START(buf);
 	wp = wantwidth == -2 ? NULL : &width;
@@ -65,19 +62,41 @@ tests(void)
 	TEST_DONE();
 
 	badarg();
-	one("empty", "", 2, 0, 0, "");
-	one("ascii", "x", -2, -2, -2, "x");
-	one("newline", "a\nb", -2, -2, -2, "a\nb");
-	one("cr", "a\rb", -2, -2, -2, "a\rb");
-	one("tab", "a\tb", -2, -2, -2, "a\tb");
-	one("esc", "\033x", -2, -2, -2, "\\033x");
-	one("inv_badbyte", "\377x", -2, -2, -2, "\\377x");
-	one("inv_nocont", "\341x", -2, -2, -2, "\\341x");
-	one("inv_nolead", "a\200b", -2, -2, -2, "a\\200b");
-	one("sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345");
-	one("sz_esc", "123456789012\033", -2, -2, 16, "123456789012");
-	one("width_ascii", "123", 2, 2, -1, "12");
-	one("width_double", "a\343\201\201", 2, 1, -1, "a");
-	one("double_fit", "a\343\201\201", 3, 3, 4, "a\343\201\201");
-	one("double_spc", "a\343\201\201", 4, 3, 4, "a\343\201\201");
+	one(1, "empty", "", 2, 0, 0, "");
+	one(1, "ascii", "x", -2, -2, -2, "x");
+	one(1, "newline", "a\nb", -2, -2, -2, "a\nb");
+	one(1, "cr", "a\rb", -2, -2, -2, "a\rb");
+	one(1, "tab", "a\tb", -2, -2, -2, "a\tb");
+	one(1, "esc", "\033x", -2, -2, -2, "\\033x");
+	one(1, "inv_badbyte", "\377x", -2, -2, -2, "\\377x");
+	one(1, "inv_nocont", "\341x", -2, -2, -2, "\\341x");
+	one(1, "inv_nolead", "a\200b", -2, -2, -2, "a\\200b");
+	one(1, "sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345");
+	one(1, "sz_esc", "123456789012\033", -2, -2, 16, "123456789012");
+	one(1, "width_ascii", "123", 2, 2, -1, "12");
+	one(1, "width_double", "a\343\201\201", 2, 1, -1, "a");
+	one(1, "double_fit", "a\343\201\201", 3, 3, 4, "a\343\201\201");
+	one(1, "double_spc", "a\343\201\201", 4, 3, 4, "a\343\201\201");
+
+	TEST_START("C_setlocale");
+	loc = setlocale(LC_CTYPE, "C");
+	ASSERT_PTR_NE(loc, NULL);
+	TEST_DONE();
+
+	badarg();
+	one(0, "empty", "", 2, 0, 0, "");
+	one(0, "ascii", "x", -2, -2, -2, "x");
+	one(0, "newline", "a\nb", -2, -2, -2, "a\nb");
+	one(0, "cr", "a\rb", -2, -2, -2, "a\rb");
+	one(0, "tab", "a\tb", -2, -2, -2, "a\tb");
+	one(0, "esc", "\033x", -2, -2, -2, "\\033x");
+	one(0, "inv_badbyte", "\377x", -2, -2, -2, "\\377x");
+	one(0, "inv_nocont", "\341x", -2, -2, -2, "\\341x");
+	one(0, "inv_nolead", "a\200b", -2, -2, -2, "a\\200b");
+	one(0, "sz_ascii", "1234567890123456", -2, -2, 16, "123456789012345");
+	one(0, "sz_esc", "123456789012\033", -2, -2, 16, "123456789012");
+	one(0, "width_ascii", "123", 2, 2, -1, "12");
+	one(0, "width_double", "a\343\201\201", 2, 1, -1, "a");
+	one(0, "double_fit", "a\343\201\201", 7, 5, -1, "a\\343");
+	one(0, "double_spc", "a\343\201\201", 13, 13, 13, "a\\343\\201\\201");
 }

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list