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(-) 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