From 47dfe299c8a5a64ade88d15ecf71f99800ea40cd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 26 Mar 2004 02:39:48 +0000 Subject: - moved some of the base tests into torture/basic/ - added a CHARSET set of tests, which determines how the server deals with some specific charset issues related to UTF-16 support. Interestingly, Samba3 already passes all but one of these tests, because our incorrect UCS-2 and UTF-8 implementations where we don't check the validity of characters actually matches what Windows does! This means that adding UTF-16 support to Samba is going to be _much_ easier than we expected. (This used to be commit c8497a42364d186f08102224d5062d176ee81f5b) --- source4/torture/basic/mangle_test.c | 205 ++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 source4/torture/basic/mangle_test.c (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c new file mode 100644 index 0000000000..94dac45b9d --- /dev/null +++ b/source4/torture/basic/mangle_test.c @@ -0,0 +1,205 @@ +/* + Unix SMB/CIFS implementation. + SMB torture tester - mangling test + Copyright (C) Andrew Tridgell 2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +static TDB_CONTEXT *tdb; + +#define NAME_LENGTH 20 + +static unsigned total, collisions, failures; + +static BOOL test_one(struct cli_state *cli, const char *name) +{ + int fnum; + const char *shortname; + fstring name2; + NTSTATUS status; + TDB_DATA data; + + total++; + + fnum = cli_open(cli->tree, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); + if (fnum == -1) { + printf("open of %s failed (%s)\n", name, cli_errstr(cli->tree)); + return False; + } + + if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) { + printf("close of %s failed (%s)\n", name, cli_errstr(cli->tree)); + return False; + } + + /* get the short name */ + status = cli_qpathinfo_alt_name(cli->tree, name, &shortname); + if (!NT_STATUS_IS_OK(status)) { + printf("query altname of %s failed (%s)\n", name, cli_errstr(cli->tree)); + return False; + } + + snprintf(name2, sizeof(name2), "\\mangle_test\\%s", shortname); + if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, name2))) { + printf("unlink of %s (%s) failed (%s)\n", + name2, name, cli_errstr(cli->tree)); + return False; + } + + /* recreate by short name */ + fnum = cli_open(cli->tree, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); + if (fnum == -1) { + printf("open2 of %s failed (%s)\n", name2, cli_errstr(cli->tree)); + return False; + } + if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) { + printf("close of %s failed (%s)\n", name, cli_errstr(cli->tree)); + return False; + } + + /* and unlink by long name */ + if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, name))) { + printf("unlink2 of %s (%s) failed (%s)\n", + name, name2, cli_errstr(cli->tree)); + failures++; + cli_unlink(cli->tree, name2); + return True; + } + + /* see if the short name is already in the tdb */ + data = tdb_fetch_bystring(tdb, shortname); + if (data.dptr) { + /* maybe its a duplicate long name? */ + if (strcasecmp(name, data.dptr) != 0) { + /* we have a collision */ + collisions++; + printf("Collision between %s and %s -> %s " + " (coll/tot: %u/%u)\n", + name, data.dptr, shortname, collisions, total); + } + free(data.dptr); + } else { + TDB_DATA namedata; + /* store it for later */ + namedata.dptr = name; + namedata.dsize = strlen(name)+1; + tdb_store_bystring(tdb, shortname, namedata, TDB_REPLACE); + } + + return True; +} + + +static void gen_name(char *name) +{ + const char *chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-$~..."; + unsigned max_idx = strlen(chars); + unsigned len; + int i; + char *p; + + fstrcpy(name, "\\mangle_test\\"); + p = name + strlen(name); + + len = 1 + random() % NAME_LENGTH; + + for (i=0;itree, "\\mangle_test\\*"); + cli_rmdir(cli->tree, "\\mangle_test"); + + if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, "\\mangle_test"))) { + printf("ERROR: Failed to make directory\n"); + return False; + } + + for (i=0;itree, "\\mangle_test\\*"); + if (NT_STATUS_IS_ERR(cli_rmdir(cli->tree, "\\mangle_test"))) { + printf("ERROR: Failed to remove directory\n"); + return False; + } + + printf("\nTotal collisions %u/%u - %.2f%% (%u failures)\n", + collisions, total, (100.0*collisions) / total, failures); + + torture_close_connection(cli); + + printf("mangle test finished\n"); + return (failures == 0); +} -- cgit From 770e3307ce3da928762e15a136c562df86a9c799 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Jun 2004 10:12:52 +0000 Subject: r962: convert 'unsigned' and 'unsigned int' to uint_t metze (This used to be commit 57151e80eb1090281401930c8fe25b20a8cf3a38) --- source4/torture/basic/mangle_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 94dac45b9d..4859ee7c4c 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -24,7 +24,7 @@ static TDB_CONTEXT *tdb; #define NAME_LENGTH 20 -static unsigned total, collisions, failures; +static uint_t total, collisions, failures; static BOOL test_one(struct cli_state *cli, const char *name) { @@ -108,8 +108,8 @@ static BOOL test_one(struct cli_state *cli, const char *name) static void gen_name(char *name) { const char *chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-$~..."; - unsigned max_idx = strlen(chars); - unsigned len; + uint_t max_idx = strlen(chars); + uint_t len; int i; char *p; -- cgit From c5fbb6f23c2d399c7510bc552cdb1a27b1ef66a8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 4 Aug 2004 13:23:35 +0000 Subject: r1654: rename cli_ -> smbcli_ rename CLI_ -> SMBCLI_ metze (This used to be commit 8441750fd9427dd6fe477f27e603821b4026f038) --- source4/torture/basic/mangle_test.c | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 4859ee7c4c..c0c77f950f 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -26,7 +26,7 @@ static TDB_CONTEXT *tdb; static uint_t total, collisions, failures; -static BOOL test_one(struct cli_state *cli, const char *name) +static BOOL test_one(struct smbcli_state *cli, const char *name) { int fnum; const char *shortname; @@ -36,48 +36,48 @@ static BOOL test_one(struct cli_state *cli, const char *name) total++; - fnum = cli_open(cli->tree, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); + fnum = smbcli_open(cli->tree, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { - printf("open of %s failed (%s)\n", name, cli_errstr(cli->tree)); + printf("open of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); return False; } - if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) { - printf("close of %s failed (%s)\n", name, cli_errstr(cli->tree)); + if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) { + printf("close of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); return False; } /* get the short name */ - status = cli_qpathinfo_alt_name(cli->tree, name, &shortname); + status = smbcli_qpathinfo_alt_name(cli->tree, name, &shortname); if (!NT_STATUS_IS_OK(status)) { - printf("query altname of %s failed (%s)\n", name, cli_errstr(cli->tree)); + printf("query altname of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); return False; } snprintf(name2, sizeof(name2), "\\mangle_test\\%s", shortname); - if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, name2))) { + if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, name2))) { printf("unlink of %s (%s) failed (%s)\n", - name2, name, cli_errstr(cli->tree)); + name2, name, smbcli_errstr(cli->tree)); return False; } /* recreate by short name */ - fnum = cli_open(cli->tree, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); + fnum = smbcli_open(cli->tree, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { - printf("open2 of %s failed (%s)\n", name2, cli_errstr(cli->tree)); + printf("open2 of %s failed (%s)\n", name2, smbcli_errstr(cli->tree)); return False; } - if (NT_STATUS_IS_ERR(cli_close(cli->tree, fnum))) { - printf("close of %s failed (%s)\n", name, cli_errstr(cli->tree)); + if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) { + printf("close of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); return False; } /* and unlink by long name */ - if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, name))) { + if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, name))) { printf("unlink2 of %s (%s) failed (%s)\n", - name, name2, cli_errstr(cli->tree)); + name, name2, smbcli_errstr(cli->tree)); failures++; - cli_unlink(cli->tree, name2); + smbcli_unlink(cli->tree, name2); return True; } @@ -151,7 +151,7 @@ static void gen_name(char *name) BOOL torture_mangle(int dummy) { extern int torture_numops; - static struct cli_state *cli; + static struct smbcli_state *cli; int i; printf("starting mangle test\n"); @@ -167,10 +167,10 @@ BOOL torture_mangle(int dummy) return False; } - cli_unlink(cli->tree, "\\mangle_test\\*"); - cli_rmdir(cli->tree, "\\mangle_test"); + smbcli_unlink(cli->tree, "\\mangle_test\\*"); + smbcli_rmdir(cli->tree, "\\mangle_test"); - if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, "\\mangle_test"))) { + if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\mangle_test"))) { printf("ERROR: Failed to make directory\n"); return False; } @@ -189,8 +189,8 @@ BOOL torture_mangle(int dummy) } } - cli_unlink(cli->tree, "\\mangle_test\\*"); - if (NT_STATUS_IS_ERR(cli_rmdir(cli->tree, "\\mangle_test"))) { + smbcli_unlink(cli->tree, "\\mangle_test\\*"); + if (NT_STATUS_IS_ERR(smbcli_rmdir(cli->tree, "\\mangle_test"))) { printf("ERROR: Failed to remove directory\n"); return False; } -- cgit From ba6d5fcb97b9831dddf7dfe09fb02fbb23d864b4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Oct 2004 13:40:50 +0000 Subject: r3324: made the smbtorture code completely warning free (This used to be commit 7067bb9b52223cafa28470f264f0b60646a07a01) --- source4/torture/basic/mangle_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index c0c77f950f..8c4f5514a6 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -96,7 +96,7 @@ static BOOL test_one(struct smbcli_state *cli, const char *name) } else { TDB_DATA namedata; /* store it for later */ - namedata.dptr = name; + namedata.dptr = discard_const_p(char, name); namedata.dsize = strlen(name)+1; tdb_store_bystring(tdb, shortname, namedata, TDB_REPLACE); } @@ -148,7 +148,7 @@ static void gen_name(char *name) } -BOOL torture_mangle(int dummy) +BOOL torture_mangle(void) { extern int torture_numops; static struct smbcli_state *cli; -- cgit From 0e255bb542b1f79c32e9295617199ea8d60753d4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 12 Nov 2004 09:37:59 +0000 Subject: r3699: - split the delayed write testing out of RAW-WRITE, as it is not yet clear what the correct behaviour is for delayed stat info update. - use a common torture_setup_dir() function for setting up a test directory in torture tests. (This used to be commit f7fb34715b7d6ea3c35ddd684cfb27459a420339) --- source4/torture/basic/mangle_test.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 8c4f5514a6..70a9227521 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -167,11 +167,7 @@ BOOL torture_mangle(void) return False; } - smbcli_unlink(cli->tree, "\\mangle_test\\*"); - smbcli_rmdir(cli->tree, "\\mangle_test"); - - if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\mangle_test"))) { - printf("ERROR: Failed to make directory\n"); + if (!torture_setup_dir(cli, "\\mangle_test")) { return False; } -- cgit From fedf0b0d91fdf2a6ae0ef47acd4047f662bd3374 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 03:48:43 +0000 Subject: r5296: - only include the tdb headers where they are needed - removed the u32 hack in events.c as I think this was only needed as tdb.h defines u32. Metze, can you check that this hack is indeed no longer needed on your suse system? (This used to be commit 6f79432fe656164d4770dbce114a30dda5e7bf9a) --- source4/torture/basic/mangle_test.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 70a9227521..a0333b1c53 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -19,6 +19,7 @@ */ #include "includes.h" +#include "lib/tdb/include/tdbutil.h" static TDB_CONTEXT *tdb; -- cgit From e82aad1ce39a6b7a2e51b9e2cb494d74ec70e158 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 05:09:35 +0000 Subject: r5298: - got rid of pstring.h from includes.h. This at least makes it a bit less likely that anyone will use pstring for new code - got rid of winbind_client.h from includes.h. This one triggered a huge change, as winbind_client.h was including system/filesys.h and defining the old uint32 and uint16 types, as well as its own pstring and fstring. (This used to be commit 9db6c79e902ec538108d6b7d3324039aabe1704f) --- source4/torture/basic/mangle_test.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index a0333b1c53..3ea2644d1a 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -19,7 +19,9 @@ */ #include "includes.h" +#include "system/filesys.h" #include "lib/tdb/include/tdbutil.h" +#include "pstring.h" static TDB_CONTEXT *tdb; -- cgit From 67de5725bc28129fa942c7d014c9722d0e906dea Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Aug 2005 20:41:48 +0000 Subject: r8895: work around broken glibc strrchr function that gives valgrind errors on some boxes (This used to be commit 5079fdea1b4fde4f844713f42e678759324d801d) --- source4/torture/basic/mangle_test.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 3ea2644d1a..9097a9328b 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -177,6 +177,8 @@ BOOL torture_mangle(void) for (i=0;i Date: Tue, 3 Jan 2006 13:41:17 +0000 Subject: r12693: Move core data structures out of smb.h into core.h torture prototypes in seperate header (This used to be commit 73610639b23ca3743077193fa0b1de7c7f65944d) --- source4/torture/basic/mangle_test.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 9097a9328b..29bb4fcd18 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -19,6 +19,7 @@ */ #include "includes.h" +#include "torture/torture.h" #include "system/filesys.h" #include "lib/tdb/include/tdbutil.h" #include "pstring.h" -- cgit From 78c50015bb8bd5a1d831a6e7ec796b3367c73145 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 3 Jan 2006 15:40:05 +0000 Subject: r12694: Move some headers to the directory of the subsystem they belong to. (This used to be commit c722f665c90103f3ed57621c460e32ad33e7a8a3) --- source4/torture/basic/mangle_test.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 29bb4fcd18..8317a4ee18 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -22,6 +22,7 @@ #include "torture/torture.h" #include "system/filesys.h" #include "lib/tdb/include/tdbutil.h" +#include "libcli/libcli.h" #include "pstring.h" static TDB_CONTEXT *tdb; -- cgit From a920f2f9a8e4ee076471c293765ed0bee13d4cc5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 18 Jan 2006 16:20:33 +0000 Subject: r13004: fix compiler warnings metze (This used to be commit 833efdf8a943b210ba8e5b219dc754260001bedb) --- source4/torture/basic/mangle_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 8317a4ee18..36b7481316 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -90,7 +90,7 @@ static BOOL test_one(struct smbcli_state *cli, const char *name) data = tdb_fetch_bystring(tdb, shortname); if (data.dptr) { /* maybe its a duplicate long name? */ - if (strcasecmp(name, data.dptr) != 0) { + if (strcasecmp(name, (const char *)data.dptr) != 0) { /* we have a collision */ collisions++; printf("Collision between %s and %s -> %s " @@ -101,7 +101,7 @@ static BOOL test_one(struct smbcli_state *cli, const char *name) } else { TDB_DATA namedata; /* store it for later */ - namedata.dptr = discard_const_p(char, name); + namedata.dptr = discard_const_p(uint8_t, name); namedata.dsize = strlen(name)+1; tdb_store_bystring(tdb, shortname, namedata, TDB_REPLACE); } -- cgit From d09b70c98b8222eb293bc9d8713ec071188ed01d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 17 Mar 2006 17:59:58 +0000 Subject: r14527: Fix build problems. (This used to be commit 863ca4014d9b821706ee90f58ab5d5cf3899a4c7) --- source4/torture/basic/mangle_test.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 36b7481316..18b2e912ba 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -23,6 +23,7 @@ #include "system/filesys.h" #include "lib/tdb/include/tdbutil.h" #include "libcli/libcli.h" +#include "torture/util.h" #include "pstring.h" static TDB_CONTEXT *tdb; -- cgit From 909b111f587705a45f63540b39968f1af58a9b5d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 25 Mar 2006 16:01:28 +0000 Subject: r14720: Add torture_context argument to all torture tests (This used to be commit 3c7a5ce29108dd82210dc3e1f00414f545949e1d) --- source4/torture/basic/mangle_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 18b2e912ba..5eb00c076f 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -154,7 +154,7 @@ static void gen_name(char *name) } -BOOL torture_mangle(void) +BOOL torture_mangle(struct torture_context *torture) { extern int torture_numops; static struct smbcli_state *cli; -- cgit From 6ab33938d5239e8688440f65e802f627622d301b Mon Sep 17 00:00:00 2001 From: James Peach Date: Mon, 24 Apr 2006 00:16:51 +0000 Subject: r15186: Introduce ISDOT and ISDOTDOT macros for testing whether a filename is "." for "..". These express the intention better that strcmp or strequal and improve searchability via cscope/ctags. (This used to be commit 7e4ad7e8e5ec266b969e3075c4ad7f021571f24e) --- source4/torture/basic/mangle_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 5eb00c076f..5f2a07e02f 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -21,6 +21,7 @@ #include "includes.h" #include "torture/torture.h" #include "system/filesys.h" +#include "system/dir.h" #include "lib/tdb/include/tdbutil.h" #include "libcli/libcli.h" #include "torture/util.h" @@ -130,7 +131,7 @@ static void gen_name(char *name) p[i] = 0; - if (strcmp(p, ".") == 0 || strcmp(p, "..") == 0) { + if (ISDOT(p) || ISDOTDOT(p)) { p[0] = '_'; } -- cgit From b7c5bc522b286e8e478b6f74a68bc68829e64c3c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 10 Jul 2006 08:00:06 +0000 Subject: r16907: Add an index parameter to torture_open_connection. Next step is to enable the unclist parameter for all tests that do two connections, to enable cluster testing. Volker (This used to be commit a5d6db09244d444986f8fded3fc6e72c74c8ca1f) --- source4/torture/basic/mangle_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 5f2a07e02f..7e17adece7 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -163,7 +163,7 @@ BOOL torture_mangle(struct torture_context *torture) printf("starting mangle test\n"); - if (!torture_open_connection(&cli)) { + if (!torture_open_connection(&cli, 0)) { return False; } -- cgit From 8773e743c518578584d07d35ffdafdd598af88b0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 16 Oct 2006 13:06:41 +0000 Subject: r19339: Merge my 4.0-unittest branch. This adds an API for more fine-grained output in the testsuite rather than just True or False for a set of tests. The aim is to use this for: * known failure lists (run all tests and detect tests that started working or started failing). This would allow us to get rid of the RPC-SAMBA3-* tests * nicer torture output * simplification of the testsuite system * compatibility with other unit testing systems * easier usage of smbtorture (being able to run one test and automatically set up the environment for that) This is still a work-in-progress; expect more updates over the next couple of days. (This used to be commit 0eb6097305776325c75081356309115f445a7218) --- source4/torture/basic/mangle_test.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 7e17adece7..091e471e8a 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -155,18 +155,12 @@ static void gen_name(char *name) } -BOOL torture_mangle(struct torture_context *torture) +BOOL torture_mangle(struct torture_context *torture, + struct smbcli_state *cli) { extern int torture_numops; - static struct smbcli_state *cli; int i; - printf("starting mangle test\n"); - - if (!torture_open_connection(&cli, 0)) { - return False; - } - /* we will use an internal tdb to store the names we have used */ tdb = tdb_open(NULL, 100000, TDB_INTERNAL, 0, 0); if (!tdb) { @@ -203,8 +197,5 @@ BOOL torture_mangle(struct torture_context *torture) printf("\nTotal collisions %u/%u - %.2f%% (%u failures)\n", collisions, total, (100.0*collisions) / total, failures); - torture_close_connection(cli); - - printf("mangle test finished\n"); return (failures == 0); } -- cgit From af870da6194b47c6cd09445c1e03832d00e951bb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 20 Oct 2006 23:32:23 +0000 Subject: r19428: moved tdbutil.c from lib/tdb/common/ to lib/util/util_tdb.c tdbutil.c is Samba specific, so should not be part of the generic tdb library (This used to be commit 979dd24f5e44605fc1603b690913b8c31be7478f) --- source4/torture/basic/mangle_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 091e471e8a..68ee0b63f5 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -22,7 +22,8 @@ #include "torture/torture.h" #include "system/filesys.h" #include "system/dir.h" -#include "lib/tdb/include/tdbutil.h" +#include "lib/tdb/include/tdb.h" +#include "lib/util/util_tdb.h" #include "libcli/libcli.h" #include "torture/util.h" #include "pstring.h" -- cgit From 628ff1bea3e167e2d45dffbffb3c4fffaa3d1916 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 29 Apr 2007 21:37:29 +0000 Subject: r22579: disable progress printing in the build-farm metze (This used to be commit 93089ad5e8b6e20c4fa92bf13b0137765aeac689) --- source4/torture/basic/mangle_test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 68ee0b63f5..98a0d07efb 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -184,8 +184,10 @@ BOOL torture_mangle(struct torture_context *torture, break; } if (total && total % 100 == 0) { - printf("collisions %u/%u - %.2f%% (%u failures)\r", - collisions, total, (100.0*collisions) / total, failures); + if (torture_setting_bool(torture, "progress", true)) { + printf("collisions %u/%u - %.2f%% (%u failures)\r", + collisions, total, (100.0*collisions) / total, failures); + } } } -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/torture/basic/mangle_test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 98a0d07efb..665360fc64 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From cd962355abad90a2161765a7be7d26e63572cab7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Sep 2007 15:08:14 +0000 Subject: r25000: Fix some more C++ compatibility warnings. (This used to be commit 08bb1ef643ab906f1645cf6f32763dc73b1884e4) --- source4/torture/basic/mangle_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 665360fc64..d13450dd3a 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -155,8 +155,8 @@ static void gen_name(char *name) } -BOOL torture_mangle(struct torture_context *torture, - struct smbcli_state *cli) +bool torture_mangle(struct torture_context *torture, + struct smbcli_state *cli) { extern int torture_numops; int i; -- cgit From 3b6186a67630cf05bc33e6e9288e132f39173ef4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Sep 2007 17:59:53 +0000 Subject: r25008: Remove use of pstring. (This used to be commit c57869e2620de30c303b0cb2f70cd07b32f269fc) --- source4/torture/basic/mangle_test.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index d13450dd3a..729e2c5c43 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -25,7 +25,6 @@ #include "lib/util/util_tdb.h" #include "libcli/libcli.h" #include "torture/util.h" -#include "pstring.h" static TDB_CONTEXT *tdb; @@ -33,11 +32,12 @@ static TDB_CONTEXT *tdb; static uint_t total, collisions, failures; -static BOOL test_one(struct smbcli_state *cli, const char *name) +static bool test_one(struct torture_context *tctx ,struct smbcli_state *cli, + const char *name) { int fnum; const char *shortname; - fstring name2; + const char *name2; NTSTATUS status; TDB_DATA data; @@ -46,12 +46,12 @@ static BOOL test_one(struct smbcli_state *cli, const char *name) fnum = smbcli_open(cli->tree, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { printf("open of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) { printf("close of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); - return False; + return false; } /* get the short name */ @@ -61,7 +61,7 @@ static BOOL test_one(struct smbcli_state *cli, const char *name) return False; } - snprintf(name2, sizeof(name2), "\\mangle_test\\%s", shortname); + name2 = talloc_asprintf(tctx, "\\mangle_test\\%s", shortname); if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, name2))) { printf("unlink of %s (%s) failed (%s)\n", name2, name, smbcli_errstr(cli->tree)); @@ -112,18 +112,21 @@ static BOOL test_one(struct smbcli_state *cli, const char *name) } -static void gen_name(char *name) +static char *gen_name(TALLOC_CTX *mem_ctx) { const char *chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-$~..."; uint_t max_idx = strlen(chars); uint_t len; int i; char *p; + char *name; - fstrcpy(name, "\\mangle_test\\"); - p = name + strlen(name); + name = talloc_strdup(mem_ctx, "\\mangle_test\\"); len = 1 + random() % NAME_LENGTH; + + name = talloc_realloc(mem_ctx, name, char, strlen(name) + len + 6); + p = name + strlen(name); for (i=0;i Date: Sun, 16 Sep 2007 10:30:31 +0000 Subject: r25186: Fix a memory corruption in base-mangle (This used to be commit 4822b3f0db11059281b33e896250f36e3b3448eb) --- source4/torture/basic/mangle_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 729e2c5c43..dc7bc21a55 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -144,7 +144,7 @@ static char *gen_name(TALLOC_CTX *mem_ctx) } /* and a medium probability of a common lead string */ - if (random() % 10 == 0) { + if ((len > 5) && (random() % 10 == 0)) { strncpy(p, "ABCDE", 5); } -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/torture/basic/mangle_test.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source4/torture/basic/mangle_test.c') diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index dc7bc21a55..58d7098972 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -58,25 +58,25 @@ static bool test_one(struct torture_context *tctx ,struct smbcli_state *cli, status = smbcli_qpathinfo_alt_name(cli->tree, name, &shortname); if (!NT_STATUS_IS_OK(status)) { printf("query altname of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); - return False; + return false; } name2 = talloc_asprintf(tctx, "\\mangle_test\\%s", shortname); if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, name2))) { printf("unlink of %s (%s) failed (%s)\n", name2, name, smbcli_errstr(cli->tree)); - return False; + return false; } /* recreate by short name */ fnum = smbcli_open(cli->tree, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { printf("open2 of %s failed (%s)\n", name2, smbcli_errstr(cli->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) { printf("close of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); - return False; + return false; } /* and unlink by long name */ @@ -85,7 +85,7 @@ static bool test_one(struct torture_context *tctx ,struct smbcli_state *cli, name, name2, smbcli_errstr(cli->tree)); failures++; smbcli_unlink(cli->tree, name2); - return True; + return true; } /* see if the short name is already in the tdb */ @@ -108,7 +108,7 @@ static bool test_one(struct torture_context *tctx ,struct smbcli_state *cli, tdb_store_bystring(tdb, shortname, namedata, TDB_REPLACE); } - return True; + return true; } @@ -170,11 +170,11 @@ bool torture_mangle(struct torture_context *torture, tdb = tdb_open(NULL, 100000, TDB_INTERNAL, 0, 0); if (!tdb) { printf("ERROR: Failed to open tdb\n"); - return False; + return false; } if (!torture_setup_dir(cli, "\\mangle_test")) { - return False; + return false; } for (i=0;itree, "\\mangle_test\\*"); if (NT_STATUS_IS_ERR(smbcli_rmdir(cli->tree, "\\mangle_test"))) { printf("ERROR: Failed to remove directory\n"); - return False; + return false; } printf("\nTotal collisions %u/%u - %.2f%% (%u failures)\n", -- cgit