diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-04-12 03:42:44 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-04-12 03:42:44 +0000 |
commit | a2d5f9a8098343d2f2209a56c8858479ba33e9c9 (patch) | |
tree | 6e1c9b34fa4f1934cae1c0a5eca14f47ce3f2461 /source3/torture/mangle_test.c | |
parent | 3067ec21fb34f46fd1683aad6d455e7d6da8f52e (diff) | |
download | samba-a2d5f9a8098343d2f2209a56c8858479ba33e9c9.tar.gz |
better mangling test. We now test that we can create by long name and
delete by short name, and that we can create by short name and delete
by long name
our old mangling code fails this test.
also tweaked the random filename generation to produce more likely
collisions
(This used to be commit 65609c52960c2b5938150a2fdb5290541f4e0225)
Diffstat (limited to 'source3/torture/mangle_test.c')
-rw-r--r-- | source3/torture/mangle_test.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/source3/torture/mangle_test.c b/source3/torture/mangle_test.c index 9024925beb1..7f05b953c5e 100644 --- a/source3/torture/mangle_test.c +++ b/source3/torture/mangle_test.c @@ -22,7 +22,7 @@ static TDB_CONTEXT *tdb; -#define NAME_LENGTH 30 +#define NAME_LENGTH 20 static unsigned total, collisions; @@ -61,6 +61,24 @@ static BOOL test_one(struct cli_state *cli, const char *name) return False; } + /* recreate by short name */ + fnum = cli_open(cli, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); + if (fnum == -1) { + printf("open2 of %s failed (%s)\n", name2, cli_errstr(cli)); + return False; + } + if (!cli_close(cli, fnum)) { + printf("close of %s failed (%s)\n", name, cli_errstr(cli)); + return False; + } + + /* and unlink by long name */ + if (!cli_unlink(cli, name)) { + printf("unlink2 of %s (%s) failed (%s)\n", + name, name2, cli_errstr(cli)); + return False; + } + /* see if the short name is already in the tdb */ data = tdb_fetch_by_string(tdb, shortname); if (data.dptr) { @@ -83,7 +101,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; @@ -103,6 +121,19 @@ static void gen_name(char *name) if (strcmp(p, ".") == 0 || strcmp(p, "..") == 0) { p[0] = '_'; } + + /* have a high probability of a common lead char */ + if (random() % 2 == 0) { + p[0] = 'A'; + } + + /* and a high probability of a good extension length */ + if (random() % 2 == 0) { + char *s = strrchr(p, '.'); + if (s) { + s[4] = 0; + } + } } |