diff options
author | Andrew Bartlett <abartlet@samba.org> | 2003-04-23 08:12:34 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2003-04-23 08:12:34 +0000 |
commit | 2206df6b30c4992daa17257287390421cfc0662d (patch) | |
tree | e22b30e4aa5e028b6b1c7c5d5e7e53b77e3d25e3 /source3/torture/mangle_test.c | |
parent | a7d2c332fca9c85c21ff6dba424559c9323feacf (diff) | |
download | samba-2206df6b30c4992daa17257287390421cfc0662d.tar.gz samba-2206df6b30c4992daa17257287390421cfc0662d.tar.bz2 samba-2206df6b30c4992daa17257287390421cfc0662d.zip |
Merge torture tests from HEAD - it looks like we had rather an incomplete
merge last time. I hope this might fix a few failures on the build farm too.
Andrew Bartlett
(This used to be commit 0c837126923cc30fa60223a5a68d4f527971cc7b)
Diffstat (limited to 'source3/torture/mangle_test.c')
-rw-r--r-- | source3/torture/mangle_test.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/source3/torture/mangle_test.c b/source3/torture/mangle_test.c index 6d127a918e..e4ccfc1b83 100644 --- a/source3/torture/mangle_test.c +++ b/source3/torture/mangle_test.c @@ -107,7 +107,7 @@ static BOOL test_one(struct cli_state *cli, const char *name) static void gen_name(char *name) { - const char *chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-$~..."; + const char *chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-$~... "; unsigned max_idx = strlen(chars); unsigned len; int i; @@ -135,7 +135,12 @@ static void gen_name(char *name) /* and a medium probability of a common lead string */ if (random() % 10 == 0) { - strncpy(p, "ABCDE", 5); + if (strlen(p) <= 5) { + fstrcpy(p, "ABCDE"); + } else { + /* try not to kill off the null termination */ + memcpy(p, "ABCDE", 5); + } } /* and a high probability of a good extension length */ @@ -151,8 +156,9 @@ static void gen_name(char *name) BOOL torture_mangle(int dummy) { extern int torture_numops; - static struct cli_state cli; + static struct cli_state *cli; int i; + BOOL ret = True; printf("starting mangle test\n"); @@ -167,20 +173,22 @@ BOOL torture_mangle(int dummy) return False; } - cli_unlink(&cli, "\\mangle_test\\*"); - cli_rmdir(&cli, "\\mangle_test"); + cli_unlink(cli, "\\mangle_test\\*"); + cli_rmdir(cli, "\\mangle_test"); - if (!cli_mkdir(&cli, "\\mangle_test")) { + if (!cli_mkdir(cli, "\\mangle_test")) { printf("ERROR: Failed to make directory\n"); return False; } for (i=0;i<torture_numops;i++) { fstring name; + ZERO_STRUCT(name); gen_name(name); - - if (!test_one(&cli, name)) { + + if (!test_one(cli, name)) { + ret = False; break; } if (total && total % 100 == 0) { @@ -189,8 +197,8 @@ BOOL torture_mangle(int dummy) } } - cli_unlink(&cli, "\\mangle_test\\*"); - if (!cli_rmdir(&cli, "\\mangle_test")) { + cli_unlink(cli, "\\mangle_test\\*"); + if (!cli_rmdir(cli, "\\mangle_test")) { printf("ERROR: Failed to remove directory\n"); return False; } @@ -198,8 +206,8 @@ BOOL torture_mangle(int dummy) printf("\nTotal collisions %u/%u - %.2f%% (%u failures)\n", collisions, total, (100.0*collisions) / total, failures); - torture_close_connection(&cli); + torture_close_connection(cli); printf("mangle test finished\n"); - return (failures == 0); + return (ret && (failures == 0)); } |