r14173: change smb interface structures to always use
[gd/samba-autobuild/.git] / source4 / torture / torture.c
index 82fda0d4ff58dda89ae639f0d0a6e7d89305fe69..9598e1ea2e5ad375546fb2e9228a2d3a9826282f 100644 (file)
 #include "system/time.h"
 #include "system/wait.h"
 #include "system/filesys.h"
-#include "ioctl.h"
+#include "libcli/raw/ioctl.h"
+#include "libcli/libcli.h"
+#include "lib/ldb/include/ldb.h"
+#include "librpc/rpc/dcerpc_table.h"
+#include "lib/events/events.h"
+#include "libcli/resolve/resolve.h"
+
+#include "torture/basic/proto.h"
+#include "torture/raw/proto.h"
+#include "torture/smb2/proto.h"
+#include "torture/rpc/proto.h"
+#include "torture/rap/proto.h"
+#include "torture/auth/proto.h"
+#include "torture/local/proto.h"
+#include "torture/nbench/proto.h"
+#include "torture/ldap/proto.h"
+#include "torture/com/proto.h"
+#include "torture/nbt/proto.h"
+#include "torture/libnet/proto.h"
+#include "torture/torture.h"
 
 int torture_nprocs=4;
 int torture_numops=10;
@@ -894,30 +913,35 @@ static BOOL run_negprot_nowait(void)
 
        printf("Filling send buffer\n");
 
-       for (i=0;i<1000;i++) {
+       for (i=0;i<100;i++) {
                struct smbcli_request *req;
                req = smb_raw_negotiate_send(cli->transport, PROTOCOL_NT1);
-               smbcli_transport_process(cli->transport);
+               event_loop_once(cli->transport->socket->event.ctx);
                if (req->state == SMBCLI_REQUEST_ERROR) {
-                       printf("Failed to fill pipe - %s\n", nt_errstr(req->status));
-                       torture_close_connection(cli);
-                       return correct;
+                       if (i > 0) {
+                               printf("Failed to fill pipe packet[%d] - %s (ignored)\n", i+1, nt_errstr(req->status));
+                               break;
+                       } else {
+                               printf("Failed to fill pipe - %s \n", nt_errstr(req->status));
+                               torture_close_connection(cli);
+                               return False;
+                       }
                }
        }
 
        printf("Opening secondary connection\n");
        if (!torture_open_connection(&cli2)) {
-               return False;
-       }
-
-       if (!torture_close_connection(cli)) {
+               printf("Failed to open secondary connection\n");
                correct = False;
        }
 
        if (!torture_close_connection(cli2)) {
+               printf("Failed to close secondary connection\n");
                correct = False;
        }
 
+       torture_close_connection(cli);
+
        printf("finished negprot nowait test\n");
 
        return correct;
@@ -1898,7 +1922,7 @@ BOOL torture_ioctl_test(void)
        }
 
        parms.ioctl.level = RAW_IOCTL_IOCTL;
-       parms.ioctl.in.fnum = fnum;
+       parms.ioctl.file.fnum = fnum;
        parms.ioctl.in.request = IOCTL_QUERY_JOB_INFO;
        status = smb_raw_ioctl(cli->tree, mem_ctx, &parms);
        printf("ioctl job info: %s\n", smbcli_errstr(cli->tree));
@@ -2269,6 +2293,7 @@ static struct {
 
        /* rpc testers */
         {"RPC-LSA", torture_rpc_lsa, 0},
+        {"RPC-LSALOOKUP", torture_rpc_lsa_lookup, 0},
         {"RPC-SECRETS", torture_rpc_lsa_secrets, 0},
         {"RPC-ECHO", torture_rpc_echo, 0},
         {"RPC-DFS", torture_rpc_dfs, 0},
@@ -2330,7 +2355,10 @@ static struct {
        {"NBT-REGISTER", torture_nbt_register, 0},
        {"NBT-WINS", torture_nbt_wins, 0},
        {"NBT-DGRAM", torture_nbt_dgram, 0},
-       {"NBT-WINSREPLICATION", torture_nbt_winsreplication, 0},
+       {"NBT-BROWSE", torture_nbt_browse, 0},
+       {"NBT-WINSREPLICATION-SIMPLE", torture_nbt_winsreplication_simple, 0},
+       {"NBT-WINSREPLICATION-REPLICA", torture_nbt_winsreplication_replica, 0},
+       {"NBT-WINSREPLICATION-OWNED", torture_nbt_winsreplication_owned, 0},
        
        /* libnet tests */
        {"NET-USERINFO", torture_userinfo, 0},
@@ -2539,10 +2567,12 @@ static void max_runtime_handler(int sig)
        int argc_new;
        char **argv_new;
        poptContext pc;
-       enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS,OPT_DANGEROUS};
+       enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS,
+           OPT_DANGEROUS,OPT_SMB_PORTS};
+
        struct poptOption long_options[] = {
                POPT_AUTOHELP
-               {"smb-ports",   'p', POPT_ARG_STRING, NULL,             0,      "SMB ports",    NULL},
+               {"smb-ports",   'p', POPT_ARG_STRING, NULL,     OPT_SMB_PORTS,  "SMB ports",    NULL},
                {"seed",          0, POPT_ARG_INT,  &torture_seed,      0,      "seed",         NULL},
                {"num-progs",     0, POPT_ARG_INT,  &torture_nprocs,    0,      "num progs",    NULL},
                {"num-ops",       0, POPT_ARG_INT,  &torture_numops,    0,      "num ops",      NULL},
@@ -2568,6 +2598,9 @@ static void max_runtime_handler(int sig)
        setbuffer(stdout, NULL, 0);
 #endif
 
+       /* we are never interested in SIGPIPE */
+       BlockSignals(True,SIGPIPE);
+
        pc = poptGetContext("smbtorture", argc, (const char **) argv, long_options, 
                            POPT_CONTEXT_KEEP_FIRST);
 
@@ -2590,6 +2623,9 @@ static void max_runtime_handler(int sig)
                case OPT_DANGEROUS:
                        lp_set_cmdline("torture:dangerous", "Yes");
                        break;
+               case OPT_SMB_PORTS:
+                       lp_set_cmdline("smb ports", poptGetOptArg(pc));
+                       break;
                default:
                        d_printf("Invalid option %s: %s\n", 
                                 poptBadOption(pc, 0), poptStrerror(opt));
@@ -2608,6 +2644,8 @@ static void max_runtime_handler(int sig)
                alarm(max_runtime);
        }
 
+       ldb_global_init();
+
        dcerpc_init();
 
        dcerpc_table_init();