From fbd5367245eef1966a5e52adee6f48bfea1dd474 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 6 Apr 2003 11:19:26 +0000 Subject: Fix bigballofmud.so, and add a test to show a bug I'm having with push_ucs2. Andrew Bartlett (This used to be commit a60fd29b43537935500f40a32fec553f2b52c0d3) --- source3/torture/t_push_ucs2.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 source3/torture/t_push_ucs2.c (limited to 'source3/torture/t_push_ucs2.c') diff --git a/source3/torture/t_push_ucs2.c b/source3/torture/t_push_ucs2.c new file mode 100644 index 0000000000..0ab17983a0 --- /dev/null +++ b/source3/torture/t_push_ucs2.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2003 by Martin Pool + * Copyright (C) 2003 by Andrew Bartlett + * + * Test harness for push_ucs2 + */ + +#include "includes.h" + +static int check_push_ucs2(const char *orig) +{ + smb_ucs2_t *dest = NULL; + char *orig2 = NULL; + int ret; + + push_ucs2_allocate(&dest, orig); + pull_ucs2_allocate(&orig2, dest); + ret = strcmp(orig, orig2); + SAFE_FREE(dest); + SAFE_FREE(orig2); +} + +int main(int argc, char *argv[]) +{ + int i, ret; + + if (argc != 2) { + fprintf(stderr, "usage: %s STRING1\n" + "Converts a string, prints the results of memcmp\n", + argv[0]); + return 2; + } + + for (i = 0; i < 10000; i++) + ret = check_push_ucs2(argv[1]); + + printf("%d\n", ret); + + return 0; +} -- cgit From 854c5d60bd89d5d6a8b4b44c8297e16a425ffb2d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 6 Apr 2003 12:01:44 +0000 Subject: If the string does not convert back, print the buggy result. (This used to be commit 98f76325542c0ab2e0bbcf082a15c6f8db27e37c) --- source3/torture/t_push_ucs2.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source3/torture/t_push_ucs2.c') diff --git a/source3/torture/t_push_ucs2.c b/source3/torture/t_push_ucs2.c index 0ab17983a0..ca04394acc 100644 --- a/source3/torture/t_push_ucs2.c +++ b/source3/torture/t_push_ucs2.c @@ -16,22 +16,29 @@ static int check_push_ucs2(const char *orig) push_ucs2_allocate(&dest, orig); pull_ucs2_allocate(&orig2, dest); ret = strcmp(orig, orig2); + if (ret) { + fprintf(stderr, "orig: %s\n", orig); + fprintf(stderr, "orig (UNIX -> UCS2 -> UNIX): %s\n", orig2); + } + SAFE_FREE(dest); SAFE_FREE(orig2); + + return ret; } int main(int argc, char *argv[]) { - int i, ret; + int i, ret = 0; if (argc != 2) { fprintf(stderr, "usage: %s STRING1\n" - "Converts a string, prints the results of memcmp\n", + "Converts a string, prints the results of strcmp\n", argv[0]); return 2; } - for (i = 0; i < 10000; i++) + for (i = 0; ((i < 10000) && (!ret)); i++) ret = check_push_ucs2(argv[1]); printf("%d\n", ret); -- cgit From bce94d35f125eaeaa4db7866503418b8f281edf2 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Tue, 8 Apr 2003 08:05:01 +0000 Subject: Integrate abartlet's t_push_ucs2 test into test framework: - Build t_push_ucs2 as part of check-programs, the prerequisite for "make check". - t_push_ucs2.c: Load configuration from /dev/null so that we get a unix_charset of UTF-8 and can do meaningful UCS2 tests. Better comment. - Add a test to strings.py which tries conversion UTF8->UCS2->UTF8 and checks the results. Do this for English, Latin-1, and Katakana strings. - Add Python module with symbolic names for a handful of UNICODE characters. (This used to be commit 275e095c92ac74815ab9e388a0e83cdb7ddd85f3) --- source3/torture/t_push_ucs2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/torture/t_push_ucs2.c') diff --git a/source3/torture/t_push_ucs2.c b/source3/torture/t_push_ucs2.c index ca04394acc..86ae1b9b6c 100644 --- a/source3/torture/t_push_ucs2.c +++ b/source3/torture/t_push_ucs2.c @@ -30,10 +30,14 @@ static int check_push_ucs2(const char *orig) int main(int argc, char *argv[]) { int i, ret = 0; - + + /* Needed to initialize character set */ + lp_load("/dev/null", True, False, False); + if (argc != 2) { fprintf(stderr, "usage: %s STRING1\n" - "Converts a string, prints the results of strcmp\n", + "Checks that a string translated UNIX->UCS2->UNIX is unchanged\n" + "Should be always 0\n", argv[0]); return 2; } -- cgit From 80cd7c552ff95b3aa4caf79768af5b1e5c07c506 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Wed, 9 Apr 2003 05:22:17 +0000 Subject: t_push_ucs2, t_strcmp: Run tests only once by default, rather than 10000 times. (In theory they should be pure functions....) You can specify a parameter to repeat them if you want to e.g. measure performance. (This used to be commit 92acecd28c3374abcadbff0ab9cb765411f453f4) --- source3/torture/t_push_ucs2.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/torture/t_push_ucs2.c') diff --git a/source3/torture/t_push_ucs2.c b/source3/torture/t_push_ucs2.c index 86ae1b9b6c..8bfc6f7ad9 100644 --- a/source3/torture/t_push_ucs2.c +++ b/source3/torture/t_push_ucs2.c @@ -30,19 +30,22 @@ static int check_push_ucs2(const char *orig) int main(int argc, char *argv[]) { int i, ret = 0; + int count = 1; /* Needed to initialize character set */ lp_load("/dev/null", True, False, False); - if (argc != 2) { - fprintf(stderr, "usage: %s STRING1\n" + if (argc < 2) { + fprintf(stderr, "usage: %s STRING1 [COUNT]\n" "Checks that a string translated UNIX->UCS2->UNIX is unchanged\n" "Should be always 0\n", argv[0]); return 2; } + if (argc >= 3) + count = atoi(argv[2]); - for (i = 0; ((i < 10000) && (!ret)); i++) + for (i = 0; ((i < count) && (!ret)); i++) ret = check_push_ucs2(argv[1]); printf("%d\n", ret); -- cgit From 9c15bd311db76885b27f30ba92d885833f668550 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 28 Jan 2006 22:53:04 +0000 Subject: r13212: r12414@cabra: derrell | 2006-01-28 17:52:17 -0500 lp_load() could not be called multiple times to modify parameter settings based on reading from multiple configuration settings. Each time, it initialized all of the settings back to their defaults before reading the specified configuration file. This patch adds a parameter to lp_load() specifying whether the settings should be initialized. It does, however, still force the settings to be initialized the first time, even if the request was to not initialize them. (Not doing so could wreak havoc due to uninitialized values.) (This used to be commit f2a24de769d1b2266e576597c57a8e3b1e2a2b51) --- source3/torture/t_push_ucs2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/torture/t_push_ucs2.c') diff --git a/source3/torture/t_push_ucs2.c b/source3/torture/t_push_ucs2.c index 8bfc6f7ad9..8d327acfa5 100644 --- a/source3/torture/t_push_ucs2.c +++ b/source3/torture/t_push_ucs2.c @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) int count = 1; /* Needed to initialize character set */ - lp_load("/dev/null", True, False, False); + lp_load("/dev/null", True, False, False, True); if (argc < 2) { fprintf(stderr, "usage: %s STRING1 [COUNT]\n" -- cgit From fb37f156009611af0dd454a0fb0829a09cd638ac Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Tue, 29 Apr 2008 14:36:24 -0700 Subject: Cleanup size_t return values in callers of convert_string_allocate This patch is the second iteration of an inside-out conversion to cleanup functions in charcnv.c returning size_t == -1 to indicate failure. (This used to be commit 6b189dabc562d86dcaa685419d0cb6ea276f100d) --- source3/torture/t_push_ucs2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/torture/t_push_ucs2.c') diff --git a/source3/torture/t_push_ucs2.c b/source3/torture/t_push_ucs2.c index 8d327acfa5..b9bf87ba54 100644 --- a/source3/torture/t_push_ucs2.c +++ b/source3/torture/t_push_ucs2.c @@ -12,9 +12,10 @@ static int check_push_ucs2(const char *orig) smb_ucs2_t *dest = NULL; char *orig2 = NULL; int ret; + size_t converted_size; - push_ucs2_allocate(&dest, orig); - pull_ucs2_allocate(&orig2, dest); + push_ucs2_allocate(&dest, orig, &converted_size); + pull_ucs2_allocate(&orig2, dest, &converted_size); ret = strcmp(orig, orig2); if (ret) { fprintf(stderr, "orig: %s\n", orig); -- cgit