From 9915045a453eb90dfa768af988fbf01d0c72f2a8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 19 Dec 2008 23:41:19 +0100 Subject: Add a torture test simulating Windows write behaviour Jeremy, enjoy :-) --- source3/torture/torture.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) (limited to 'source3/torture/torture.c') diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 5584c22a8f..5e5ce3798c 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -28,6 +28,7 @@ static const char *sockops="TCP_NODELAY"; static int nprocs=1; static int port_to_use=0; int torture_numops=100; +int torture_blocksize=1024*1024; static int procnum; /* records process count number when forking */ static struct cli_state *current_cli; static fstring randomfname; @@ -4974,6 +4975,81 @@ static bool run_chain1(int dummy) return True; } +static size_t null_source(uint8_t *buf, size_t n, void *priv) +{ + size_t *to_pull = (size_t *)priv; + size_t thistime = *to_pull; + + thistime = MIN(thistime, n); + if (thistime == 0) { + return 0; + } + + memset(buf, 0, thistime); + *to_pull -= thistime; + return thistime; +} + +static bool run_windows_write(int dummy) +{ + struct cli_state *cli1; + int fnum; + int i; + bool ret = false; + const char *fname = "\\writetest.txt"; + double seconds; + double kbytes; + + printf("starting windows_write test\n"); + if (!torture_open_connection(&cli1, 0)) { + return False; + } + + fnum = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); + if (fnum == -1) { + printf("open failed (%s)\n", cli_errstr(cli1)); + return False; + } + + cli_sockopt(cli1, sockops); + + start_timer(); + + for (i=0; i Date: Fri, 19 Dec 2008 23:49:14 +0100 Subject: Extend the chain1 test with write&x --- source3/torture/torture.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'source3/torture/torture.c') diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 5e5ce3798c..6bf7aa8e25 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -4928,6 +4928,23 @@ static void chain1_read_completion(struct async_req *req) TALLOC_FREE(req); } +static void chain1_write_completion(struct async_req *req) +{ + NTSTATUS status; + size_t written; + + status = cli_write_andx_recv(req, &written); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(req); + d_printf("cli_write_andx_recv returned %s\n", + nt_errstr(status)); + return; + } + + d_printf("wrote %d bytes\n", (int)written); + TALLOC_FREE(req); +} + static void chain1_close_completion(struct async_req *req) { NTSTATUS status; @@ -4946,6 +4963,7 @@ static bool run_chain1(int dummy) struct event_context *evt = event_context_init(NULL); struct async_req *reqs[4]; bool done = false; + const char *text = "hallo"; printf("starting chain1 test\n"); if (!torture_open_connection(&cli1, 0)) { @@ -4958,8 +4976,9 @@ static bool run_chain1(int dummy) 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[1] = cli_write_andx_send(talloc_tos(), evt, cli1, 0, 0, + (uint8_t *)text, 0, strlen(text)); + reqs[1]->async.fn = chain1_write_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); -- cgit