diff options
author | Luke Leighton <lkcl@samba.org> | 2000-05-24 05:40:03 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 2000-05-24 05:40:03 +0000 |
commit | fb66b3b6e6f7de7ffbbf2ae3537be7a115597b39 (patch) | |
tree | 2861f1431019515493cd4264c3e88db760704c9f /source3/utils | |
parent | 295b2d31a55c1450667519502fb94d852bf6cfd0 (diff) | |
download | samba-fb66b3b6e6f7de7ffbbf2ae3537be7a115597b39.tar.gz samba-fb66b3b6e6f7de7ffbbf2ae3537be7a115597b39.tar.bz2 samba-fb66b3b6e6f7de7ffbbf2ae3537be7a115597b39.zip |
torture test:
same cli_state:
open file rw/denynone, open *same* file r/denynone.
write to file (fd1) read from file (fd2). compare. repeat.
two cli_states:
open file rw/denynone (cli1), open *same* file r/denynone (cli2).
write to file (fd1) read from file (fd2). compare. repeat.
(This used to be commit 0a993f37830938a8d4262c6b7913af502bbf015f)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/torture.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/source3/utils/torture.c b/source3/utils/torture.c index e74106609d..8f22c011e1 100644 --- a/source3/utils/torture.c +++ b/source3/utils/torture.c @@ -270,6 +270,95 @@ static void run_torture(int dummy) close_connection(&cli); } +static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2) +{ + char *lockfname = "\\torture.lck"; + int fnum1; + int fnum2; + int i; + char buf[131072]; + char buf_rd[131072]; + + if (!cli_unlink(c1, lockfname)) { + printf("unlink failed (%s)\n", cli_errstr(c1)); + } + + fnum1 = cli_open(c1, lockfname, O_RDWR | O_CREAT | O_EXCL, + DENY_NONE); + if (fnum1 == -1) { + printf("first open read/write of %s failed (%s)\n", + lockfname, cli_errstr(c1)); + return False; + } + fnum2 = cli_open(c2, lockfname, O_RDONLY, + DENY_NONE); + if (fnum2 == -1) { + printf("second open read-only of %s failed (%s)\n", + lockfname, cli_errstr(c2)); + cli_close(c1, fnum1); + return False; + } + + for (i=0;i<numops;i++) + { + unsigned buf_size = ((unsigned)sys_random()%(sizeof(buf)-1))+ 1; + if (i % 10 == 0) { + printf("%d\r", i); fflush(stdout); + } + + generate_random_buffer(buf, buf_size, False); + + if (cli_write(c1, fnum1, 0, buf, 0, buf_size) != buf_size) { + printf("write failed (%s)\n", cli_errstr(c1)); + } + + if (cli_read(c2, fnum2, buf_rd, 0, buf_size) != buf_size) { + printf("read failed (%s)\n", cli_errstr(c2)); + } + + if (memcmp(buf_rd, buf, buf_size) != 0) + { + printf("read/write compare failed\n"); + } + } + + if (!cli_close(c2, fnum2)) { + printf("close failed (%s)\n", cli_errstr(c2)); + } + if (!cli_close(c1, fnum1)) { + printf("close failed (%s)\n", cli_errstr(c1)); + } + + if (!cli_unlink(c1, lockfname)) { + printf("unlink failed (%s)\n", cli_errstr(c1)); + } + + return True; +} + +static void run_readwritetest(int dummy) +{ + static struct cli_state cli1, cli2; + BOOL test; + + if (!open_connection(&cli1) || !open_connection(&cli2)) { + return; + } + cli_sockopt(&cli1, sockops); + cli_sockopt(&cli2, sockops); + + printf("starting readwritetest\n"); + + test = rw_torture2(&cli1, &cli2); + printf("Passed readwritetest v1: %s\n", BOOLSTR(test)); + + test = rw_torture2(&cli1, &cli1); + printf("Passed readwritetest v2: %s\n", BOOLSTR(test)); + + close_connection(&cli1); + close_connection(&cli2); +} + int line_count = 0; /* run a test that simulates an approximate netbench client load */ @@ -1855,9 +1944,11 @@ static struct { {"DENY1", run_denytest1, 0}, {"DENY2", run_denytest2, 0}, {"TCON", run_tcon_test, 0}, + {"RW", run_readwritetest, 0}, {NULL, NULL, 0}}; + /**************************************************************************** run a specified test or "ALL" ****************************************************************************/ |