Fix a bunch of "warning: variable ‘XXXX’ set but not used [-Wunused-but-set-variable...
[kai/samba.git] / source4 / torture / basic / disconnect.c
index 5bc7d997edb8d59d6f7af2a519499bc0c901060e..17fbc61d2f8c8e0719d86ca2499ae357dd864bb5 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
-#include "torture/torture.h"
 #include "system/filesys.h"
 #include "libcli/raw/libcliraw.h"
+#include "libcli/raw/raw_proto.h"
 #include "libcli/libcli.h"
 #include "torture/util.h"
+#include "torture/basic/proto.h"
 
 #define BASEDIR "\\test_disconnect"
 
                printf("(%s) Incorrect status %s - should be %s\n", \
                       __location__, nt_errstr(status), nt_errstr(correct)); \
                talloc_free(cli); \
-               return False; \
+               return false; \
        }} while (0)
 
 /*
   test disconnect after async open
 */
-static BOOL test_disconnect_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_disconnect_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
 {
        union smb_open io;
-       NTSTATUS status;
        struct smbcli_request *req1, *req2;
+       NTSTATUS status;
 
        printf("trying open/disconnect\n");
 
        io.generic.level = RAW_OPEN_NTCREATEX;
-       io.ntcreatex.in.root_fid = 0;
+       io.ntcreatex.in.root_fid.fnum = 0;
        io.ntcreatex.in.flags = 0;
        io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA;
        io.ntcreatex.in.create_options = 0;
@@ -66,20 +66,25 @@ static BOOL test_disconnect_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.ntcreatex.in.share_access = 0;
        req1 = smb_raw_open_send(cli->tree, &io);
        req2 = smb_raw_open_send(cli->tree, &io);
+       if (!req1 || !req2) {
+               printf("test_disconnect_open: smb_raw_open_send() "
+                       "returned NULL\n");
+               return false;
+       }
 
        status = smbcli_chkpath(cli->tree, "\\");
        CHECK_STATUS(status, NT_STATUS_OK);
        
        talloc_free(cli);
 
-       return True;
+       return true;
 }
 
 
 /*
   test disconnect with timed lock
 */
-static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
 {
        union smb_lock io;
        NTSTATUS status;
@@ -93,7 +98,7 @@ static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
                           O_RDWR | O_CREAT, DENY_NONE);
        if (fnum == -1) {
                printf("open failed in mux_write - %s\n", smbcli_errstr(cli->tree));
-               return False;
+               return false;
        }
 
        io.lockx.level = RAW_LOCK_LOCKX;
@@ -113,13 +118,18 @@ static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        lock[0].pid = 2;
        io.lockx.in.timeout = 3000;
        req = smb_raw_lock_send(cli->tree, &io);
+       if (!req) {
+               printf("test_disconnect_lock: smb_raw_lock_send() "
+                       "returned NULL\n");
+               return false;
+       }
 
        status = smbcli_chkpath(cli->tree, "\\");
        CHECK_STATUS(status, NT_STATUS_OK);
 
        talloc_free(cli);
 
-       return True;
+       return true;
 }
 
 
@@ -127,9 +137,9 @@ static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
 /* 
    basic testing of disconnects
 */
-BOOL torture_disconnect(struct torture_context *torture)
+bool torture_disconnect(struct torture_context *torture)
 {
-       BOOL ret = True;
+       bool ret = true;
        TALLOC_CTX *mem_ctx;
        int i;
        extern int torture_numops;
@@ -137,33 +147,33 @@ BOOL torture_disconnect(struct torture_context *torture)
 
        mem_ctx = talloc_init("torture_raw_mux");
 
-       if (!torture_open_connection(&cli, 0)) {
-               return False;
+       if (!torture_open_connection(&cli, torture, 0)) {
+               return false;
        }
 
        if (!torture_setup_dir(cli, BASEDIR)) {
-               return False;
+               return false;
        }
 
        for (i=0;i<torture_numops;i++) {
                ret &= test_disconnect_lock(cli, mem_ctx);
-               if (!torture_open_connection(&cli, 0)) {
-                       return False;
+               if (!torture_open_connection(&cli, torture, 0)) {
+                       return false;
                }
 
                ret &= test_disconnect_open(cli, mem_ctx);
-               if (!torture_open_connection(&cli, 0)) {
-                       return False;
+               if (!torture_open_connection(&cli, torture, 0)) {
+                       return false;
                }
 
-               if (torture_setting_bool(torture, "samba3", False)) {
+               if (torture_setting_bool(torture, "samba3", false)) {
                        /*
                         * In Samba3 it might happen that the old smbd from
                         * test_disconnect_lock is not scheduled before the
                         * new process comes in. Try to get rid of the random
                         * failures in the build farm.
                         */
-                       msleep(200);
+                       smb_msleep(200);
                }
        }