diff options
Diffstat (limited to 'source3/torture')
-rw-r--r-- | source3/torture/torture.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 75a5b30e30..d8942e42b9 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -4897,6 +4897,117 @@ static bool subst_test(const char *str, const char *user, const char *domain, return result; } +static void chain1_open_completion(struct async_req *req) +{ + int fnum; + NTSTATUS status; + + status = cli_open_recv(req, &fnum); + TALLOC_FREE(req); + + d_printf("cli_open_recv returned %s: %d\n", + nt_errstr(status), + NT_STATUS_IS_OK(status) ? fnum : -1); +} + +static void chain1_read_completion(struct async_req *req) +{ + NTSTATUS status; + ssize_t received; + uint8_t *rcvbuf; + + status = cli_read_andx_recv(req, &received, &rcvbuf); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(req); + d_printf("cli_read_andx_recv returned %s\n", + nt_errstr(status)); + return; + } + + d_printf("got %d bytes: %.*s\n", (int)received, (int)received, + (char *)rcvbuf); + TALLOC_FREE(req); +} + +static void chain1_close_completion(struct async_req *req) +{ + NTSTATUS status; + + status = cli_close_recv(req); + *((bool *)(req->async.priv)) = true; + + TALLOC_FREE(req); + + d_printf("cli_close returned %s\n", nt_errstr(status)); +} + +static bool run_chain1(int dummy) +{ + struct cli_state *cli1; + struct event_context *evt = event_context_init(NULL); + struct async_req *reqs[4]; + bool done = false; + + printf("starting chain1 test\n"); + if (!torture_open_connection(&cli1, 0)) { + return False; + } + + cli_sockopt(cli1, sockops); + + cli_chain_cork(cli1, evt, 0); + reqs[0] = cli_open_send(talloc_tos(), evt, cli1, "\\test", + O_CREAT|O_RDWR, 0); + reqs[0]->async.fn = chain1_open_completion; + reqs[1] = cli_read_andx_send(talloc_tos(), evt, cli1, 0, 0, 10); + reqs[1]->async.fn = chain1_read_completion; + reqs[2] = cli_read_andx_send(talloc_tos(), evt, cli1, 0, 1, 10); + reqs[2]->async.fn = chain1_read_completion; + reqs[3] = cli_close_send(talloc_tos(), evt, cli1, 0); + reqs[3]->async.fn = chain1_close_completion; + reqs[3]->async.priv = (void *)&done; + cli_chain_uncork(cli1); + + while (!done) { + event_loop_once(evt); + } + + torture_close_connection(cli1); + return True; +} + +static bool run_cli_echo(int dummy) +{ + struct cli_state *cli; + struct event_context *ev = event_context_init(NULL); + struct async_req *req; + NTSTATUS status; + + printf("starting chain1 test\n"); + if (!torture_open_connection(&cli, 0)) { + return false; + } + cli_sockopt(cli, sockops); + + req = cli_echo_send(ev, ev, cli, 5, data_blob_const("hello", 5)); + if (req == NULL) { + d_printf("cli_echo_send failed\n"); + return false; + } + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(ev); + } + + status = cli_echo_recv(req); + d_printf("cli_echo returned %s\n", nt_errstr(status)); + + TALLOC_FREE(req); + + torture_close_connection(cli); + return NT_STATUS_IS_OK(status); +} + static bool run_local_substitute(int dummy) { bool ok = true; @@ -5394,6 +5505,8 @@ static struct { {"FDSESS", run_fdsesstest, 0}, { "EATEST", run_eatest, 0}, { "SESSSETUP_BENCH", run_sesssetup_bench, 0}, + { "CHAIN1", run_chain1, 0}, + { "CLI_ECHO", run_cli_echo, 0}, { "LOCAL-SUBSTITUTE", run_local_substitute, 0}, { "LOCAL-GENCACHE", run_local_gencache, 0}, { "LOCAL-RBTREE", run_local_rbtree, 0}, |