summaryrefslogtreecommitdiff
path: root/source4/torture/raw/write.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-20 11:13:54 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:01:57 -0500
commit31a4070fcc9cf45d08fe5b8789032957f03f8d2b (patch)
tree5e32c81c60b1df8cf9fd625567720407212af659 /source4/torture/raw/write.c
parent74e741037cb9ffdceea509be052b2161bdda3ef2 (diff)
downloadsamba-31a4070fcc9cf45d08fe5b8789032957f03f8d2b.tar.gz
samba-31a4070fcc9cf45d08fe5b8789032957f03f8d2b.tar.bz2
samba-31a4070fcc9cf45d08fe5b8789032957f03f8d2b.zip
r3085: make the RAW-WRITE tests more robust to errors in previous parts of the test
(This used to be commit 6ea815b6d426d37723a200226cb5f7236a13017f)
Diffstat (limited to 'source4/torture/raw/write.c')
-rw-r--r--source4/torture/raw/write.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/source4/torture/raw/write.c b/source4/torture/raw/write.c
index 276e5398ac..8b4de9c7e7 100644
--- a/source4/torture/raw/write.c
+++ b/source4/torture/raw/write.c
@@ -58,6 +58,18 @@
#define BASEDIR "\\testwrite"
+static BOOL setup_dir(struct smbcli_state *cli, const char *dname)
+{
+ smb_raw_exit(cli->session);
+ if (smbcli_deltree(cli->tree, dname) == -1 ||
+ NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, dname))) {
+ printf("Unable to setup %s - %s\n", dname, smbcli_errstr(cli->tree));
+ return False;
+ }
+ return True;
+}
+
+
/*
setup a random buffer based on a seed
*/
@@ -103,9 +115,7 @@ static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
buf = talloc_zero(mem_ctx, maxsize);
- if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
+ if (!setup_dir(cli, BASEDIR)) {
return False;
}
@@ -222,9 +232,7 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
buf = talloc_zero(mem_ctx, maxsize);
- if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
+ if (!setup_dir(cli, BASEDIR)) {
return False;
}
@@ -396,9 +404,7 @@ static BOOL test_writeunlock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
buf = talloc_zero(mem_ctx, maxsize);
- if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
+ if (!setup_dir(cli, BASEDIR)) {
return False;
}
@@ -535,9 +541,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
buf = talloc_zero(mem_ctx, maxsize);
- if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
+ if (!setup_dir(cli, BASEDIR)) {
return False;
}
@@ -682,9 +686,7 @@ static BOOL test_delayed_write_update(struct smbcli_state *cli, TALLOC_CTX *mem_
printf("Testing delayed update of write time\n");
- if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
+ if (!setup_dir(cli, BASEDIR)) {
return False;
}
@@ -715,7 +717,7 @@ static BOOL test_delayed_write_update(struct smbcli_state *cli, TALLOC_CTX *mem_
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
if (written != 1) {
- printf("write failed - wrote %d bytes\n", written);
+ printf("write failed - wrote %d bytes (%s)\n", written, __location__);
return False;
}
@@ -776,9 +778,7 @@ static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx
printf("Testing finfo update on close\n");
- if (smbcli_deltree(cli->tree, BASEDIR) == -1 ||
- NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR))) {
- printf("Unable to setup %s - %s\n", BASEDIR, smbcli_errstr(cli->tree));
+ if (!setup_dir(cli, BASEDIR)) {
return False;
}