From 8773e743c518578584d07d35ffdafdd598af88b0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 16 Oct 2006 13:06:41 +0000 Subject: r19339: Merge my 4.0-unittest branch. This adds an API for more fine-grained output in the testsuite rather than just True or False for a set of tests. The aim is to use this for: * known failure lists (run all tests and detect tests that started working or started failing). This would allow us to get rid of the RPC-SAMBA3-* tests * nicer torture output * simplification of the testsuite system * compatibility with other unit testing systems * easier usage of smbtorture (being able to run one test and automatically set up the environment for that) This is still a work-in-progress; expect more updates over the next couple of days. (This used to be commit 0eb6097305776325c75081356309115f445a7218) --- source4/torture/basic/misc.c | 855 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 855 insertions(+) create mode 100644 source4/torture/basic/misc.c (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c new file mode 100644 index 0000000000..c00372b805 --- /dev/null +++ b/source4/torture/basic/misc.c @@ -0,0 +1,855 @@ +/* + Unix SMB/CIFS implementation. + SMB torture tester + Copyright (C) Andrew Tridgell 1997-2003 + Copyright (C) Jelmer Vernooij 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "libcli/raw/libcliraw.h" +#include "system/time.h" +#include "system/wait.h" +#include "system/filesys.h" +#include "libcli/raw/ioctl.h" +#include "libcli/libcli.h" +#include "lib/events/events.h" +#include "libcli/resolve/resolve.h" +#include "auth/credentials/credentials.h" +#include "librpc/gen_ndr/ndr_nbt.h" +#include "torture/torture.h" +#include "torture/util.h" +#include "libcli/smb_composite/smb_composite.h" +#include "libcli/composite/composite.h" + +extern struct cli_credentials *cmdline_credentials; +static void benchrw_callback(struct smbcli_request *req); +enum benchrw_stage { + START, + OPEN_CONNECTION, + CLEANUP_TESTDIR, + MK_TESTDIR, + OPEN_FILE, + INITIAL_WRITE, + READ_WRITE_DATA, + MAX_OPS_REACHED, + ERROR, + CLOSE_FILE, + CLEANUP, + FINISHED +}; + +struct benchrw_state{ + struct torture_context *tctx; + char *dname; + char *fname; + uint16_t fnum; + int nr; + struct smbcli_tree *cli; + uint8_t *buffer; + int writecnt; + int readcnt; + int completed; + TALLOC_CTX *mem_ctx; + void *req_params; + enum benchrw_stage mode; + struct params{ + struct unclist{ + const char *host; + const char *share; + } **unc; + const char *workgroup; + int retry; + unsigned int writeblocks; + unsigned int blocksize; + unsigned int writeratio; + } *lp_params; + }; + +static BOOL wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len) +{ + while (NT_STATUS_IS_ERR(smbcli_lock(c->tree, fnum, offset, len, -1, WRITE_LOCK))) { + if (!check_error(__location__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False; + } + return True; +} + + +static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) +{ + const char *lockfname = "\\torture.lck"; + char *fname; + int fnum; + int fnum2; + pid_t pid2, pid = getpid(); + int i, j; + uint8_t buf[1024]; + BOOL correct = True; + + fnum2 = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL, + DENY_NONE); + if (fnum2 == -1) + fnum2 = smbcli_open(c->tree, lockfname, O_RDWR, DENY_NONE); + if (fnum2 == -1) { + torture_comment(tctx, "open of %s failed (%s)\n", lockfname, smbcli_errstr(c->tree)); + return False; + } + + + for (i=0;itree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL); + if (fnum == -1) { + torture_comment(tctx, "open failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + break; + } + + if (smbcli_write(c->tree, fnum, 0, &pid, 0, sizeof(pid)) != sizeof(pid)) { + torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + + for (j=0;j<50;j++) { + if (smbcli_write(c->tree, fnum, 0, buf, + sizeof(pid)+(j*sizeof(buf)), + sizeof(buf)) != sizeof(buf)) { + torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + } + + pid2 = 0; + + if (smbcli_read(c->tree, fnum, &pid2, 0, sizeof(pid)) != sizeof(pid)) { + torture_comment(tctx, "read failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + + if (pid2 != pid) { + torture_comment(tctx, "data corruption!\n"); + correct = False; + } + + if (NT_STATUS_IS_ERR(smbcli_close(c->tree, fnum))) { + torture_comment(tctx, "close failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + + if (NT_STATUS_IS_ERR(smbcli_unlink(c->tree, fname))) { + torture_comment(tctx, "unlink failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + + if (NT_STATUS_IS_ERR(smbcli_unlock(c->tree, fnum2, n*sizeof(int), sizeof(int)))) { + torture_comment(tctx, "unlock failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + free(fname); + } + + smbcli_close(c->tree, fnum2); + smbcli_unlink(c->tree, lockfname); + + torture_comment(tctx, "%d\n", i); + + return correct; +} + +BOOL run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dummy) +{ + return rw_torture(tctx, cli); +} + + +/* + see how many RPC pipes we can open at once +*/ +BOOL run_pipe_number(struct torture_context *tctx, + struct smbcli_state *cli1) +{ + const char *pipe_name = "\\WKSSVC"; + int fnum; + int num_pipes = 0; + + while(1) { + fnum = smbcli_nt_create_full(cli1->tree, pipe_name, 0, SEC_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OPEN_IF, 0, 0); + + if (fnum == -1) { + torture_comment(tctx, "Open of pipe %s failed with error (%s)\n", pipe_name, smbcli_errstr(cli1->tree)); + break; + } + num_pipes++; + torture_comment(tctx, "%d\r", num_pipes); + fflush(stdout); + } + + torture_comment(tctx, "pipe_number test - we can open %d %s pipes.\n", num_pipes, pipe_name ); + return True; +} + + + + +/* + open N connections to the server and just hold them open + used for testing performance when there are N idle users + already connected + */ +BOOL torture_holdcon(struct torture_context *tctx) +{ + int i; + struct smbcli_state **cli; + int num_dead = 0; + + torture_comment(tctx, "Opening %d connections\n", torture_numops); + + cli = malloc_array_p(struct smbcli_state *, torture_numops); + + for (i=0;itree, "\\"); + if (!NT_STATUS_IS_OK(status)) { + torture_comment(tctx, "Connection %d is dead\n", i); + cli[i] = NULL; + num_dead++; + } + usleep(100); + } + } + + if (num_dead == torture_numops) { + torture_comment(tctx, "All connections dead - finishing\n"); + break; + } + + torture_comment(tctx, "."); + fflush(stdout); + } + + return True; +} + +/* +test how many open files this server supports on the one socket +*/ +BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int dummy) +{ +#define MAXFID_TEMPLATE "\\maxfid\\fid%d\\maxfid.%d.%d" + char *fname; + int fnums[0x11000], i; + int retries=4, maxfid; + BOOL correct = True; + + if (retries <= 0) { + torture_comment(tctx, "failed to connect\n"); + return False; + } + + if (smbcli_deltree(cli->tree, "\\maxfid") == -1) { + torture_comment(tctx, "Failed to deltree \\maxfid - %s\n", + smbcli_errstr(cli->tree)); + return False; + } + if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\maxfid"))) { + torture_comment(tctx, "Failed to mkdir \\maxfid, error=%s\n", + smbcli_errstr(cli->tree)); + return False; + } + + torture_comment(tctx, "Testing maximum number of open files\n"); + + for (i=0; i<0x11000; i++) { + if (i % 1000 == 0) { + asprintf(&fname, "\\maxfid\\fid%d", i/1000); + if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) { + torture_comment(tctx, "Failed to mkdir %s, error=%s\n", + fname, smbcli_errstr(cli->tree)); + return False; + } + free(fname); + } + asprintf(&fname, MAXFID_TEMPLATE, i/1000, i,(int)getpid()); + if ((fnums[i] = smbcli_open(cli->tree, fname, + O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) == + -1) { + torture_comment(tctx, "open of %s failed (%s)\n", + fname, smbcli_errstr(cli->tree)); + torture_comment(tctx, "maximum fnum is %d\n", i); + break; + } + free(fname); + torture_comment(tctx, "%6d\r", i); + } + torture_comment(tctx, "%6d\n", i); + i--; + + maxfid = i; + + torture_comment(tctx, "cleaning up\n"); + for (i=0;itree, fnums[i]))) { + torture_comment(tctx, "Close of fnum %d failed - %s\n", fnums[i], smbcli_errstr(cli->tree)); + } + if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { + torture_comment(tctx, "unlink of %s failed (%s)\n", + fname, smbcli_errstr(cli->tree)); + correct = False; + } + free(fname); + + asprintf(&fname, MAXFID_TEMPLATE, (maxfid-i)/1000, maxfid-i,(int)getpid()); + if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnums[maxfid-i]))) { + torture_comment(tctx, "Close of fnum %d failed - %s\n", fnums[maxfid-i], smbcli_errstr(cli->tree)); + } + if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { + torture_comment(tctx, "unlink of %s failed (%s)\n", + fname, smbcli_errstr(cli->tree)); + correct = False; + } + free(fname); + + torture_comment(tctx, "%6d %6d\r", i, maxfid-i); + } + torture_comment(tctx, "%6d\n", 0); + + if (smbcli_deltree(cli->tree, "\\maxfid") == -1) { + torture_comment(tctx, "Failed to deltree \\maxfid - %s\n", + smbcli_errstr(cli->tree)); + return False; + } + + torture_comment(tctx, "maxfid test finished\n"); + if (!torture_close_connection(cli)) { + correct = False; + } + return correct; +#undef MAXFID_TEMPLATE +} + + + +/* + sees what IOCTLs are supported + */ +BOOL torture_ioctl_test(struct torture_context *tctx, + struct smbcli_state *cli) +{ + uint16_t device, function; + int fnum; + const char *fname = "\\ioctl.dat"; + NTSTATUS status; + union smb_ioctl parms; + TALLOC_CTX *mem_ctx; + + mem_ctx = talloc_named_const(tctx, 0, "ioctl_test"); + + smbcli_unlink(cli->tree, fname); + + fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); + if (fnum == -1) { + torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); + return False; + } + + parms.ioctl.level = RAW_IOCTL_IOCTL; + parms.ioctl.in.file.fnum = fnum; + parms.ioctl.in.request = IOCTL_QUERY_JOB_INFO; + status = smb_raw_ioctl(cli->tree, mem_ctx, &parms); + torture_comment(tctx, "ioctl job info: %s\n", smbcli_errstr(cli->tree)); + + for (device=0;device<0x100;device++) { + torture_comment(tctx, "testing device=0x%x\n", device); + for (function=0;function<0x100;function++) { + parms.ioctl.in.request = (device << 16) | function; + status = smb_raw_ioctl(cli->tree, mem_ctx, &parms); + + if (NT_STATUS_IS_OK(status)) { + torture_comment(tctx, "ioctl device=0x%x function=0x%x OK : %d bytes\n", + device, function, (int)parms.ioctl.out.blob.length); + } + } + } + + return True; +} + +/* + init params using lp_parm_xxx + return number of unclist entries +*/ +static int init_benchrw_params(struct torture_context *tctx, struct params *lpar) +{ + char **unc_list = NULL; + int num_unc_names = 0, conn_index=0, empty_lines=0; + const char *p; + lpar->retry = lp_parm_int(-1, "torture", "retry",3); + lpar->blocksize = lp_parm_int(-1, "torture", "blocksize",65535); + lpar->writeblocks = lp_parm_int(-1, "torture", "writeblocks",15); + lpar->writeratio = lp_parm_int(-1, "torture", "writeratio",5); + lpar->workgroup = lp_workgroup(); + + p = lp_parm_string(-1, "torture", "unclist"); + if (p) { + char *h, *s; + unc_list = file_lines_load(p, &num_unc_names, NULL); + if (!unc_list || num_unc_names <= 0) { + torture_comment(tctx, "Failed to load unc names list from '%s'\n", p); + exit(1); + } + + lpar->unc = talloc_array(tctx, struct unclist *, (num_unc_names-empty_lines)); + for(conn_index = 0; conn_index < num_unc_names; conn_index++) { + /* ignore empty lines */ + if(strlen(unc_list[conn_index % num_unc_names])==0){ + empty_lines++; + continue; + } + if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names], + NULL, &h, &s)) { + torture_comment(tctx, "Failed to parse UNC name %s\n", + unc_list[conn_index % num_unc_names]); + exit(1); + } + lpar->unc[conn_index-empty_lines] = talloc(tctx,struct unclist); + lpar->unc[conn_index-empty_lines]->host = h; + lpar->unc[conn_index-empty_lines]->share = s; + } + return num_unc_names-empty_lines; + }else{ + lpar->unc = talloc_array(tctx, struct unclist *, 1); + lpar->unc[0] = talloc(tctx,struct unclist); + lpar->unc[0]->host = lp_parm_string(-1, "torture", "host"); + lpar->unc[0]->share = lp_parm_string(-1, "torture", "share"); + return 1; + } +} + +/* + Called when the reads & writes are finished. closes the file. +*/ +static NTSTATUS benchrw_close(struct torture_context *tctx,struct smbcli_request *req, + struct benchrw_state *state) +{ + union smb_close close_parms; + + NT_STATUS_NOT_OK_RETURN(req->status); + + torture_comment(tctx, "Close file %d (%d)\n",state->nr,state->fnum); + close_parms.close.level = RAW_CLOSE_CLOSE; + close_parms.close.in.file.fnum = state->fnum ; + close_parms.close.in.write_time = 0; + state->mode=CLOSE_FILE; + + req = smb_raw_close_send(state->cli, &close_parms); + NT_STATUS_HAVE_NO_MEMORY(req); + /*register the callback function!*/ + req->async.fn = benchrw_callback; + req->async.private = state; + + return NT_STATUS_OK; +} + +/* + Called when the initial write is completed is done. write or read a file. +*/ +static NTSTATUS benchrw_readwrite(struct torture_context *tctx,struct smbcli_request *req, + struct benchrw_state *state) +{ + union smb_read rd; + union smb_write wr; + + NT_STATUS_NOT_OK_RETURN(req->status); + + state->completed++; + /*rotate between writes and reads*/ + if( state->completed % state->lp_params->writeratio == 0){ + torture_comment(tctx, "Callback WRITE file:%d (%d/%d)\n", + state->nr,state->completed,torture_numops); + wr.generic.level = RAW_WRITE_WRITEX ; + wr.writex.in.file.fnum = state->fnum ; + wr.writex.in.offset = 0; + wr.writex.in.wmode = 0 ; + wr.writex.in.remaining = 0; + wr.writex.in.count = state->lp_params->blocksize; + wr.writex.in.data = state->buffer; + state->readcnt=0; + req = smb_raw_write_send(state->cli,&wr); + }else{ + torture_comment(tctx, "Callback READ file:%d (%d/%d) Offset:%d\n", + state->nr,state->completed,torture_numops, + (state->readcnt*state->lp_params->blocksize)); + rd.generic.level = RAW_READ_READ ; + rd.read.in.file.fnum = state->fnum ; + rd.read.in.offset = state->readcnt * + state->lp_params->blocksize; + rd.read.in.count = state->lp_params->blocksize; + rd.read.in.remaining = 0 ; + rd.read.out.data = state->buffer; + if(state->readcnt < state->lp_params->writeblocks){ + state->readcnt++; + }else{ + /*start reading from beginn of file*/ + state->readcnt=0; + } + req = smb_raw_read_send(state->cli,&rd); + } + NT_STATUS_HAVE_NO_MEMORY(req); + /*register the callback function!*/ + req->async.fn = benchrw_callback; + req->async.private = state; + + return NT_STATUS_OK; +} + +/* + Called when the open is done. writes to the file. +*/ +static NTSTATUS benchrw_open(struct torture_context *tctx,struct smbcli_request *req, + struct benchrw_state *state) +{ + union smb_write wr; + if(state->mode == OPEN_FILE){ + NTSTATUS status; + status = smb_raw_open_recv(req,state->mem_ctx,( + union smb_open*)state->req_params); + NT_STATUS_NOT_OK_RETURN(status); + + state->fnum = ((union smb_open*)state->req_params) + ->openx.out.file.fnum; + torture_comment(tctx, "File opened (%d)\n",state->fnum); + state->mode=INITIAL_WRITE; + } + + torture_comment(tctx, "Write initial test file:%d (%d/%d)\n",state->nr, + (state->writecnt+1)*state->lp_params->blocksize, + (state->lp_params->writeblocks*state->lp_params->blocksize)); + wr.generic.level = RAW_WRITE_WRITEX ; + wr.writex.in.file.fnum = state->fnum ; + wr.writex.in.offset = state->writecnt * + state->lp_params->blocksize; + wr.writex.in.wmode = 0 ; + wr.writex.in.remaining = (state->lp_params->writeblocks * + state->lp_params->blocksize)- + ((state->writecnt+1)*state-> + lp_params->blocksize); + wr.writex.in.count = state->lp_params->blocksize; + wr.writex.in.data = state->buffer; + state->writecnt++; + if(state->writecnt == state->lp_params->writeblocks){ + state->mode=READ_WRITE_DATA; + } + req = smb_raw_write_send(state->cli,&wr); + NT_STATUS_HAVE_NO_MEMORY(req); + + /*register the callback function!*/ + req->async.fn = benchrw_callback; + req->async.private = state; + return NT_STATUS_OK; +} + +/* + Called when the mkdir is done. Opens a file. +*/ +static NTSTATUS benchrw_mkdir(struct torture_context *tctx,struct smbcli_request *req, + struct benchrw_state *state) +{ + union smb_open *open_parms; + uint8_t *writedata; + + NT_STATUS_NOT_OK_RETURN(req->status); + + /* open/create the files */ + torture_comment(tctx, "Open File %d/%d\n",state->nr+1,torture_nprocs); + open_parms=talloc_zero(state->mem_ctx, union smb_open); + NT_STATUS_HAVE_NO_MEMORY(open_parms); + open_parms->openx.level = RAW_OPEN_OPENX; + open_parms->openx.in.flags = 0; + open_parms->openx.in.open_mode = OPENX_MODE_ACCESS_RDWR; + open_parms->openx.in.search_attrs = + FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN; + open_parms->openx.in.file_attrs = 0; + open_parms->openx.in.write_time = 0; + open_parms->openx.in.open_func = OPENX_OPEN_FUNC_CREATE; + open_parms->openx.in.size = 0; + open_parms->openx.in.timeout = 0; + open_parms->openx.in.fname = state->fname; + + writedata = talloc_size(state->mem_ctx,state->lp_params->blocksize); + NT_STATUS_HAVE_NO_MEMORY(writedata); + generate_random_buffer(writedata,state->lp_params->blocksize); + state->buffer=writedata; + state->writecnt=1; + state->readcnt=0; + state->req_params=open_parms; + state->mode=OPEN_FILE; + + req = smb_raw_open_send(state->cli,open_parms); + NT_STATUS_HAVE_NO_MEMORY(req); + + /*register the callback function!*/ + req->async.fn = benchrw_callback; + req->async.private = state; + + return NT_STATUS_OK; +} + +/* + handler for completion of a sub-request of the bench-rw test +*/ +static void benchrw_callback(struct smbcli_request *req) +{ + struct benchrw_state *state = req->async.private; + struct torture_context *tctx = state->tctx; + + /*dont send new requests when torture_numops is reached*/ + if(state->completed >= torture_numops){ + state->completed=0; + state->mode=MAX_OPS_REACHED; + } + + switch (state->mode) { + + case MK_TESTDIR: + if (!NT_STATUS_IS_OK(benchrw_mkdir(tctx, req,state))) { + torture_comment(tctx, "Failed to create the test directory - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } + break; + case OPEN_FILE: + case INITIAL_WRITE: + if (!NT_STATUS_IS_OK(benchrw_open(tctx, req,state))){ + torture_comment(tctx, "Failed to open/write the file - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } + break; + case READ_WRITE_DATA: + if (!NT_STATUS_IS_OK(benchrw_readwrite(tctx,req,state))){ + torture_comment(tctx, "Failed to read/write the file - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } + break; + case MAX_OPS_REACHED: + if (!NT_STATUS_IS_OK(benchrw_close(tctx,req,state))){ + torture_comment(tctx, "Failed to read/write/close the file - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } + break; + case CLOSE_FILE: + torture_comment(tctx, "File %d closed\n",state->nr); + if (!NT_STATUS_IS_OK(req->status)) { + torture_comment(tctx, "Failed to close the file - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } + state->mode=CLEANUP; + return; + default: + break; + } + +} + +/* open connection async callback function*/ +static void async_open_callback(struct composite_context *con) +{ + struct benchrw_state *state = con->async.private_data; + struct torture_context *tctx = state->tctx; + int retry = state->lp_params->retry; + + if (NT_STATUS_IS_OK(con->status)) { + state->cli=((struct smb_composite_connect*) + state->req_params)->out.tree; + state->mode=CLEANUP_TESTDIR; + }else{ + if(state->writecnt < retry){ + torture_comment(tctx, "Failed to open connection:%d, Retry (%d/%d)\n", + state->nr,state->writecnt,retry); + state->writecnt++; + state->mode=START; + usleep(1000); + }else{ + torture_comment(tctx, "Failed to open connection (%d) - %s\n", + state->nr, nt_errstr(con->status)); + state->mode=ERROR; + } + return; + } +} + +/* + establishs a smbcli_tree from scratch (async) +*/ +static struct composite_context *torture_connect_async( + struct torture_context *tctx, + struct smb_composite_connect *smb, + TALLOC_CTX *mem_ctx, + struct event_context *ev, + const char *host, + const char *share, + const char *workgroup) +{ + torture_comment(tctx, "Open Connection to %s/%s\n",host,share); + smb->in.dest_host=talloc_strdup(mem_ctx,host); + smb->in.service=talloc_strdup(mem_ctx,share); + smb->in.port=0; + smb->in.called_name = strupper_talloc(mem_ctx, host); + smb->in.service_type=NULL; + smb->in.credentials=cmdline_credentials; + smb->in.fallback_to_anonymous=False; + smb->in.workgroup=workgroup; + + return smb_composite_connect_send(smb,mem_ctx,ev); +} + +BOOL run_benchrw(struct torture_context *tctx) +{ + struct smb_composite_connect *smb_con; + const char *fname = "\\rwtest.dat"; + struct smbcli_request *req; + struct benchrw_state **state; + int i , num_unc_names; + struct event_context *ev ; + struct composite_context *req1; + struct params lpparams; + union smb_mkdir parms; + int finished = 0; + BOOL success=True; + + torture_comment(tctx, "Start BENCH-READWRITE num_ops=%d num_nprocs=%d\n", + torture_numops,torture_nprocs); + + /*init talloc context*/ + ev = event_context_init(tctx); + state = talloc_array(tctx, struct benchrw_state *, torture_nprocs); + + /* init params using lp_parm_xxx */ + num_unc_names = init_benchrw_params(tctx,&lpparams); + + /* init private data structs*/ + for(i = 0; itctx = tctx; + state[i]->completed=0; + state[i]->lp_params=&lpparams; + state[i]->nr=i; + state[i]->dname=talloc_asprintf(tctx,"benchrw%d",i); + state[i]->fname=talloc_asprintf(tctx,"%s%s", + state[i]->dname,fname); + state[i]->mode=START; + state[i]->writecnt=0; + } + + torture_comment(tctx, "Starting async requests\n"); + while(finished != torture_nprocs){ + finished=0; + for(i = 0; imode){ + /*open multiple connections with the same userid */ + case START: + smb_con = talloc(tctx,struct smb_composite_connect) ; + state[i]->req_params=smb_con; + state[i]->mode=OPEN_CONNECTION; + req1 = torture_connect_async(tctx, smb_con, + tctx,ev, + lpparams.unc[i % num_unc_names]->host, + lpparams.unc[i % num_unc_names]->share, + lpparams.workgroup); + /* register callback fn + private data */ + req1->async.fn = async_open_callback; + req1->async.private_data=state[i]; + break; + /*setup test dirs (sync)*/ + case CLEANUP_TESTDIR: + torture_comment(tctx, "Setup test dir %d\n",i); + smb_raw_exit(state[i]->cli->session); + if (smbcli_deltree(state[i]->cli, + state[i]->dname) == -1) { + torture_comment(tctx, "Unable to delete %s - %s\n", + state[i]->dname, + smbcli_errstr(state[i]->cli)); + state[i]->mode=ERROR; + break; + } + state[i]->mode=MK_TESTDIR; + parms.mkdir.level = RAW_MKDIR_MKDIR; + parms.mkdir.in.path = state[i]->dname; + req = smb_raw_mkdir_send(state[i]->cli,&parms); + /* register callback fn + private data */ + req->async.fn = benchrw_callback; + req->async.private=state[i]; + break; + /* error occured , finish */ + case ERROR: + finished++; + success=False; + break; + /* cleanup , close connection */ + case CLEANUP: + torture_comment(tctx, "Deleting test dir %s %d/%d\n",state[i]->dname, + i+1,torture_nprocs); + smbcli_deltree(state[i]->cli,state[i]->dname); + if (NT_STATUS_IS_ERR(smb_tree_disconnect( + state[i]->cli))) { + torture_comment(tctx, "ERROR: Tree disconnect failed"); + state[i]->mode=ERROR; + break; + } + state[i]->mode=FINISHED; + case FINISHED: + finished++; + break; + default: + event_loop_once(ev); + } + } + } + + return success; +} + -- cgit From a39f239cb28e4ac6be207d4179bacffce97f1b3e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 18 Oct 2006 14:23:19 +0000 Subject: r19392: Use torture_setting_* rather than lp_parm_* where possible. (This used to be commit b28860978fe29c5b10abfb8c59d7182864e21dd6) --- source4/torture/basic/misc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index c00372b805..0059574939 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -419,13 +419,13 @@ static int init_benchrw_params(struct torture_context *tctx, struct params *lpar char **unc_list = NULL; int num_unc_names = 0, conn_index=0, empty_lines=0; const char *p; - lpar->retry = lp_parm_int(-1, "torture", "retry",3); - lpar->blocksize = lp_parm_int(-1, "torture", "blocksize",65535); - lpar->writeblocks = lp_parm_int(-1, "torture", "writeblocks",15); - lpar->writeratio = lp_parm_int(-1, "torture", "writeratio",5); + lpar->retry = torture_setting_int(tctx, "retry",3); + lpar->blocksize = torture_setting_int(tctx, "blocksize",65535); + lpar->writeblocks = torture_setting_int(tctx, "writeblocks",15); + lpar->writeratio = torture_setting_int(tctx, "writeratio",5); lpar->workgroup = lp_workgroup(); - p = lp_parm_string(-1, "torture", "unclist"); + p = torture_setting_string(tctx, "unclist", NULL); if (p) { char *h, *s; unc_list = file_lines_load(p, &num_unc_names, NULL); @@ -455,8 +455,8 @@ static int init_benchrw_params(struct torture_context *tctx, struct params *lpar }else{ lpar->unc = talloc_array(tctx, struct unclist *, 1); lpar->unc[0] = talloc(tctx,struct unclist); - lpar->unc[0]->host = lp_parm_string(-1, "torture", "host"); - lpar->unc[0]->share = lp_parm_string(-1, "torture", "share"); + lpar->unc[0]->host = torture_setting_string(tctx, "host", NULL); + lpar->unc[0]->share = torture_setting_string(tctx, "share", NULL); return 1; } } -- cgit From 108de297a7b576b624d5471c116ad6c734c63e14 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 30 Oct 2006 00:17:16 +0000 Subject: r19510: Make smbtorture's `nprocs' parameter a parametric option. (This used to be commit f5d6b3ca29788d171d53822a26295ae895a5ed8f) --- source4/torture/basic/misc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 0059574939..e8e7985f93 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -596,7 +596,8 @@ static NTSTATUS benchrw_mkdir(struct torture_context *tctx,struct smbcli_request NT_STATUS_NOT_OK_RETURN(req->status); /* open/create the files */ - torture_comment(tctx, "Open File %d/%d\n",state->nr+1,torture_nprocs); + torture_comment(tctx, "Open File %d/%d\n",state->nr+1, + lp_parm_int(-1, "torture", "nprocs", 4)); open_parms=talloc_zero(state->mem_ctx, union smb_open); NT_STATUS_HAVE_NO_MEMORY(open_parms); open_parms->openx.level = RAW_OPEN_OPENX; @@ -760,9 +761,10 @@ BOOL run_benchrw(struct torture_context *tctx) union smb_mkdir parms; int finished = 0; BOOL success=True; + int torture_nprocs = lp_parm_int(-1, "torture", "nprocs", 4); torture_comment(tctx, "Start BENCH-READWRITE num_ops=%d num_nprocs=%d\n", - torture_numops,torture_nprocs); + torture_numops, torture_nprocs); /*init talloc context*/ ev = event_context_init(tctx); -- cgit From 0cb8a7f058b80701e799593c5a2d1986c6964f18 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 20 Dec 2006 07:46:22 +0000 Subject: r20272: Fix for BASE-BENCH-READWRITE from Mathias Dietz (This used to be commit b053a7df8453527a9c2dfc03f3c35487fe75676f) --- source4/torture/basic/misc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index e8e7985f93..e8f738a975 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -63,7 +63,6 @@ struct benchrw_state{ int writecnt; int readcnt; int completed; - TALLOC_CTX *mem_ctx; void *req_params; enum benchrw_stage mode; struct params{ @@ -547,7 +546,7 @@ static NTSTATUS benchrw_open(struct torture_context *tctx,struct smbcli_request union smb_write wr; if(state->mode == OPEN_FILE){ NTSTATUS status; - status = smb_raw_open_recv(req,state->mem_ctx,( + status = smb_raw_open_recv(req,tctx,( union smb_open*)state->req_params); NT_STATUS_NOT_OK_RETURN(status); @@ -598,7 +597,7 @@ static NTSTATUS benchrw_mkdir(struct torture_context *tctx,struct smbcli_request /* open/create the files */ torture_comment(tctx, "Open File %d/%d\n",state->nr+1, lp_parm_int(-1, "torture", "nprocs", 4)); - open_parms=talloc_zero(state->mem_ctx, union smb_open); + open_parms=talloc_zero(tctx, union smb_open); NT_STATUS_HAVE_NO_MEMORY(open_parms); open_parms->openx.level = RAW_OPEN_OPENX; open_parms->openx.in.flags = 0; @@ -612,7 +611,7 @@ static NTSTATUS benchrw_mkdir(struct torture_context *tctx,struct smbcli_request open_parms->openx.in.timeout = 0; open_parms->openx.in.fname = state->fname; - writedata = talloc_size(state->mem_ctx,state->lp_params->blocksize); + writedata = talloc_size(tctx,state->lp_params->blocksize); NT_STATUS_HAVE_NO_MEMORY(writedata); generate_random_buffer(writedata,state->lp_params->blocksize); state->buffer=writedata; -- cgit From f6558c04fe6221ce07de56104a72a301a5ad95f6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 10 Feb 2007 17:46:33 +0000 Subject: r21270: Fix a memleak (This used to be commit 918031a99c583b45c854c6d066f56ca6887011dd) --- source4/torture/basic/misc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index e8f738a975..3e88e05550 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -495,6 +495,7 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx,struct smbcli_req union smb_write wr; NT_STATUS_NOT_OK_RETURN(req->status); + talloc_free(req); state->completed++; /*rotate between writes and reads*/ -- cgit From 22d39d1bee1c5d606b1d76a64bbcfecb45afae94 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 11 Feb 2007 10:42:48 +0000 Subject: r21275: Reformat the bench-readwrite test a bit (This used to be commit d2d44bf6779c6ac46b011d7e3b372c28c6f8a4f9) --- source4/torture/basic/misc.c | 206 ++++++++++++++++++++++++------------------- 1 file changed, 117 insertions(+), 89 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 3e88e05550..8f6fa66ca4 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -36,47 +36,6 @@ #include "libcli/composite/composite.h" extern struct cli_credentials *cmdline_credentials; -static void benchrw_callback(struct smbcli_request *req); -enum benchrw_stage { - START, - OPEN_CONNECTION, - CLEANUP_TESTDIR, - MK_TESTDIR, - OPEN_FILE, - INITIAL_WRITE, - READ_WRITE_DATA, - MAX_OPS_REACHED, - ERROR, - CLOSE_FILE, - CLEANUP, - FINISHED -}; - -struct benchrw_state{ - struct torture_context *tctx; - char *dname; - char *fname; - uint16_t fnum; - int nr; - struct smbcli_tree *cli; - uint8_t *buffer; - int writecnt; - int readcnt; - int completed; - void *req_params; - enum benchrw_stage mode; - struct params{ - struct unclist{ - const char *host; - const char *share; - } **unc; - const char *workgroup; - int retry; - unsigned int writeblocks; - unsigned int blocksize; - unsigned int writeratio; - } *lp_params; - }; static BOOL wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len) { @@ -409,11 +368,54 @@ BOOL torture_ioctl_test(struct torture_context *tctx, return True; } +static void benchrw_callback(struct smbcli_request *req); +enum benchrw_stage { + START, + OPEN_CONNECTION, + CLEANUP_TESTDIR, + MK_TESTDIR, + OPEN_FILE, + INITIAL_WRITE, + READ_WRITE_DATA, + MAX_OPS_REACHED, + ERROR, + CLOSE_FILE, + CLEANUP, + FINISHED +}; + +struct benchrw_state { + struct torture_context *tctx; + char *dname; + char *fname; + uint16_t fnum; + int nr; + struct smbcli_tree *cli; + uint8_t *buffer; + int writecnt; + int readcnt; + int completed; + void *req_params; + enum benchrw_stage mode; + struct params{ + struct unclist{ + const char *host; + const char *share; + } **unc; + const char *workgroup; + int retry; + unsigned int writeblocks; + unsigned int blocksize; + unsigned int writeratio; + } *lp_params; +}; + /* init params using lp_parm_xxx return number of unclist entries */ -static int init_benchrw_params(struct torture_context *tctx, struct params *lpar) +static int init_benchrw_params(struct torture_context *tctx, + struct params *lpar) { char **unc_list = NULL; int num_unc_names = 0, conn_index=0, empty_lines=0; @@ -429,33 +431,41 @@ static int init_benchrw_params(struct torture_context *tctx, struct params *lpar char *h, *s; unc_list = file_lines_load(p, &num_unc_names, NULL); if (!unc_list || num_unc_names <= 0) { - torture_comment(tctx, "Failed to load unc names list from '%s'\n", p); + torture_comment(tctx, "Failed to load unc names list " + "from '%s'\n", p); exit(1); } - lpar->unc = talloc_array(tctx, struct unclist *, (num_unc_names-empty_lines)); + lpar->unc = talloc_array(tctx, struct unclist *, + (num_unc_names-empty_lines)); for(conn_index = 0; conn_index < num_unc_names; conn_index++) { /* ignore empty lines */ if(strlen(unc_list[conn_index % num_unc_names])==0){ empty_lines++; continue; } - if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names], - NULL, &h, &s)) { - torture_comment(tctx, "Failed to parse UNC name %s\n", - unc_list[conn_index % num_unc_names]); + if (!smbcli_parse_unc( + unc_list[conn_index % num_unc_names], + NULL, &h, &s)) { + torture_comment( + tctx, "Failed to parse UNC " + "name %s\n", + unc_list[conn_index % num_unc_names]); exit(1); } - lpar->unc[conn_index-empty_lines] = talloc(tctx,struct unclist); - lpar->unc[conn_index-empty_lines]->host = h; - lpar->unc[conn_index-empty_lines]->share = s; + lpar->unc[conn_index-empty_lines] = + talloc(tctx, struct unclist); + lpar->unc[conn_index-empty_lines]->host = h; + lpar->unc[conn_index-empty_lines]->share = s; } return num_unc_names-empty_lines; }else{ lpar->unc = talloc_array(tctx, struct unclist *, 1); lpar->unc[0] = talloc(tctx,struct unclist); - lpar->unc[0]->host = torture_setting_string(tctx, "host", NULL); - lpar->unc[0]->share = torture_setting_string(tctx, "share", NULL); + lpar->unc[0]->host = torture_setting_string(tctx, "host", + NULL); + lpar->unc[0]->share = torture_setting_string(tctx, "share", + NULL); return 1; } } @@ -463,8 +473,9 @@ static int init_benchrw_params(struct torture_context *tctx, struct params *lpar /* Called when the reads & writes are finished. closes the file. */ -static NTSTATUS benchrw_close(struct torture_context *tctx,struct smbcli_request *req, - struct benchrw_state *state) +static NTSTATUS benchrw_close(struct torture_context *tctx, + struct smbcli_request *req, + struct benchrw_state *state) { union smb_close close_parms; @@ -488,8 +499,9 @@ static NTSTATUS benchrw_close(struct torture_context *tctx,struct smbcli_request /* Called when the initial write is completed is done. write or read a file. */ -static NTSTATUS benchrw_readwrite(struct torture_context *tctx,struct smbcli_request *req, - struct benchrw_state *state) +static NTSTATUS benchrw_readwrite(struct torture_context *tctx, + struct smbcli_request *req, + struct benchrw_state *state) { union smb_read rd; union smb_write wr; @@ -512,7 +524,8 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx,struct smbcli_req state->readcnt=0; req = smb_raw_write_send(state->cli,&wr); }else{ - torture_comment(tctx, "Callback READ file:%d (%d/%d) Offset:%d\n", + torture_comment(tctx, + "Callback READ file:%d (%d/%d) Offset:%d\n", state->nr,state->completed,torture_numops, (state->readcnt*state->lp_params->blocksize)); rd.generic.level = RAW_READ_READ ; @@ -541,8 +554,9 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx,struct smbcli_req /* Called when the open is done. writes to the file. */ -static NTSTATUS benchrw_open(struct torture_context *tctx,struct smbcli_request *req, - struct benchrw_state *state) +static NTSTATUS benchrw_open(struct torture_context *tctx, + struct smbcli_request *req, + struct benchrw_state *state) { union smb_write wr; if(state->mode == OPEN_FILE){ @@ -587,8 +601,9 @@ static NTSTATUS benchrw_open(struct torture_context *tctx,struct smbcli_request /* Called when the mkdir is done. Opens a file. */ -static NTSTATUS benchrw_mkdir(struct torture_context *tctx,struct smbcli_request *req, - struct benchrw_state *state) +static NTSTATUS benchrw_mkdir(struct torture_context *tctx, + struct smbcli_request *req, + struct benchrw_state *state) { union smb_open *open_parms; uint8_t *writedata; @@ -597,7 +612,7 @@ static NTSTATUS benchrw_mkdir(struct torture_context *tctx,struct smbcli_request /* open/create the files */ torture_comment(tctx, "Open File %d/%d\n",state->nr+1, - lp_parm_int(-1, "torture", "nprocs", 4)); + lp_parm_int(-1, "torture", "nprocs", 4)); open_parms=talloc_zero(tctx, union smb_open); NT_STATUS_HAVE_NO_MEMORY(open_parms); open_parms->openx.level = RAW_OPEN_OPENX; @@ -648,9 +663,10 @@ static void benchrw_callback(struct smbcli_request *req) switch (state->mode) { case MK_TESTDIR: - if (!NT_STATUS_IS_OK(benchrw_mkdir(tctx, req,state))) { - torture_comment(tctx, "Failed to create the test directory - %s\n", - nt_errstr(req->status)); + if (!NT_STATUS_IS_OK(benchrw_mkdir(tctx, req,state))) { + torture_comment(tctx, "Failed to create the test " + "directory - %s\n", + nt_errstr(req->status)); state->mode=ERROR; return; } @@ -658,24 +674,27 @@ static void benchrw_callback(struct smbcli_request *req) case OPEN_FILE: case INITIAL_WRITE: if (!NT_STATUS_IS_OK(benchrw_open(tctx, req,state))){ - torture_comment(tctx, "Failed to open/write the file - %s\n", - nt_errstr(req->status)); + torture_comment(tctx, "Failed to open/write the " + "file - %s\n", + nt_errstr(req->status)); state->mode=ERROR; return; } break; case READ_WRITE_DATA: if (!NT_STATUS_IS_OK(benchrw_readwrite(tctx,req,state))){ - torture_comment(tctx, "Failed to read/write the file - %s\n", - nt_errstr(req->status)); + torture_comment(tctx, "Failed to read/write the " + "file - %s\n", + nt_errstr(req->status)); state->mode=ERROR; return; } break; case MAX_OPS_REACHED: if (!NT_STATUS_IS_OK(benchrw_close(tctx,req,state))){ - torture_comment(tctx, "Failed to read/write/close the file - %s\n", - nt_errstr(req->status)); + torture_comment(tctx, "Failed to read/write/close " + "the file - %s\n", + nt_errstr(req->status)); state->mode=ERROR; return; } @@ -683,8 +702,9 @@ static void benchrw_callback(struct smbcli_request *req) case CLOSE_FILE: torture_comment(tctx, "File %d closed\n",state->nr); if (!NT_STATUS_IS_OK(req->status)) { - torture_comment(tctx, "Failed to close the file - %s\n", - nt_errstr(req->status)); + torture_comment(tctx, "Failed to close the " + "file - %s\n", + nt_errstr(req->status)); state->mode=ERROR; return; } @@ -709,13 +729,15 @@ static void async_open_callback(struct composite_context *con) state->mode=CLEANUP_TESTDIR; }else{ if(state->writecnt < retry){ - torture_comment(tctx, "Failed to open connection:%d, Retry (%d/%d)\n", + torture_comment(tctx, "Failed to open connection: " + "%d, Retry (%d/%d)\n", state->nr,state->writecnt,retry); state->writecnt++; state->mode=START; usleep(1000); }else{ - torture_comment(tctx, "Failed to open connection (%d) - %s\n", + torture_comment(tctx, "Failed to open connection " + "(%d) - %s\n", state->nr, nt_errstr(con->status)); state->mode=ERROR; } @@ -763,8 +785,9 @@ BOOL run_benchrw(struct torture_context *tctx) BOOL success=True; int torture_nprocs = lp_parm_int(-1, "torture", "nprocs", 4); - torture_comment(tctx, "Start BENCH-READWRITE num_ops=%d num_nprocs=%d\n", - torture_numops, torture_nprocs); + torture_comment(tctx, "Start BENCH-READWRITE num_ops=%d " + "num_nprocs=%d\n", + torture_numops, torture_nprocs); /*init talloc context*/ ev = event_context_init(tctx); @@ -782,7 +805,7 @@ BOOL run_benchrw(struct torture_context *tctx) state[i]->nr=i; state[i]->dname=talloc_asprintf(tctx,"benchrw%d",i); state[i]->fname=talloc_asprintf(tctx,"%s%s", - state[i]->dname,fname); + state[i]->dname,fname); state[i]->mode=START; state[i]->writecnt=0; } @@ -794,14 +817,15 @@ BOOL run_benchrw(struct torture_context *tctx) switch (state[i]->mode){ /*open multiple connections with the same userid */ case START: - smb_con = talloc(tctx,struct smb_composite_connect) ; + smb_con = talloc( + tctx,struct smb_composite_connect) ; state[i]->req_params=smb_con; state[i]->mode=OPEN_CONNECTION; - req1 = torture_connect_async(tctx, smb_con, - tctx,ev, - lpparams.unc[i % num_unc_names]->host, - lpparams.unc[i % num_unc_names]->share, - lpparams.workgroup); + req1 = torture_connect_async( + tctx, smb_con, tctx,ev, + lpparams.unc[i % num_unc_names]->host, + lpparams.unc[i % num_unc_names]->share, + lpparams.workgroup); /* register callback fn + private data */ req1->async.fn = async_open_callback; req1->async.private_data=state[i]; @@ -812,7 +836,9 @@ BOOL run_benchrw(struct torture_context *tctx) smb_raw_exit(state[i]->cli->session); if (smbcli_deltree(state[i]->cli, state[i]->dname) == -1) { - torture_comment(tctx, "Unable to delete %s - %s\n", + torture_comment( + tctx, + "Unable to delete %s - %s\n", state[i]->dname, smbcli_errstr(state[i]->cli)); state[i]->mode=ERROR; @@ -833,12 +859,14 @@ BOOL run_benchrw(struct torture_context *tctx) break; /* cleanup , close connection */ case CLEANUP: - torture_comment(tctx, "Deleting test dir %s %d/%d\n",state[i]->dname, + torture_comment(tctx, "Deleting test dir %s " + "%d/%d\n",state[i]->dname, i+1,torture_nprocs); smbcli_deltree(state[i]->cli,state[i]->dname); if (NT_STATUS_IS_ERR(smb_tree_disconnect( - state[i]->cli))) { - torture_comment(tctx, "ERROR: Tree disconnect failed"); + state[i]->cli))) { + torture_comment(tctx, "ERROR: Tree " + "disconnect failed"); state[i]->mode=ERROR; break; } -- cgit From f089de886fa120f5b7619daf0c0d85a0b4100973 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 11 Feb 2007 12:03:25 +0000 Subject: r21276: Actually fire off multiple parallel read/write requests. Volker (This used to be commit 1d7bcdb33ef19be7bf64356b9cb8eee9658afe09) --- source4/torture/basic/misc.c | 74 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 17 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 8f6fa66ca4..13dcf5da93 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -395,6 +395,7 @@ struct benchrw_state { int writecnt; int readcnt; int completed; + int num_parallel_requests; void *req_params; enum benchrw_stage mode; struct params{ @@ -407,6 +408,7 @@ struct benchrw_state { unsigned int writeblocks; unsigned int blocksize; unsigned int writeratio; + int num_parallel_requests; } *lp_params; }; @@ -424,6 +426,8 @@ static int init_benchrw_params(struct torture_context *tctx, lpar->blocksize = torture_setting_int(tctx, "blocksize",65535); lpar->writeblocks = torture_setting_int(tctx, "writeblocks",15); lpar->writeratio = torture_setting_int(tctx, "writeratio",5); + lpar->num_parallel_requests = torture_setting_int( + tctx, "parallel_requests", 5); lpar->workgroup = lp_workgroup(); p = torture_setting_string(tctx, "unclist", NULL); @@ -496,22 +500,50 @@ static NTSTATUS benchrw_close(struct torture_context *tctx, return NT_STATUS_OK; } +static NTSTATUS benchrw_readwrite(struct torture_context *tctx, + struct benchrw_state *state); +static void benchrw_callback(struct smbcli_request *req); + +static void benchrw_rw_callback(struct smbcli_request *req) +{ + struct benchrw_state *state = req->async.private; + struct torture_context *tctx = state->tctx; + + if (!NT_STATUS_IS_OK(req->status)) { + state->mode = ERROR; + return; + } + + state->completed++; + state->num_parallel_requests--; + + if ((state->completed >= torture_numops) + && (state->num_parallel_requests == 0)) { + benchrw_callback(req); + talloc_free(req); + return; + } + + talloc_free(req); + + if (state->completed + state->num_parallel_requests + < torture_numops) { + benchrw_readwrite(tctx, state); + } +} + /* Called when the initial write is completed is done. write or read a file. */ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, - struct smbcli_request *req, struct benchrw_state *state) { + struct smbcli_request *req; union smb_read rd; union smb_write wr; - NT_STATUS_NOT_OK_RETURN(req->status); - talloc_free(req); - - state->completed++; - /*rotate between writes and reads*/ - if( state->completed % state->lp_params->writeratio == 0){ + /* randomize between writes and reads*/ + if ( random() % state->lp_params->writeratio == 0) { torture_comment(tctx, "Callback WRITE file:%d (%d/%d)\n", state->nr,state->completed,torture_numops); wr.generic.level = RAW_WRITE_WRITEX ; @@ -523,7 +555,8 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, wr.writex.in.data = state->buffer; state->readcnt=0; req = smb_raw_write_send(state->cli,&wr); - }else{ + } + else { torture_comment(tctx, "Callback READ file:%d (%d/%d) Offset:%d\n", state->nr,state->completed,torture_numops, @@ -543,9 +576,10 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, } req = smb_raw_read_send(state->cli,&rd); } + state->num_parallel_requests += 1; NT_STATUS_HAVE_NO_MEMORY(req); /*register the callback function!*/ - req->async.fn = benchrw_callback; + req->async.fn = benchrw_rw_callback; req->async.private = state; return NT_STATUS_OK; @@ -655,8 +689,8 @@ static void benchrw_callback(struct smbcli_request *req) struct torture_context *tctx = state->tctx; /*dont send new requests when torture_numops is reached*/ - if(state->completed >= torture_numops){ - state->completed=0; + if ((state->mode == READ_WRITE_DATA) + && (state->completed >= torture_numops)) { state->mode=MAX_OPS_REACHED; } @@ -682,12 +716,17 @@ static void benchrw_callback(struct smbcli_request *req) } break; case READ_WRITE_DATA: - if (!NT_STATUS_IS_OK(benchrw_readwrite(tctx,req,state))){ - torture_comment(tctx, "Failed to read/write the " - "file - %s\n", - nt_errstr(req->status)); - state->mode=ERROR; - return; + while (state->num_parallel_requests + < state->lp_params->num_parallel_requests) { + NTSTATUS status; + status = benchrw_readwrite(tctx,state); + if (!NT_STATUS_IS_OK(status)){ + torture_comment(tctx, "Failed to read/write " + "the file - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } } break; case MAX_OPS_REACHED: @@ -801,6 +840,7 @@ BOOL run_benchrw(struct torture_context *tctx) state[i]=talloc(tctx,struct benchrw_state); state[i]->tctx = tctx; state[i]->completed=0; + state[i]->num_parallel_requests=0; state[i]->lp_params=&lpparams; state[i]->nr=i; state[i]->dname=talloc_asprintf(tctx,"benchrw%d",i); -- cgit From a626e5a274e94caa0d906a07dd25ada928e8a528 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 23 Feb 2007 13:15:56 +0000 Subject: r21519: when we want to send non initialized data, then generate a random buffer explicit to make valgrind happy found by valgrind in the build-farm on fort, there are some more places like this... metze (This used to be commit 2654f595cae046924be33a3f8f758a20565156ee) --- source4/torture/basic/misc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 13dcf5da93..9467d2fc3c 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -66,6 +66,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) return False; } + generate_random_buffer(buf, sizeof(buf)); for (i=0;i Date: Sun, 29 Apr 2007 21:37:29 +0000 Subject: r22579: disable progress printing in the build-farm metze (This used to be commit 93089ad5e8b6e20c4fa92bf13b0137765aeac689) --- source4/torture/basic/misc.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 9467d2fc3c..33f0b9eff6 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -71,7 +71,10 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) for (i=0;i Date: Thu, 17 May 2007 08:47:04 +0000 Subject: r22969: fix some more places where we could end up with more than one event context. We now have an event context on the torture_context, and we can also get one from the cli_credentials structure (This used to be commit c0f65eb6562e13530337c23e3447a6aa6eb8fc17) --- source4/torture/basic/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 33f0b9eff6..933e4334c0 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -843,7 +843,7 @@ BOOL run_benchrw(struct torture_context *tctx) torture_numops, torture_nprocs); /*init talloc context*/ - ev = event_context_init(tctx); + ev = tctx->ev; state = talloc_array(tctx, struct benchrw_state *, torture_nprocs); /* init params using lp_parm_xxx */ -- cgit From 5b2e3e8bd8a4b404f0c6158dfaad5b15e4073940 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Fri, 15 Jun 2007 11:16:19 +0000 Subject: r23505: Use RAW_READ_READX, not RAW_READ_READ in BENCH-READWRITE test (we already write with RAW_WRITE_WRITEX). Noticed by Gomati Mohanan (This used to be commit 5530b38bbf776fec86dd47d3fe73c5e7a6eb188b) --- source4/torture/basic/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 933e4334c0..0523aca961 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -575,7 +575,7 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, "Callback READ file:%d (%d/%d) Offset:%d\n", state->nr,state->completed,torture_numops, (state->readcnt*state->lp_params->blocksize)); - rd.generic.level = RAW_READ_READ ; + rd.generic.level = RAW_READ_READX ; rd.read.in.file.fnum = state->fnum ; rd.read.in.offset = state->readcnt * state->lp_params->blocksize; -- cgit From 7e02cb210158061ebe185c10ba695c498f26764d Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Fri, 15 Jun 2007 12:23:14 +0000 Subject: r23506: Turn back to RAW_READ_READ because buildfarm fails. Investigating. (This used to be commit a580d19cb39e35464d28a8aa15bb9587e3e7d518) --- source4/torture/basic/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 0523aca961..12eec9d551 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -575,7 +575,7 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, "Callback READ file:%d (%d/%d) Offset:%d\n", state->nr,state->completed,torture_numops, (state->readcnt*state->lp_params->blocksize)); - rd.generic.level = RAW_READ_READX ; + rd.generic.level = RAW_READ_READ; rd.read.in.file.fnum = state->fnum ; rd.read.in.offset = state->readcnt * state->lp_params->blocksize; -- cgit From de4f15a3ad0efaa02787839f29496abe9f5d5e80 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Sun, 17 Jun 2007 16:46:44 +0000 Subject: r23529: When using READX, fill in readx fields. Thanks to Metze for spotting it. (This used to be commit 9bb079d70d3fab3ad66143301e8ddfbb5135dedb) --- source4/torture/basic/misc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 12eec9d551..7a2aad0e75 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -575,13 +575,14 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, "Callback READ file:%d (%d/%d) Offset:%d\n", state->nr,state->completed,torture_numops, (state->readcnt*state->lp_params->blocksize)); - rd.generic.level = RAW_READ_READ; - rd.read.in.file.fnum = state->fnum ; - rd.read.in.offset = state->readcnt * + rd.generic.level = RAW_READ_READX; + rd.readx.in.file.fnum = state->fnum ; + rd.readx.in.offset = state->readcnt * state->lp_params->blocksize; - rd.read.in.count = state->lp_params->blocksize; - rd.read.in.remaining = 0 ; - rd.read.out.data = state->buffer; + rd.readx.in.mincnt = state->lp_params->blocksize; + rd.readx.in.maxcnt = rd.readx.in.mincnt; + rd.readx.in.remaining = 0 ; + rd.readx.out.data = state->buffer; if(state->readcnt < state->lp_params->writeblocks){ state->readcnt++; }else{ -- cgit From 9ed016b692f8fc4f35362dffd25e00e8f72d9c24 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Mon, 18 Jun 2007 14:06:04 +0000 Subject: r23540: Continue fixing bench-readwrite. We need to initialize state->readcnt not only when file is written but at initial write as well. (This used to be commit 0258f9d3c21d1f9ce6bfcf31138d7f8b9bfb6b7d) --- source4/torture/basic/misc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 7a2aad0e75..e611ddcc32 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -577,12 +577,12 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, (state->readcnt*state->lp_params->blocksize)); rd.generic.level = RAW_READ_READX; rd.readx.in.file.fnum = state->fnum ; - rd.readx.in.offset = state->readcnt * - state->lp_params->blocksize; + rd.readx.in.offset = state->readcnt*state->lp_params->blocksize; rd.readx.in.mincnt = state->lp_params->blocksize; rd.readx.in.maxcnt = rd.readx.in.mincnt; rd.readx.in.remaining = 0 ; rd.readx.out.data = state->buffer; + rd.readx.in.read_for_execute = False; if(state->readcnt < state->lp_params->writeblocks){ state->readcnt++; }else{ @@ -727,6 +727,7 @@ static void benchrw_callback(struct smbcli_request *req) "file - %s\n", nt_errstr(req->status)); state->mode=ERROR; + state->readcnt=0; return; } break; -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/torture/basic/misc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index e611ddcc32..a98d34e3a8 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -6,7 +6,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From d981c69a18599ce7848afc3e77ad8ab14e6efbe8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 26 Aug 2007 18:24:12 +0000 Subject: r24670: Use torture functions for settings. (This used to be commit a6906676309f3b1bec1a69427e7ffd0a768061b8) --- source4/torture/basic/misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index a98d34e3a8..b4584fcf58 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -660,7 +660,7 @@ static NTSTATUS benchrw_mkdir(struct torture_context *tctx, /* open/create the files */ torture_comment(tctx, "Open File %d/%d\n",state->nr+1, - lp_parm_int(-1, "torture", "nprocs", 4)); + torture_setting_int(tctx, "nprocs", 4)); open_parms=talloc_zero(tctx, union smb_open); NT_STATUS_HAVE_NO_MEMORY(open_parms); open_parms->openx.level = RAW_OPEN_OPENX; @@ -837,7 +837,7 @@ BOOL run_benchrw(struct torture_context *tctx) union smb_mkdir parms; int finished = 0; BOOL success=True; - int torture_nprocs = lp_parm_int(-1, "torture", "nprocs", 4); + int torture_nprocs = torture_setting_int(tctx, "nprocs", 4); torture_comment(tctx, "Start BENCH-READWRITE num_ops=%d " "num_nprocs=%d\n", -- cgit From 2fefa818a95138fc7d6508093f426cb4ed92138f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 28 Aug 2007 00:16:58 +0000 Subject: r24728: Use more stock torture functions. (This used to be commit da3a7ee407a2b41bd01f45072cad12bf29250b33) --- source4/torture/basic/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index b4584fcf58..d72e3ca1cd 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -556,7 +556,7 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, union smb_write wr; /* randomize between writes and reads*/ - if ( random() % state->lp_params->writeratio == 0) { + if (random() % state->lp_params->writeratio == 0) { torture_comment(tctx, "Callback WRITE file:%d (%d/%d)\n", state->nr,state->completed,torture_numops); wr.generic.level = RAW_WRITE_WRITEX ; -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/torture/basic/misc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index d72e3ca1cd..d493aa819e 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -33,6 +33,7 @@ #include "torture/util.h" #include "libcli/smb_composite/smb_composite.h" #include "libcli/composite/composite.h" +#include "param/param.h" extern struct cli_credentials *cmdline_credentials; -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/torture/basic/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index d493aa819e..19eef87f6f 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -442,7 +442,7 @@ static int init_benchrw_params(struct torture_context *tctx, lpar->writeratio = torture_setting_int(tctx, "writeratio",5); lpar->num_parallel_requests = torture_setting_int( tctx, "parallel_requests", 5); - lpar->workgroup = lp_workgroup(); + lpar->workgroup = lp_workgroup(global_loadparm); p = torture_setting_string(tctx, "unclist", NULL); if (p) { -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/torture/basic/misc.c | 78 ++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 19eef87f6f..f0d5ef5536 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -37,16 +37,16 @@ extern struct cli_credentials *cmdline_credentials; -static BOOL wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len) +static bool wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len) { while (NT_STATUS_IS_ERR(smbcli_lock(c->tree, fnum, offset, len, -1, WRITE_LOCK))) { - if (!check_error(__location__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False; + if (!check_error(__location__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return false; } - return True; + return true; } -static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) +static bool rw_torture(struct torture_context *tctx, struct smbcli_state *c) { const char *lockfname = "\\torture.lck"; char *fname; @@ -55,7 +55,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) pid_t pid2, pid = getpid(); int i, j; uint8_t buf[1024]; - BOOL correct = True; + bool correct = true; fnum2 = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE); @@ -63,7 +63,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) fnum2 = smbcli_open(c->tree, lockfname, O_RDWR, DENY_NONE); if (fnum2 == -1) { torture_comment(tctx, "open of %s failed (%s)\n", lockfname, smbcli_errstr(c->tree)); - return False; + return false; } generate_random_buffer(buf, sizeof(buf)); @@ -79,19 +79,19 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) asprintf(&fname, "\\torture.%u", n); if (!wait_lock(c, fnum2, n*sizeof(int), sizeof(int))) { - return False; + return false; } fnum = smbcli_open(c->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL); if (fnum == -1) { torture_comment(tctx, "open failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; break; } if (smbcli_write(c->tree, fnum, 0, &pid, 0, sizeof(pid)) != sizeof(pid)) { torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } for (j=0;j<50;j++) { @@ -99,7 +99,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) sizeof(pid)+(j*sizeof(buf)), sizeof(buf)) != sizeof(buf)) { torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } } @@ -107,27 +107,27 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) if (smbcli_read(c->tree, fnum, &pid2, 0, sizeof(pid)) != sizeof(pid)) { torture_comment(tctx, "read failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } if (pid2 != pid) { torture_comment(tctx, "data corruption!\n"); - correct = False; + correct = false; } if (NT_STATUS_IS_ERR(smbcli_close(c->tree, fnum))) { torture_comment(tctx, "close failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } if (NT_STATUS_IS_ERR(smbcli_unlink(c->tree, fname))) { torture_comment(tctx, "unlink failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } if (NT_STATUS_IS_ERR(smbcli_unlock(c->tree, fnum2, n*sizeof(int), sizeof(int)))) { torture_comment(tctx, "unlock failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } free(fname); } @@ -140,7 +140,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) return correct; } -BOOL run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dummy) +bool run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dummy) { return rw_torture(tctx, cli); } @@ -149,7 +149,7 @@ BOOL run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dum /* see how many RPC pipes we can open at once */ -BOOL run_pipe_number(struct torture_context *tctx, +bool run_pipe_number(struct torture_context *tctx, struct smbcli_state *cli1) { const char *pipe_name = "\\WKSSVC"; @@ -172,7 +172,7 @@ BOOL run_pipe_number(struct torture_context *tctx, } torture_comment(tctx, "pipe_number test - we can open %d %s pipes.\n", num_pipes, pipe_name ); - return True; + return true; } @@ -183,7 +183,7 @@ BOOL run_pipe_number(struct torture_context *tctx, used for testing performance when there are N idle users already connected */ -BOOL torture_holdcon(struct torture_context *tctx) +bool torture_holdcon(struct torture_context *tctx) { int i; struct smbcli_state **cli; @@ -195,7 +195,7 @@ BOOL torture_holdcon(struct torture_context *tctx) for (i=0;itree, "\\maxfid") == -1) { torture_comment(tctx, "Failed to deltree \\maxfid - %s\n", smbcli_errstr(cli->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\maxfid"))) { torture_comment(tctx, "Failed to mkdir \\maxfid, error=%s\n", smbcli_errstr(cli->tree)); - return False; + return false; } torture_comment(tctx, "Testing maximum number of open files\n"); @@ -266,7 +266,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) { torture_comment(tctx, "Failed to mkdir %s, error=%s\n", fname, smbcli_errstr(cli->tree)); - return False; + return false; } free(fname); } @@ -299,7 +299,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { torture_comment(tctx, "unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - correct = False; + correct = false; } free(fname); @@ -310,7 +310,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { torture_comment(tctx, "unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - correct = False; + correct = false; } free(fname); @@ -324,12 +324,12 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int if (smbcli_deltree(cli->tree, "\\maxfid") == -1) { torture_comment(tctx, "Failed to deltree \\maxfid - %s\n", smbcli_errstr(cli->tree)); - return False; + return false; } torture_comment(tctx, "maxfid test finished\n"); if (!torture_close_connection(cli)) { - correct = False; + correct = false; } return correct; #undef MAXFID_TEMPLATE @@ -340,7 +340,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int /* sees what IOCTLs are supported */ -BOOL torture_ioctl_test(struct torture_context *tctx, +bool torture_ioctl_test(struct torture_context *tctx, struct smbcli_state *cli) { uint16_t device, function; @@ -357,7 +357,7 @@ BOOL torture_ioctl_test(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - return False; + return false; } parms.ioctl.level = RAW_IOCTL_IOCTL; @@ -379,7 +379,7 @@ BOOL torture_ioctl_test(struct torture_context *tctx, } } - return True; + return true; } static void benchrw_callback(struct smbcli_request *req); @@ -582,7 +582,7 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, rd.readx.in.maxcnt = rd.readx.in.mincnt; rd.readx.in.remaining = 0 ; rd.readx.out.data = state->buffer; - rd.readx.in.read_for_execute = False; + rd.readx.in.read_for_execute = false; if(state->readcnt < state->lp_params->writeblocks){ state->readcnt++; }else{ @@ -819,13 +819,13 @@ static struct composite_context *torture_connect_async( smb->in.called_name = strupper_talloc(mem_ctx, host); smb->in.service_type=NULL; smb->in.credentials=cmdline_credentials; - smb->in.fallback_to_anonymous=False; + smb->in.fallback_to_anonymous=false; smb->in.workgroup=workgroup; return smb_composite_connect_send(smb,mem_ctx,ev); } -BOOL run_benchrw(struct torture_context *tctx) +bool run_benchrw(struct torture_context *tctx) { struct smb_composite_connect *smb_con; const char *fname = "\\rwtest.dat"; @@ -837,7 +837,7 @@ BOOL run_benchrw(struct torture_context *tctx) struct params lpparams; union smb_mkdir parms; int finished = 0; - BOOL success=True; + bool success=true; int torture_nprocs = torture_setting_int(tctx, "nprocs", 4); torture_comment(tctx, "Start BENCH-READWRITE num_ops=%d " @@ -911,7 +911,7 @@ BOOL run_benchrw(struct torture_context *tctx) /* error occured , finish */ case ERROR: finished++; - success=False; + success=false; break; /* cleanup , close connection */ case CLEANUP: -- cgit From bbdfbf8d9d486aee51117976b8f825759a4c4a37 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 00:28:22 +0100 Subject: r26238: Add a loadparm context parameter to torture_context, remove more uses of global_loadparm. (This used to be commit a33a5530545086b81a3b205aa109dff11c546926) --- source4/torture/basic/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index f0d5ef5536..46f74ee1b1 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -442,7 +442,7 @@ static int init_benchrw_params(struct torture_context *tctx, lpar->writeratio = torture_setting_int(tctx, "writeratio",5); lpar->num_parallel_requests = torture_setting_int( tctx, "parallel_requests", 5); - lpar->workgroup = lp_workgroup(global_loadparm); + lpar->workgroup = lp_workgroup(tctx->lp_ctx); p = torture_setting_string(tctx, "unclist", NULL); if (p) { -- cgit From 0a2f1a46a02d2c9497d05d7e534829dc6e9430dc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 15:53:07 +0100 Subject: r26249: Remove a couple more uses of global_loadparm. (This used to be commit 80a61200508a00d5b16a3e748ce92d54b9fefcd2) --- source4/torture/basic/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 46f74ee1b1..e9a41e8299 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -194,7 +194,7 @@ bool torture_holdcon(struct torture_context *tctx) cli = malloc_array_p(struct smbcli_state *, torture_numops); for (i=0;i Date: Wed, 12 Dec 2007 02:15:29 +0100 Subject: r26409: Pass smb ports along. (This used to be commit 2833f320de1f1fd39c710ad0a61c3fa1bb1df31f) --- source4/torture/basic/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index e9a41e8299..0832556b53 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -815,7 +815,7 @@ static struct composite_context *torture_connect_async( torture_comment(tctx, "Open Connection to %s/%s\n",host,share); smb->in.dest_host=talloc_strdup(mem_ctx,host); smb->in.service=talloc_strdup(mem_ctx,share); - smb->in.port=0; + smb->in.dest_ports=lp_smb_ports(tctx->lp_ctx); smb->in.called_name = strupper_talloc(mem_ctx, host); smb->in.service_type=NULL; smb->in.credentials=cmdline_credentials; -- cgit From 771b347f9b185895390445be96081c781e28a26d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Jan 2008 18:39:01 -0600 Subject: r26644: Janitorial: Pass resolve_context explicitly to various SMB functions, should help fix the build for OpenChange. (This used to be commit 385ffe4f4cc9a21a760c0f00410f56e2592fd507) --- source4/torture/basic/misc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 0832556b53..ccff18bfc4 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -822,7 +822,8 @@ static struct composite_context *torture_connect_async( smb->in.fallback_to_anonymous=false; smb->in.workgroup=workgroup; - return smb_composite_connect_send(smb,mem_ctx,ev); + return smb_composite_connect_send(smb,mem_ctx, + lp_resolve_context(tctx->lp_ctx),ev); } bool run_benchrw(struct torture_context *tctx) -- cgit From 969b8579c755441092e27b499ecedbd7d725816d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Jan 2008 18:39:15 -0600 Subject: r26646: libcli/smb_composite: Allow specifying SMB parameters in smb_composite_connect structure. AFAIK no global variables will now be used when doing RPC client connections. (This used to be commit 0ef75e4e3cb0e1bd10e367a00f5e9b725587c40a) --- source4/torture/basic/misc.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index ccff18bfc4..f4cb47e7ba 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -821,6 +821,12 @@ static struct composite_context *torture_connect_async( smb->in.credentials=cmdline_credentials; smb->in.fallback_to_anonymous=false; smb->in.workgroup=workgroup; + smb->in.max_xmit = lp_max_xmit(tctx->lp_ctx); + smb->in.max_mux = lp_maxmux(tctx->lp_ctx); + smb->in.ntstatus_support = lp_nt_status_support(tctx->lp_ctx); + smb->in.max_protocol = lp_cli_maxprotocol(tctx->lp_ctx); + smb->in.unicode = lp_unicode(tctx->lp_ctx); + smb->in.use_spnego = lp_use_spnego(tctx->lp_ctx) && lp_nt_status_support(tctx->lp_ctx); return smb_composite_connect_send(smb,mem_ctx, lp_resolve_context(tctx->lp_ctx),ev); -- cgit From 425732f688865ebe2bfe568c8278edec50cbdedf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 3 Jan 2008 17:21:58 -0600 Subject: r26651: libsmb: Allow specifying signing policy from higher up. The number of arguments is getting a bit excessive now, so it probably makes sense to pass in the smbcli_options struct rather than all members individually and add a convenience function for obtaining a smbcli_options struct from a loadparm context. (This used to be commit 9f64213463b5bf3bcbf36913139e9a5042e967a2) --- source4/torture/basic/misc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index f4cb47e7ba..986a4574a9 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -827,6 +827,7 @@ static struct composite_context *torture_connect_async( smb->in.max_protocol = lp_cli_maxprotocol(tctx->lp_ctx); smb->in.unicode = lp_unicode(tctx->lp_ctx); smb->in.use_spnego = lp_use_spnego(tctx->lp_ctx) && lp_nt_status_support(tctx->lp_ctx); + smb->in.signing = lp_client_signing(tctx->lp_ctx); return smb_composite_connect_send(smb,mem_ctx, lp_resolve_context(tctx->lp_ctx),ev); -- cgit From dcc282590b34537fc1ead61c3300172528273b44 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 3 Jan 2008 17:22:12 -0600 Subject: r26654: libcli/smb_composite: Rather than specifying each of the gazillion options for SMB individually, just specify the smbcli_options struct. (This used to be commit 8a97886e24a4b969aa91409c06f423b71a45f6eb) --- source4/torture/basic/misc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 986a4574a9..d991f117cd 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -821,13 +821,7 @@ static struct composite_context *torture_connect_async( smb->in.credentials=cmdline_credentials; smb->in.fallback_to_anonymous=false; smb->in.workgroup=workgroup; - smb->in.max_xmit = lp_max_xmit(tctx->lp_ctx); - smb->in.max_mux = lp_maxmux(tctx->lp_ctx); - smb->in.ntstatus_support = lp_nt_status_support(tctx->lp_ctx); - smb->in.max_protocol = lp_cli_maxprotocol(tctx->lp_ctx); - smb->in.unicode = lp_unicode(tctx->lp_ctx); - smb->in.use_spnego = lp_use_spnego(tctx->lp_ctx) && lp_nt_status_support(tctx->lp_ctx); - smb->in.signing = lp_client_signing(tctx->lp_ctx); + lp_smbcli_options(tctx->lp_ctx, &smb->in.options); return smb_composite_connect_send(smb,mem_ctx, lp_resolve_context(tctx->lp_ctx),ev); -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/torture/basic/misc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index d991f117cd..188fc1bc69 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -20,6 +20,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" #include "system/time.h" #include "system/wait.h" #include "system/filesys.h" -- cgit From 1e973565b6c0cb738b25a2d9439d5acb441701f4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 27 Apr 2008 14:02:46 +0100 Subject: Move subunit infrastructure code into lib/torture. (This used to be commit 5b44d8121de7735d69e6238a1442aff034a8ebd3) --- source4/torture/basic/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/basic/misc.c') diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 188fc1bc69..24e0324bc3 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -30,7 +30,7 @@ #include "libcli/resolve/resolve.h" #include "auth/credentials/credentials.h" #include "librpc/gen_ndr/ndr_nbt.h" -#include "torture/torture.h" +#include "torture/smbtorture.h" #include "torture/util.h" #include "libcli/smb_composite/smb_composite.h" #include "libcli/composite/composite.h" -- cgit