r6581: improved the error message for RAW-LOCK timeouts
[samba.git] / source / torture / raw / lock.c
index 034c79326044454d24d9271e225eb6473f0ac294..4976d53b910de5577e4c26679e7009ea440c45c9 100644 (file)
@@ -21,6 +21,7 @@
 #include "includes.h"
 #include "libcli/raw/libcliraw.h"
 #include "system/time.h"
+#include "system/filesys.h"
 
 #define CHECK_STATUS(status, correct) do { \
        if (!NT_STATUS_EQUAL(status, correct)) { \
@@ -52,9 +53,7 @@ static BOOL test_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        int fnum;
        const char *fname = BASEDIR "\\test.txt";
 
-       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 (!torture_setup_dir(cli, BASEDIR)) {
                return False;
        }
 
@@ -190,9 +189,7 @@ static BOOL test_lockx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        int fnum;
        const char *fname = BASEDIR "\\test.txt";
 
-       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 (!torture_setup_dir(cli, BASEDIR)) {
                return False;
        }
 
@@ -370,11 +367,9 @@ static BOOL test_pidhigh(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        BOOL ret = True;
        int fnum;
        const char *fname = BASEDIR "\\test.txt";
-       char c = 1;
+       uint8_t c = 1;
 
-       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 (!torture_setup_dir(cli, BASEDIR)) {
                return False;
        }
 
@@ -456,9 +451,7 @@ static BOOL test_async(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        time_t t;
        struct smbcli_request *req;
 
-       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 (!torture_setup_dir(cli, BASEDIR)) {
                return False;
        }
 
@@ -550,11 +543,13 @@ static BOOL test_async(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
 
+       t = time(NULL);
        status = smbcli_request_simple_recv(req);
        CHECK_STATUS(status, NT_STATUS_OK);
 
        if (time(NULL) > t+2) {
-               printf("lock cancel by unlock was not immediate (%s)\n", __location__);
+               printf("lock cancel by unlock was not immediate (%s) - took %d secs\n", 
+                      __location__, (int)time(NULL)-t);
                ret = False;
                goto done;
        }
@@ -606,12 +601,10 @@ static BOOL test_changetype(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        NTSTATUS status;
        BOOL ret = True;
        int fnum;
-       char c = 0;
+       uint8_t c = 0;
        const char *fname = BASEDIR "\\test.txt";
 
-       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 (!torture_setup_dir(cli, BASEDIR)) {
                return False;
        }
 
@@ -685,6 +678,6 @@ BOOL torture_raw_lock(void)
        ret &= test_changetype(cli, mem_ctx);
 
        torture_close_connection(cli);
-       talloc_destroy(mem_ctx);
+       talloc_free(mem_ctx);
        return ret;
 }