summaryrefslogtreecommitdiff
path: root/source4/torture/torture.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-05-14 22:07:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:53:46 -0500
commit31b9470996632d717c3c74482308e200906fdb8f (patch)
tree9c5fc8d0ce2efc4839b50601529ecfd492f773dc /source4/torture/torture.c
parent2bc3b3bcec7900cda3841af95ab08e07c3d26c9d (diff)
downloadsamba-31b9470996632d717c3c74482308e200906fdb8f.tar.gz
samba-31b9470996632d717c3c74482308e200906fdb8f.tar.bz2
samba-31b9470996632d717c3c74482308e200906fdb8f.zip
r741: Test from Volker in RAW-OPEN for truncating a file containing locks.
Also added the same ad-hoc test is LOCK7. Jeremy. (This used to be commit 6cb21ccda3cb420171e2d5afb3842a6be4bd4d18)
Diffstat (limited to 'source4/torture/torture.c')
-rw-r--r--source4/torture/torture.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 09ab503274..78674990e8 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -1489,6 +1489,8 @@ static BOOL run_locktest7(int dummy)
struct cli_state *cli1;
const char *fname = "\\lockt7.lck";
int fnum1;
+ int fnum2;
+ size_t size;
char buf[200];
BOOL correct = False;
@@ -1603,11 +1605,38 @@ static BOOL run_locktest7(int dummy)
goto fail;
}
- cli_unlock(cli1->tree, fnum1, 130, 0);
+ printf("Testing truncate of locked file.\n");
+
+ fnum2 = cli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE);
+
+ if (fnum2 == -1) {
+ printf("Unable to truncate locked file.\n");
+ correct = False;
+ goto fail;
+ } else {
+ printf("Truncated locked file.\n");
+ }
+
+ if (NT_STATUS_IS_ERR(cli_getatr(cli1->tree, fname, NULL, &size, NULL))) {
+ printf("getatr failed (%s)\n", cli_errstr(cli1->tree));
+ correct = False;
+ goto fail;
+ }
+
+ if (size != 0) {
+ printf("Unable to truncate locked file. Size was %u\n", size);
+ correct = False;
+ goto fail;
+ }
+
+ cli1->session->pid = 1;
+
+ cli_unlock(cli1->tree, fnum1, 130, 4);
correct = True;
fail:
cli_close(cli1->tree, fnum1);
+ cli_close(cli1->tree, fnum2);
cli_unlink(cli1->tree, fname);
torture_close_connection(cli1);
@@ -3225,7 +3254,9 @@ error_test60:
}
printf("non-io open test #7 passed.\n");
+
error_test70:
+
cli_unlink(cli1->tree, fname);
if (!torture_close_connection(cli1)) {