This would appear to restore smbtorture to be able to use the syntax
[samba.git] / source4 / torture / torture.c
index f54483ae455a3ef9e59c98d5482e12657f597a27..46bb99d2eac380748e0c8e4eafb72763f82a0006 100644 (file)
@@ -26,7 +26,6 @@ int torture_entries=1000;
 int torture_failures=1;
 static int procnum; /* records process count number when forking */
 static struct cli_state *current_cli;
-static char *randomfname;
 static BOOL use_oplocks;
 static BOOL use_level_II_oplocks;
 static const char *client_txt = "client_oplocks.txt";
@@ -98,11 +97,11 @@ BOOL torture_open_connection(struct cli_state **c)
 
        if (use_kerberos)
                flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
-       
+
        status = cli_full_connection(c, lp_netbios_name(),
                                     host, NULL, 
                                     share, "?????", 
-                                    username, lp_workgroup(), 
+                                    username, username[0]?lp_workgroup():"",
                                     password, flags, &retry);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to open connection - %s\n", nt_errstr(status));
@@ -132,6 +131,36 @@ BOOL torture_close_connection(struct cli_state *c)
 }
 
 
+/* open a rpc connection to a named pipe */
+NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p, 
+                               const char *pipe_name,
+                               const char *pipe_uuid, 
+                               uint32 pipe_version)
+{
+        NTSTATUS status;
+       char *binding = lp_parm_string(-1, "torture", "binding");
+
+       if (!binding) {
+               printf("You must specify a ncacn binding string\n");
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       status = dcerpc_pipe_connect(p, binding, pipe_uuid, pipe_version,
+                                    lp_workgroup(), 
+                                    lp_parm_string(-1, "torture", "username"),
+                                    lp_parm_string(-1, "torture", "password"));
+        return status;
+}
+
+/* close a rpc connection to a named pipe */
+NTSTATUS torture_rpc_close(struct dcerpc_pipe *p)
+{
+       dcerpc_pipe_close(p);
+       return NT_STATUS_OK;
+}
+
+
 /* check if the server produced the expected error code */
 static BOOL check_error(int line, struct cli_state *c, 
                        uint8 eclass, uint32 ecode, NTSTATUS nterr)
@@ -285,7 +314,7 @@ static BOOL run_torture(int dummy)
        return ret;
 }
 
-static BOOL rw_torture3(struct cli_state *c, char *lockfname)
+static BOOL rw_torture3(struct cli_state *c, const char *lockfname)
 {
        int fnum = -1;
        unsigned int i = 0;
@@ -503,8 +532,7 @@ static BOOL run_readwritemulti(int dummy)
 
        cli = current_cli;
 
-       printf("run_readwritemulti: fname %s\n", randomfname);
-       test = rw_torture3(cli, randomfname);
+       test = rw_torture3(cli, "\\multitest.txt");
 
        if (!torture_close_connection(cli)) {
                test = False;
@@ -2777,7 +2805,7 @@ static BOOL run_rename(int dummy)
 static BOOL run_pipe_number(int dummy)
 {
        struct cli_state *cli1;
-       const char *pipe_name = "\\SPOOLSS";
+       const char *pipe_name = "\\WKSSVC";
        int fnum;
        int num_pipes = 0;
 
@@ -3476,9 +3504,8 @@ BOOL torture_ioctl_test(int dummy)
        uint16 device, function;
        int fnum;
        const char *fname = "\\ioctl.dat";
-       DATA_BLOB blob;
        NTSTATUS status;
-       struct smb_ioctl parms;
+       union smb_ioctl parms;
        TALLOC_CTX *mem_ctx;
 
        if (!torture_open_connection(&cli)) {
@@ -3497,20 +3524,20 @@ BOOL torture_ioctl_test(int dummy)
                return False;
        }
 
-       parms.in.request = IOCTL_QUERY_JOB_INFO;
+       parms.ioctl.level = RAW_IOCTL_IOCTL;
+       parms.ioctl.in.request = IOCTL_QUERY_JOB_INFO;
        status = smb_raw_ioctl(cli->tree, mem_ctx, &parms);
        printf("ioctl job info: %s\n", cli_errstr(cli));
 
        for (device=0;device<0x100;device++) {
                printf("testing device=0x%x\n", device);
                for (function=0;function<0x100;function++) {
-                       parms.in.request = (device << 16) | function;
+                       parms.ioctl.in.request = (device << 16) | function;
                        status = smb_raw_ioctl(cli->tree, mem_ctx, &parms);
 
                        if (NT_STATUS_IS_OK(status)) {
                                printf("ioctl device=0x%x function=0x%x OK : %d bytes\n", 
-                                       device, function, blob.length);
-                               data_blob_free(&parms.out.blob);
+                                       device, function, parms.ioctl.out.blob.length);
                        }
                }
        }
@@ -3755,6 +3782,9 @@ static BOOL run_deny3test(int dummy)
        return True;
 }
 
+static void sigcont(void)
+{
+}
 
 static double create_procs(BOOL (*fn)(int), BOOL *result)
 {
@@ -3763,10 +3793,12 @@ static double create_procs(BOOL (*fn)(int), BOOL *result)
        volatile BOOL *child_status_out;
        int synccount;
        int tries = 8;
-       double start_time_limit = 10 + (nprocs * 0.5);
+       double start_time_limit = 10 + (nprocs * 1.5);
 
        synccount = 0;
 
+       signal(SIGCONT, sigcont);
+
        child_status = (volatile pid_t *)shm_setup(sizeof(pid_t)*nprocs);
        if (!child_status) {
                printf("Failed to setup shared memory\n");
@@ -3808,7 +3840,7 @@ static double create_procs(BOOL (*fn)(int), BOOL *result)
 
                        child_status[i] = getpid();
 
-                       while (child_status[i] && end_timer() < start_time_limit) msleep(2);
+                       pause();
 
                        if (child_status[i]) {
                                printf("Child %d failed to start!\n", i);
@@ -3840,10 +3872,10 @@ static double create_procs(BOOL (*fn)(int), BOOL *result)
 
        /* start the client load */
        start_timer();
-
        for (i=0;i<nprocs;i++) {
                child_status[i] = 0;
        }
+       kill(0, SIGCONT);
 
        printf("%d clients started\n", nprocs);
 
@@ -3939,6 +3971,21 @@ static struct {
        {"SCAN-NTTRANS", torture_nttrans_scan, 0},
        {"SCAN-ALIASES", torture_trans2_aliases, 0},
        {"SCAN-SMB", torture_smb_scan, 0},
+        {"RPC-LSA", torture_rpc_lsa, 0},
+        {"RPC-ECHO", torture_rpc_echo, 0},
+        {"RPC-DFS", torture_rpc_dfs, 0},
+        {"RPC-SPOOLSS", torture_rpc_spoolss, 0},
+        {"RPC-SAMR", torture_rpc_samr, 0},
+        {"RPC-NETLOGON", torture_rpc_netlogon, 0},
+        {"RPC-WKSSVC", torture_rpc_wkssvc, 0},
+        {"RPC-SRVSVC", torture_rpc_srvsvc, 0},
+        {"RPC-ATSVC", torture_rpc_atsvc, 0},
+        {"RPC-EVENTLOG", torture_rpc_eventlog, 0},
+        {"RPC-EPMAPPER", torture_rpc_epmapper, 0},
+        {"RPC-WINREG", torture_rpc_winreg, 0},
+        {"RPC-MGMT", torture_rpc_mgmt, 0},
+        {"RPC-SCANNER", torture_rpc_scanner, 0},
+        {"RPC-AUTOIDL", torture_rpc_autoidl, 0},
        {NULL, NULL, 0}};
 
 
@@ -3962,9 +4009,6 @@ static BOOL run_test(const char *name)
        }
 
        for (i=0;torture_ops[i].name;i++) {
-               asprintf(&randomfname, "\\XX%x", 
-                        (unsigned)random());
-
                if (gen_fnmatch(name, torture_ops[i].name) == 0) {
                        double t;
                        matched = True;
@@ -4078,27 +4122,37 @@ static void usage(void)
         for(p = argv[1]; *p; p++)
           if(*p == '\\')
             *p = '/';
-       if (strncmp(argv[1], "//", 2)) {
-               usage();
-       }
 
-       host = strdup(&argv[1][2]);
-       p = strchr_m(&host[2],'/');
-       if (!p) {
-               usage();
+
+       /* see if its a RPC transport specifier */
+       if (strncmp(argv[1], "ncacn_", 6) == 0) {
+               lp_set_cmdline("torture:binding", argv[1]);
+       } else {
+               char *binding = NULL;
+               if (strncmp(argv[1], "//", 2)) {
+                       usage();
+               }
+
+               host = strdup(&argv[1][2]);
+               p = strchr_m(&host[2],'/');
+               if (!p) {
+                       usage();
+               }
+               *p = 0;
+               share = strdup(p+1);
+               
+               lp_set_cmdline("torture:host", host);
+               lp_set_cmdline("torture:share", share);
+               lp_set_cmdline("torture:password", "");
+               asprintf(&binding, "ncacn_np:%s", host);
+               lp_set_cmdline("torture:binding", binding);
        }
-       *p = 0;
-       share = strdup(p+1);
 
        if (getenv("LOGNAME")) {
                username = strdup(getenv("LOGNAME"));
        }
-
-       lp_set_cmdline("torture:host", host);
-       lp_set_cmdline("torture:share", share);
        lp_set_cmdline("torture:username", username);
-       lp_set_cmdline("torture:password", "");
+
 
        argc--;
        argv++;
@@ -4168,10 +4222,6 @@ static void usage(void)
                }
        }
 
-       printf("host=%s share=%s user=%s myname=%s\n", 
-              host, share, lp_parm_string(-1, "torture", "username"), 
-              lp_netbios_name());
-
        if (argc == optind) {
                printf("You must specify a test to run, or 'ALL'\n");
        } else {