summaryrefslogtreecommitdiff
path: root/source3/torture
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-02-05 01:31:47 +0000
committerAndrew Tridgell <tridge@samba.org>2002-02-05 01:31:47 +0000
commit38fa35571ec9c86dfcd22ed603f9249c071771d8 (patch)
treef1991315945271f3214dbf8b9b712f73a7753443 /source3/torture
parent4ddd288f9a8abc63abe133dd41ad30bcb01ad64e (diff)
downloadsamba-38fa35571ec9c86dfcd22ed603f9249c071771d8.tar.gz
samba-38fa35571ec9c86dfcd22ed603f9249c071771d8.tar.bz2
samba-38fa35571ec9c86dfcd22ed603f9249c071771d8.zip
rewrote smbtorture to use the new dbench 2 format and methods
(This used to be commit 36f816a5e12a80f0184f43cbd44ef5fac53fcb81)
Diffstat (limited to 'source3/torture')
-rw-r--r--source3/torture/nbio.c271
-rw-r--r--source3/torture/torture.c144
2 files changed, 228 insertions, 187 deletions
diff --git a/source3/torture/nbio.c b/source3/torture/nbio.c
index 678f3ab556..0785c4e196 100644
--- a/source3/torture/nbio.c
+++ b/source3/torture/nbio.c
@@ -28,12 +28,68 @@
static char buf[70000];
extern int line_count;
+extern int nbio_id;
+static int nprocs;
static struct {
int fd;
int handle;
} ftable[MAX_FILES];
+static struct {
+ double bytes_in, bytes_out;
+ int line;
+} *children;
+
+double nbio_total(void)
+{
+ int i;
+ double total = 0;
+ for (i=0;i<nprocs;i++) {
+ total += children[i].bytes_out + children[i].bytes_in;
+ }
+ return total;
+}
+
+void nb_alarm(void)
+{
+ int i;
+ int lines=0;
+ if (nbio_id != -1) return;
+
+ for (i=0;i<nprocs;i++) {
+ lines += children[i].line;
+ }
+
+ printf("%8d %.2f MB/sec\r", lines/nprocs, 1.0e-6 * nbio_total() / end_timer());
+
+ signal(SIGALRM, nb_alarm);
+ alarm(1);
+}
+
+void nbio_shmem(int n)
+{
+ nprocs = n;
+ children = shm_setup(sizeof(*children) * nprocs);
+ if (!children) {
+ printf("Failed to setup shared memory!\n");
+ exit(1);
+ }
+}
+
+static int find_handle(int handle)
+{
+ int i;
+ children[nbio_id].line = line_count;
+ for (i=0;i<MAX_FILES;i++) {
+ if (ftable[i].handle == handle) return i;
+ }
+ printf("ERROR: handle %d was not found\n",
+ line_count, handle);
+ exit(1);
+}
+
+
static struct cli_state *c;
static void sigsegv(int sig)
@@ -50,13 +106,12 @@ void nb_setup(struct cli_state *cli)
{
signal(SIGSEGV, sigsegv);
c = cli;
+ start_timer();
}
void nb_unlink(char *fname)
{
- strupper(fname);
-
if (!cli_unlink(c, fname)) {
#if NBDEBUG
printf("(%d) unlink %s failed (%s)\n",
@@ -65,175 +120,167 @@ void nb_unlink(char *fname)
}
}
-void nb_open(char *fname, int handle, int size)
+
+void nb_createx(char *fname,
+ unsigned create_options, unsigned create_disposition, int handle)
{
int fd, i;
- int flags = O_RDWR|O_CREAT;
- size_t st_size;
static int count;
- strupper(fname);
-
- if (size == 0) flags |= O_TRUNC;
-
- fd = cli_open(c, fname, flags, DENY_NONE);
- if (fd == -1) {
-#if NBDEBUG
- printf("(%d) open %s failed for handle %d (%s)\n",
- line_count, fname, handle, cli_errstr(c));
-#endif
- return;
+ fd = cli_nt_create_full(c, fname,
+ FILE_READ_DATA | FILE_WRITE_DATA,
+ 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ create_disposition,
+ create_options);
+ if (fd == -1 && handle != -1) {
+ printf("ERROR: cli_nt_create_full failed for %s - %s\n",
+ fname, cli_errstr(c));
+ exit(1);
}
- cli_getattrE(c, fd, NULL, &st_size, NULL, NULL, NULL);
- if (size > st_size) {
-#if NBDEBUG
- printf("(%d) needs expanding %s to %d from %d\n",
- line_count, fname, size, (int)st_size);
-#endif
- } else if (size < st_size) {
-#if NBDEBUG
- printf("(%d) needs truncating %s to %d from %d\n",
- line_count, fname, size, (int)st_size);
-#endif
+ if (fd != -1 && handle == -1) {
+ printf("ERROR: cli_nt_create_full succeeded for %s\n", fname);
+ exit(1);
}
+ if (fd == -1) return;
+
for (i=0;i<MAX_FILES;i++) {
if (ftable[i].handle == 0) break;
}
if (i == MAX_FILES) {
- printf("file table full for %s\n", fname);
+ printf("(%d) file table full for %s\n", line_count,
+ fname);
exit(1);
}
ftable[i].handle = handle;
ftable[i].fd = fd;
- if (count++ % 100 == 0) {
- printf(".");
- }
}
-void nb_write(int handle, int size, int offset)
+void nb_writex(int handle, int offset, int size, int ret_size)
{
int i;
if (buf[0] == 0) memset(buf, 1, sizeof(buf));
- for (i=0;i<MAX_FILES;i++) {
- if (ftable[i].handle == handle) break;
- }
- if (i == MAX_FILES) {
-#if NBDEBUG
- printf("(%d) nb_write: handle %d was not open size=%d ofs=%d\n",
- line_count, handle, size, offset);
-#endif
- return;
- }
- if (cli_smbwrite(c, ftable[i].fd, buf, offset, size) != size) {
- printf("(%d) write failed on handle %d, fd %d \
+ i = find_handle(handle);
+ if (cli_write(c, ftable[i].fd, 0, buf, offset, size) != ret_size) {
+ printf("(%d) ERROR: write failed on handle %d, fd %d \
errno %d (%s)\n", line_count, handle, ftable[i].fd, errno, strerror(errno));
- if (errno == ENOSPC) {
- printf("Halting.\n");
- fflush(stdout);
- fflush(stderr);
- exit(3);
- }
+ exit(1);
}
+
+ children[nbio_id].bytes_out += ret_size;
}
-void nb_read(int handle, int size, int offset)
+void nb_readx(int handle, int offset, int size, int ret_size)
{
int i, ret;
- for (i=0;i<MAX_FILES;i++) {
- if (ftable[i].handle == handle) break;
- }
- if (i == MAX_FILES) {
- printf("(%d) nb_read: handle %d was not open size=%d ofs=%d\n",
- line_count, handle, size, offset);
- return;
- }
- if ((ret=cli_read(c, ftable[i].fd, buf, offset, size)) != size) {
-#if NBDEBUG
- printf("(%d) read failed on handle %d ofs=%d size=%d res=%d fd %d errno %d (%s)\n",
+ i = find_handle(handle);
+ if ((ret=cli_read(c, ftable[i].fd, buf, offset, size)) != ret_size) {
+ printf("(%d) ERROR: read failed on handle %d ofs=%d size=%d res=%d fd %d errno %d (%s)\n",
line_count, handle, offset, size, ret, ftable[i].fd, errno, strerror(errno));
-#endif
+ exit(1);
}
+ children[nbio_id].bytes_in += ret_size;
}
void nb_close(int handle)
{
int i;
- for (i=0;i<MAX_FILES;i++) {
- if (ftable[i].handle == handle) break;
- }
- if (i == MAX_FILES) {
- printf("(%d) nb_close: handle %d was not open\n",
- line_count, handle);
- return;
+ i = find_handle(handle);
+ if (!cli_close(c, ftable[i].fd)) {
+ printf("(%d) close failed on handle %d\n", line_count, handle);
+ exit(1);
}
- cli_close(c, ftable[i].fd);
ftable[i].handle = 0;
}
-void nb_mkdir(char *fname)
-{
- strupper(fname);
-
- if (!cli_mkdir(c, fname)) {
-#if NBDEBUG
- printf("mkdir %s failed (%s)\n",
- fname, cli_errstr(c));
-#endif
- }
-}
-
void nb_rmdir(char *fname)
{
- strupper(fname);
-
if (!cli_rmdir(c, fname)) {
-#if NBDEBUG
- printf("rmdir %s failed (%s)\n",
+ printf("ERROR: rmdir %s failed (%s)\n",
fname, cli_errstr(c));
-#endif
+ exit(1);
}
}
void nb_rename(char *old, char *new)
{
- strupper(old);
- strupper(new);
-
if (!cli_rename(c, old, new)) {
-#if NBDEBUG
- printf("rename %s %s failed (%s)\n",
+ printf("ERROR: rename %s %s failed (%s)\n",
old, new, cli_errstr(c));
-#endif
+ exit(1);
}
}
-void nb_stat(char *fname, int size)
+void nb_qpathinfo(char *fname)
+{
+ cli_qpathinfo(c, fname, NULL, NULL, NULL, NULL, NULL);
+}
+
+void nb_qfileinfo(int fnum)
+{
+ int i;
+ i = find_handle(fnum);
+ cli_qfileinfo(c, ftable[i].fd, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+}
+
+void nb_qfsinfo(int level)
{
- size_t st_size;
+ int bsize, total, avail;
+ /* this is not the right call - we need cli_qfsinfo() */
+ cli_dskattr(c, &bsize, &total, &avail);
+}
- strupper(fname);
+static void find_fn(file_info *finfo, const char *name, void *state)
+{
+ /* noop */
+}
- if (!cli_getatr(c, fname, NULL, &st_size, NULL)) {
-#if NBDEBUG
- printf("(%d) nb_stat: %s size=%d %s\n",
- line_count, fname, size, cli_errstr(c));
-#endif
- return;
- }
- if (st_size != size) {
-#if NBDEBUG
- printf("(%d) nb_stat: %s wrong size %d %d\n",
- line_count, fname, (int)st_size, size);
-#endif
+void nb_findfirst(char *mask)
+{
+ cli_list(c, mask, 0, find_fn, NULL);
+}
+
+void nb_flush(int fnum)
+{
+ int i;
+ i = find_handle(fnum);
+ /* hmmm, we don't have cli_flush() yet */
+}
+
+static int total_deleted;
+
+static void delete_fn(file_info *finfo, const char *name, void *state)
+{
+ char *s, *n;
+ if (finfo->name[0] == '.') return;
+
+ n = strdup(name);
+ n[strlen(n)-1] = 0;
+ asprintf(&s, "%s%s", n, finfo->name);
+ if (finfo->mode & aDIR) {
+ nb_deltree(s);
+ } else {
+ total_deleted++;
+ nb_unlink(s);
}
+ free(s);
+ free(n);
}
-void nb_create(char *fname, int size)
+void nb_deltree(char *dname)
{
- nb_open(fname, 5000, size);
- nb_close(5000);
+ char *mask;
+ asprintf(&mask, "%s\\*", dname);
+
+ total_deleted = 0;
+
+ cli_list(c, mask, aDIR, delete_fn, NULL);
+ free(mask);
+ nb_rmdir(dname);
+
+ if (total_deleted) printf("WARNING: Cleaned up %d files\n", total_deleted);
}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 6ef67224db..7233e2799b 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -31,6 +31,8 @@ static struct cli_state current_cli;
static fstring randomfname;
static BOOL use_oplocks;
static BOOL use_level_II_oplocks;
+static char *client_txt = "client_oplocks.txt";
+
BOOL torture_showall = False;
static double create_procs(BOOL (*fn)(int), BOOL *result);
@@ -38,12 +40,12 @@ static double create_procs(BOOL (*fn)(int), BOOL *result);
static struct timeval tp1,tp2;
-static void start_timer(void)
+void start_timer(void)
{
gettimeofday(&tp1,NULL);
}
-static double end_timer(void)
+double end_timer(void)
{
gettimeofday(&tp2,NULL);
return((tp2.tv_sec - tp1.tv_sec) +
@@ -60,7 +62,7 @@ static double end_timer(void)
This function uses system5 shared memory. It takes advantage of a property
that the memory is not destroyed if it is attached when the id is removed
*/
-static void *shm_setup(int size)
+void *shm_setup(int size)
{
int shmid;
void *ret;
@@ -615,6 +617,9 @@ static BOOL run_readwritelarge(int dummy)
}
int line_count = 0;
+int nbio_id;
+
+#define ival(s) strtol(s, NULL, 0)
/* run a test that simulates an approximate netbench client load */
static BOOL run_netbench(int client)
@@ -630,16 +635,18 @@ static BOOL run_netbench(int client)
cli = current_cli;
+ nbio_id = client;
+
cli_sockopt(&cli, sockops);
nb_setup(&cli);
- slprintf(cname,sizeof(fname), "CLIENT%d", client);
+ slprintf(cname,sizeof(fname), "client%d", client);
- f = fopen("client.txt", "r");
+ f = fopen(client_txt, "r");
if (!f) {
- perror("client.txt");
+ perror(client_txt);
return False;
}
@@ -650,10 +657,8 @@ static BOOL run_netbench(int client)
/* printf("[%d] %s\n", line_count, line); */
- all_string_sub(line,"CLIENT1", cname, sizeof(line));
+ all_string_sub(line,"client1", cname, sizeof(line));
- for (i=0;i<20;i++) params[i] = "";
-
/* parse the command parameters */
params[0] = strtok(line," ");
i = 0;
@@ -663,56 +668,50 @@ static BOOL run_netbench(int client)
if (i < 2) continue;
- if (strcmp(params[1],"REQUEST") == 0) {
- if (!strcmp(params[0],"SMBopenX")) {
- fstrcpy(fname, params[5]);
- } else if (!strcmp(params[0],"SMBclose")) {
- nb_close(atoi(params[3]));
- } else if (!strcmp(params[0],"SMBmkdir")) {
- nb_mkdir(params[3]);
- } else if (!strcmp(params[0],"CREATE")) {
- nb_create(params[3], atoi(params[5]));
- } else if (!strcmp(params[0],"SMBrmdir")) {
- nb_rmdir(params[3]);
- } else if (!strcmp(params[0],"SMBunlink")) {
- fstrcpy(fname, params[3]);
- } else if (!strcmp(params[0],"SMBmv")) {
- nb_rename(params[3], params[5]);
- } else if (!strcmp(params[0],"SMBgetatr")) {
- fstrcpy(fname, params[3]);
- } else if (!strcmp(params[0],"SMBwrite")) {
- nb_write(atoi(params[3]),
- atoi(params[5]), atoi(params[7]));
- } else if (!strcmp(params[0],"SMBwritebraw")) {
- nb_write(atoi(params[3]),
- atoi(params[7]), atoi(params[5]));
- } else if (!strcmp(params[0],"SMBreadbraw")) {
- nb_read(atoi(params[3]),
- atoi(params[7]), atoi(params[5]));
- } else if (!strcmp(params[0],"SMBread")) {
- nb_read(atoi(params[3]),
- atoi(params[5]), atoi(params[7]));
- }
+ if (!strncmp(params[0],"SMB", 3)) {
+ printf("ERROR: You are using a dbench 1 load file\n");
+ exit(1);
+ }
+
+ if (!strcmp(params[0],"NTCreateX")) {
+ nb_createx(params[1], ival(params[2]), ival(params[3]),
+ ival(params[4]));
+ } else if (!strcmp(params[0],"Close")) {
+ nb_close(ival(params[1]));
+ } else if (!strcmp(params[0],"Rename")) {
+ nb_rename(params[1], params[2]);
+ } else if (!strcmp(params[0],"Unlink")) {
+ nb_unlink(params[1]);
+ } else if (!strcmp(params[0],"Deltree")) {
+ nb_deltree(params[1]);
+ } else if (!strcmp(params[0],"Rmdir")) {
+ nb_rmdir(params[1]);
+ } else if (!strcmp(params[0],"QUERY_PATH_INFORMATION")) {
+ nb_qpathinfo(params[1]);
+ } else if (!strcmp(params[0],"QUERY_FILE_INFORMATION")) {
+ nb_qfileinfo(ival(params[1]));
+ } else if (!strcmp(params[0],"QUERY_FS_INFORMATION")) {
+ nb_qfsinfo(ival(params[1]));
+ } else if (!strcmp(params[0],"FIND_FIRST")) {
+ nb_findfirst(params[1]);
+ } else if (!strcmp(params[0],"WriteX")) {
+ nb_writex(ival(params[1]),
+ ival(params[2]), ival(params[3]), ival(params[4]));
+ } else if (!strcmp(params[0],"ReadX")) {
+ nb_readx(ival(params[1]),
+ ival(params[2]), ival(params[3]), ival(params[4]));
+ } else if (!strcmp(params[0],"Flush")) {
+ nb_flush(ival(params[1]));
} else {
- if (!strcmp(params[0],"SMBopenX")) {
- if (!strncmp(params[2], "ERR", 3)) continue;
- nb_open(fname, atoi(params[3]), atoi(params[5]));
- } else if (!strcmp(params[0],"SMBgetatr")) {
- if (!strncmp(params[2], "ERR", 3)) continue;
- nb_stat(fname, atoi(params[3]));
- } else if (!strcmp(params[0],"SMBunlink")) {
- if (!strncmp(params[2], "ERR", 3)) continue;
- nb_unlink(fname);
- }
+ printf("Unknown operation %s\n", params[0]);
+ exit(1);
}
}
fclose(f);
- slprintf(fname,sizeof(fname), "CLIENTS/CLIENT%d", client);
+ slprintf(fname,sizeof(fname), "clients/client%d", client);
rmdir(fname);
- rmdir("CLIENTS");
-
- printf("+");
+ rmdir("clients");
if (!torture_close_connection(&cli)) {
correct = False;
@@ -722,35 +721,27 @@ static BOOL run_netbench(int client)
}
-/* run a test that simulates an approximate netbench w9X client load */
-static BOOL run_nbw95(int dummy)
+/* run a test that simulates an approximate netbench client load */
+static BOOL run_nbench(int dummy)
{
double t;
BOOL correct = True;
- t = create_procs(run_netbench, &correct);
- /* to produce a netbench result we scale accoding to the
- netbench measured throughput for the run that produced the
- sniff that was used to produce client.txt. That run used 2
- clients and ran for 660 seconds to produce a result of
- 4MBit/sec. */
- printf("Throughput %g MB/sec (NB=%g MB/sec %g MBit/sec)\n",
- 132*nprocs/t, 0.5*0.5*nprocs*660/t, 2*nprocs*660/t);
- return correct;
-}
-/* run a test that simulates an approximate netbench wNT client load */
-static BOOL run_nbwnt(int dummy)
-{
- double t;
- BOOL correct = True;
+ nbio_shmem(nprocs);
+
+ nbio_id = -1;
+
+ signal(SIGALRM, nb_alarm);
+ alarm(1);
t = create_procs(run_netbench, &correct);
- printf("Throughput %g MB/sec (NB=%g MB/sec %g MBit/sec)\n",
- 132*nprocs/t, 0.5*0.5*nprocs*660/t, 2*nprocs*660/t);
+ alarm(0);
+
+ printf("\nThroughput %g MB/sec\n",
+ 1.0e-6 * nbio_total() / t);
return correct;
}
-
/*
This test checks for two things:
@@ -3077,8 +3068,7 @@ static struct {
{"TORTURE",run_torture, FLAG_MULTIPROC},
{"RANDOMIPC", run_randomipc, 0},
{"NEGNOWAIT", run_negprot_nowait, 0},
- {"NBW95", run_nbw95, 0},
- {"NBWNT", run_nbwnt, 0},
+ {"NBENCH", run_nbench, 0},
{"OPLOCK1", run_oplock1, 0},
{"OPLOCK2", run_oplock2, 0},
{"OPLOCK3", run_oplock3, 0},
@@ -3159,6 +3149,7 @@ static void usage(void)
printf("\t-O socket_options\n");
printf("\t-m maximum protocol\n");
printf("\t-L use oplocks\n");
+ printf("\t-c CLIENT.TXT specify client load file for NBENCH\n");
printf("\t-A showall\n");
printf("\n\n");
@@ -3259,6 +3250,9 @@ static void usage(void)
case 'n':
fstrcpy(myname, optarg);
break;
+ case 'c':
+ client_txt = optarg;
+ break;
case 'U':
pstrcpy(username,optarg);
p = strchr_m(username,'%');