diff options
author | Richard Sharpe <sharpe@samba.org> | 2004-02-25 22:14:35 +0000 |
---|---|---|
committer | Richard Sharpe <sharpe@samba.org> | 2004-02-25 22:14:35 +0000 |
commit | eb8ed992c65a4d394d40ef21002c366ce501c7e4 (patch) | |
tree | 949459299acc3aa323371deae247ef63e8ef33ec /source3 | |
parent | ebd86253c6bfb8ccb01e23c7e0446802e9009825 (diff) | |
download | samba-eb8ed992c65a4d394d40ef21002c366ce501c7e4.tar.gz samba-eb8ed992c65a4d394d40ef21002c366ce501c7e4.tar.bz2 samba-eb8ed992c65a4d394d40ef21002c366ce501c7e4.zip |
Adds some more tests of renaming an open file that has been opened with
different share modes. It also has a commented out test to see if we can
actually open a renamed file, and it turns out that we can, it seems. I am
not sure at this stage how long that is the case for, though.
(This used to be commit 89d810d234f53c9731ded85848bd9c17d45d5125)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/torture/torture.c | 83 |
1 files changed, 76 insertions, 7 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 57ba24e63e..9947e22c4f 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -3326,7 +3326,7 @@ static BOOL run_rename(int dummy) const char *fname = "\\test.txt"; const char *fname1 = "\\test1.txt"; BOOL correct = True; - int fnum1; + int fnum1, fnum2; printf("starting rename test\n"); @@ -3345,9 +3345,9 @@ static BOOL run_rename(int dummy) } if (!cli_rename(cli1, fname, fname1)) { - printf("First rename failed (this is correct) - %s\n", cli_errstr(cli1)); + printf("First rename failed (SHARE_READ) (this is correct) - %s\n", cli_errstr(cli1)); } else { - printf("First rename succeeded - this should have failed !\n"); + printf("First rename succeeded (SHARE_READ) - this should have failed !\n"); correct = False; } @@ -3371,10 +3371,10 @@ static BOOL run_rename(int dummy) } if (!cli_rename(cli1, fname, fname1)) { - printf("Second rename failed - this should have succeeded - %s\n", cli_errstr(cli1)); + printf("Second rename failed (SHARE_DELETE | SHARE_READ) - this should have succeeded - %s\n", cli_errstr(cli1)); correct = False; } else { - printf("Second rename succeeded\n"); + printf("Second rename succeeded (SHARE_DELETE | SHARE_READ)\n"); } if (!cli_close(cli1, fnum1)) { @@ -3418,10 +3418,10 @@ static BOOL run_rename(int dummy) #endif if (!cli_rename(cli1, fname, fname1)) { - printf("Third rename failed - this should have succeeded - %s\n", cli_errstr(cli1)); + printf("Third rename failed (SHARE_NONE) - this should have succeeded - %s\n", cli_errstr(cli1)); correct = False; } else { - printf("Third rename succeeded\n"); + printf("Third rename succeeded (SHARE_NONE)\n"); } if (!cli_close(cli1, fnum1)) { @@ -3432,6 +3432,75 @@ static BOOL run_rename(int dummy) cli_unlink(cli1, fname); cli_unlink(cli1, fname1); + /*----*/ + + fnum1 = cli_nt_create_full(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL, + FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OVERWRITE_IF, 0, 0); + + if (fnum1 == -1) { + printf("Fourth open failed - %s\n", cli_errstr(cli1)); + return False; + } + + if (!cli_rename(cli1, fname, fname1)) { + printf("Fourth rename failed (SHARE_READ | SHARE_WRITE) (this is correct) - %s\n", cli_errstr(cli1)); + } else { + printf("Fourth rename succeeded (SHARE_READ | SHARE_WRITE) - this should have failed !\n"); + correct = False; + } + + if (!cli_close(cli1, fnum1)) { + printf("close - 4 failed (%s)\n", cli_errstr(cli1)); + return False; + } + + cli_unlink(cli1, fname); + cli_unlink(cli1, fname1); + + /*--*/ + + fnum1 = cli_nt_create_full(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0, 0); + + if (fnum1 == -1) { + printf("Fifth open failed - %s\n", cli_errstr(cli1)); + return False; + } + + if (!cli_rename(cli1, fname, fname1)) { + printf("Fifth rename failed (SHARE_READ | SHARE_WRITE | SHARE_DELETE) - this should have failed ! \n"); + correct = False; + } else { + printf("Fifth rename succeeded (SHARE_READ | SHARE_WRITE | SHARE_DELETE) (this is correct) - %s\n", cli_errstr(cli1)); + } + + /* + * Now check if the first name still exists ... + */ + + /*fnum2 = cli_nt_create_full(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0, 0); + + if (fnum2 == -1) { + printf("Opening original file after rename of open file fails: %s\n", + cli_errstr(cli1)); + } + else { + printf("Opening original file after rename of open file works ...\n"); + (void)cli_close(cli1, fnum2); + } */ + + /*--*/ + + + if (!cli_close(cli1, fnum1)) { + printf("close - 5 failed (%s)\n", cli_errstr(cli1)); + return False; + } + + cli_unlink(cli1, fname); + cli_unlink(cli1, fname1); + if (!torture_close_connection(cli1)) { correct = False; } |