Fix a typo
[nivanova/samba-autobuild/.git] / source3 / torture / torture.c
index 00e8266a22af8a359aaabc00ce6ea9c87eef51aa..1d463467517adc8a09a5673b80e8cd3cce935c8f 100644 (file)
@@ -2471,7 +2471,7 @@ static bool run_attrtest(int dummy)
        cli_open(cli, fname, 
                        O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
        cli_close(cli, fnum);
-       if (!cli_getatr(cli, fname, NULL, NULL, &t)) {
+       if (!NT_STATUS_IS_OK(cli_getatr(cli, fname, NULL, NULL, &t))) {
                printf("getatr failed (%s)\n", cli_errstr(cli));
                correct = False;
        }
@@ -2485,12 +2485,12 @@ static bool run_attrtest(int dummy)
 
        t2 = t-60*60*24; /* 1 day ago */
 
-       if (!cli_setatr(cli, fname, 0, t2)) {
+       if (!NT_STATUS_IS_OK(cli_setatr(cli, fname, 0, t2))) {
                printf("setatr failed (%s)\n", cli_errstr(cli));
                correct = True;
        }
 
-       if (!cli_getatr(cli, fname, NULL, NULL, &t)) {
+       if (!NT_STATUS_IS_OK(cli_getatr(cli, fname, NULL, NULL, &t))) {
                printf("getatr failed (%s)\n", cli_errstr(cli));
                correct = True;
        }
@@ -3726,7 +3726,7 @@ static bool run_opentest(int dummy)
                return False;
        }
 
-       if (!cli_setatr(cli1, fname, aRONLY, 0)) {
+       if (!NT_STATUS_IS_OK(cli_setatr(cli1, fname, aRONLY, 0))) {
                printf("cli_setatr failed (%s)\n", cli_errstr(cli1));
                return False;
        }
@@ -3796,7 +3796,7 @@ static bool run_opentest(int dummy)
        }
 
        /* Ensure size == 20. */
-       if (!cli_getatr(cli1, fname, NULL, &fsize, NULL)) {
+       if (!NT_STATUS_IS_OK(cli_getatr(cli1, fname, NULL, &fsize, NULL))) {
                printf("(3) getatr failed (%s)\n", cli_errstr(cli1));
                return False;
        }
@@ -3819,7 +3819,7 @@ static bool run_opentest(int dummy)
        }
 
        /* Ensure size == 0. */
-       if (!cli_getatr(cli1, fname, NULL, &fsize, NULL)) {
+       if (!NT_STATUS_IS_OK(cli_getatr(cli1, fname, NULL, &fsize, NULL))) {
                printf("(3) getatr failed (%s)\n", cli_errstr(cli1));
                return False;
        }
@@ -4285,7 +4285,7 @@ static bool run_openattrtest(int dummy)
                                return False;
                        }
 
-                       if (!cli_getatr(cli1, fname, &attr, NULL, NULL)) {
+                       if (!NT_STATUS_IS_OK(cli_getatr(cli1, fname, &attr, NULL, NULL))) {
                                printf("getatr(2) failed (%s)\n", cli_errstr(cli1));
                                return False;
                        }
@@ -4995,6 +4995,58 @@ static bool run_chain1(int dummy)
        return True;
 }
 
+static void chain2_sesssetup_completion(struct tevent_req *req)
+{
+       NTSTATUS status;
+       status = cli_session_setup_guest_recv(req);
+       d_printf("sesssetup returned %s\n", nt_errstr(status));
+}
+
+static void chain2_tcon_completion(struct tevent_req *req)
+{
+       bool *done = (bool *)tevent_req_callback_data_void(req);
+       NTSTATUS status;
+       status = cli_tcon_andx_recv(req);
+       d_printf("tcon_and_x returned %s\n", nt_errstr(status));
+       *done = true;
+}
+
+static bool run_chain2(int dummy)
+{
+       struct cli_state *cli1;
+       struct event_context *evt = event_context_init(NULL);
+       struct tevent_req *reqs[2], *smbreqs[2];
+       bool done = false;
+
+       printf("starting chain2 test\n");
+       if (!torture_open_connection(&cli1, 0)) {
+               return False;
+       }
+
+       cli_sockopt(cli1, sockops);
+
+       reqs[0] = cli_session_setup_guest_create(talloc_tos(), evt, cli1,
+                                                &smbreqs[0]);
+       if (reqs[0] == NULL) return false;
+       tevent_req_set_callback(reqs[0], chain2_sesssetup_completion, NULL);
+
+       reqs[1] = cli_tcon_andx_create(talloc_tos(), evt, cli1, "IPC$",
+                                      "?????", NULL, 0, &smbreqs[1]);
+       if (reqs[1] == NULL) return false;
+       tevent_req_set_callback(reqs[1], chain2_tcon_completion, &done);
+
+       if (!cli_smb_chain_send(smbreqs, ARRAY_SIZE(smbreqs))) {
+               return false;
+       }
+
+       while (!done) {
+               event_loop_once(evt);
+       }
+
+       torture_close_connection(cli1);
+       return True;
+}
+
 static bool run_mangle1(int dummy)
 {
        struct cli_state *cli;
@@ -5006,7 +5058,7 @@ static bool run_mangle1(int dummy)
        SMB_OFF_T size;
        uint16_t mode;
 
-       printf("starting chain1 test\n");
+       printf("starting mangle1 test\n");
        if (!torture_open_connection(&cli, 0)) {
                return False;
        }
@@ -5866,6 +5918,7 @@ static struct {
        { "EATEST", run_eatest, 0},
        { "SESSSETUP_BENCH", run_sesssetup_bench, 0},
        { "CHAIN1", run_chain1, 0},
+       { "CHAIN2", run_chain2, 0},
        { "WINDOWS-WRITE", run_windows_write, 0},
        { "CLI_ECHO", run_cli_echo, 0},
        { "GETADDRINFO", run_getaddrinfo_send, 0},