summaryrefslogtreecommitdiff
path: root/source3/torture/torture.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-12-19 23:51:23 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-12-19 23:51:23 +0100
commit9617a3945b804bf2d1409285df2a7add12690063 (patch)
treeb6506c7f5ed050900b511bbffb52df3544bda505 /source3/torture/torture.c
parent0898b96d26981d553e041a78721e32946bd4bddf (diff)
parentd26a34c22f5d2685f8e75149f87db8d086e32e13 (diff)
downloadsamba-9617a3945b804bf2d1409285df2a7add12690063.tar.gz
samba-9617a3945b804bf2d1409285df2a7add12690063.tar.bz2
samba-9617a3945b804bf2d1409285df2a7add12690063.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source3/torture/torture.c')
-rw-r--r--source3/torture/torture.c105
1 files changed, 102 insertions, 3 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 5584c22a8f..6bf7aa8e25 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;
@@ -4927,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;
@@ -4945,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)) {
@@ -4957,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);
@@ -4974,6 +4994,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<torture_numops; i++) {
+ char c = 0;
+ off_t start = i * torture_blocksize;
+ NTSTATUS status;
+ size_t to_pull = torture_blocksize - 1;
+
+ if (cli_write(cli1, fnum, 0, &c,
+ start + torture_blocksize - 1, 1) != 1) {
+ printf("cli_write failed: %s\n", cli_errstr(cli1));
+ goto fail;
+ }
+
+ status = cli_push(cli1, fnum, 0, i * torture_blocksize, torture_blocksize,
+ null_source, &to_pull);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_push returned: %s\n", nt_errstr(status));
+ goto fail;
+ }
+ }
+
+ seconds = end_timer();
+ kbytes = (double)torture_blocksize * torture_numops;
+ kbytes /= 1024;
+
+ printf("Wrote %d kbytes in %.2f seconds: %d kb/sec\n", (int)kbytes,
+ (double)seconds, (int)(kbytes/seconds));
+
+ ret = true;
+ fail:
+ cli_close(cli1, fnum);
+ cli_unlink(cli1, fname);
+ torture_close_connection(cli1);
+ return ret;
+}
+
static bool run_cli_echo(int dummy)
{
struct cli_state *cli;
@@ -5535,6 +5630,7 @@ static struct {
{ "EATEST", run_eatest, 0},
{ "SESSSETUP_BENCH", run_sesssetup_bench, 0},
{ "CHAIN1", run_chain1, 0},
+ { "WINDOWS-WRITE", run_windows_write, 0},
{ "CLI_ECHO", run_cli_echo, 0},
{ "LOCAL-SUBSTITUTE", run_local_substitute, 0},
{ "LOCAL-GENCACHE", run_local_gencache, 0},
@@ -5693,7 +5789,7 @@ static void usage(void)
fstrcpy(workgroup, lp_workgroup());
- while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:m:Ld:Aec:ks:b:")) != EOF) {
+ while ((opt = getopt(argc, argv, "p:hW:U:n:N:O:o:m:Ld:Aec:ks:b:B:")) != EOF) {
switch (opt) {
case 'p':
port_to_use = atoi(optarg);
@@ -5756,6 +5852,9 @@ static void usage(void)
fstrcpy(multishare_conn_fname, optarg);
use_multishare_conn = True;
break;
+ case 'B':
+ torture_blocksize = atoi(optarg);
+ break;
default:
printf("Unknown option %c (%d)\n", (char)opt, opt);
usage();