diff options
author | Andrew Bartlett <abartlet@samba.org> | 2001-07-04 13:51:06 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2001-07-04 13:51:06 +0000 |
commit | 8551e592c230d087faaaa5d6295515a592c6fd18 (patch) | |
tree | 12bbd9d62c6f2c4fc97bdb17ad0743e61f10a3e5 | |
parent | 927b61173b4bbfac2b7fc3cc234873e22ddd6859 (diff) | |
download | samba-8551e592c230d087faaaa5d6295515a592c6fd18.tar.gz samba-8551e592c230d087faaaa5d6295515a592c6fd18.tar.xz samba-8551e592c230d087faaaa5d6295515a592c6fd18.zip |
This brings SAMBA_2_2's torture.c into line with HEAD, so I can run the same tests on both and see what breaks.
Andrew Bartlett
-rw-r--r-- | source/utils/torture.c | 1198 |
1 files changed, 731 insertions, 467 deletions
diff --git a/source/utils/torture.c b/source/utils/torture.c index 84f68e638da..6290a0abc52 100644 --- a/source/utils/torture.c +++ b/source/utils/torture.c @@ -33,7 +33,7 @@ static fstring randomfname; static BOOL use_oplocks; static BOOL use_level_II_oplocks; -static double create_procs(void (*fn)(int)); +static double create_procs(BOOL (*fn)(int), BOOL *result); static struct timeval tp1,tp2; @@ -153,13 +153,17 @@ static BOOL open_connection(struct cli_state *c) } -static void close_connection(struct cli_state *c) +static BOOL close_connection(struct cli_state *c) { + BOOL ret = True; if (!cli_tdis(c)) { printf("tdis failed (%s)\n", cli_errstr(c)); + ret = False; } - cli_shutdown(c); + cli_shutdown(c); + + return ret; } @@ -200,6 +204,7 @@ static BOOL rw_torture(struct cli_state *c) pid_t pid2, pid = getpid(); int i, j; char buf[1024]; + BOOL correct = True; fnum2 = cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE); @@ -225,11 +230,13 @@ static BOOL rw_torture(struct cli_state *c) fnum = cli_open(c, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL); if (fnum == -1) { printf("open failed (%s)\n", cli_errstr(c)); + correct = False; break; } if (cli_write(c, fnum, 0, (char *)&pid, 0, sizeof(pid)) != sizeof(pid)) { printf("write failed (%s)\n", cli_errstr(c)); + correct = False; } for (j=0;j<50;j++) { @@ -237,6 +244,7 @@ static BOOL rw_torture(struct cli_state *c) sizeof(pid)+(j*sizeof(buf)), sizeof(buf)) != sizeof(buf)) { printf("write failed (%s)\n", cli_errstr(c)); + correct = False; } } @@ -244,22 +252,27 @@ static BOOL rw_torture(struct cli_state *c) if (cli_read(c, fnum, (char *)&pid2, 0, sizeof(pid)) != sizeof(pid)) { printf("read failed (%s)\n", cli_errstr(c)); + correct = False; } if (pid2 != pid) { printf("data corruption!\n"); + correct = False; } if (!cli_close(c, fnum)) { printf("close failed (%s)\n", cli_errstr(c)); + correct = False; } if (!cli_unlink(c, fname)) { printf("unlink failed (%s)\n", cli_errstr(c)); + correct = False; } if (!cli_unlock(c, fnum2, n*sizeof(int), sizeof(int))) { printf("unlock failed (%s)\n", cli_errstr(c)); + correct = False; } } @@ -268,20 +281,25 @@ static BOOL rw_torture(struct cli_state *c) printf("%d\n", i); - return True; + return correct; } -static void run_torture(int dummy) +static BOOL run_torture(int dummy) { struct cli_state cli; + BOOL ret; cli = current_cli; cli_sockopt(&cli, sockops); - rw_torture(&cli); + ret = rw_torture(&cli); - close_connection(&cli); + if (!close_connection(&cli)) { + ret = False; + } + + return ret; } static BOOL rw_torture3(struct cli_state *c, char *lockfname) @@ -293,6 +311,7 @@ static BOOL rw_torture3(struct cli_state *c, char *lockfname) unsigned count; unsigned countprev = 0; unsigned sent = 0; + BOOL correct = True; srandom(1); for (i = 0; i < sizeof(buf); i += sizeof(uint32)) @@ -345,6 +364,7 @@ static BOOL rw_torture3(struct cli_state *c, char *lockfname) if (cli_write(c, fnum, 0, buf+count, count, sent) != sent) { printf("write failed (%s)\n", cli_errstr(c)); + correct = False; } } else @@ -356,6 +376,7 @@ static BOOL rw_torture3(struct cli_state *c, char *lockfname) printf("read failed offset:%d size:%d (%s)\n", count, sizeof(buf)-count, cli_errstr(c)); + correct = False; sent = 0; } if (sent > 0) @@ -365,6 +386,7 @@ static BOOL rw_torture3(struct cli_state *c, char *lockfname) printf("read/write compare failed\n"); printf("offset: %d req %d recvd %d\n", count, sizeof(buf)-count, sent); + correct = False; break; } } @@ -374,9 +396,10 @@ static BOOL rw_torture3(struct cli_state *c, char *lockfname) if (!cli_close(c, fnum)) { printf("close failed (%s)\n", cli_errstr(c)); + correct = False; } - return True; + return correct; } static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2) @@ -387,9 +410,11 @@ static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2) int i; char buf[131072]; char buf_rd[131072]; + BOOL correct = True; + ssize_t bytes_read; if (!cli_unlink(c1, lockfname)) { - printf("unlink failed (%s)\n", cli_errstr(c1)); + printf("unlink failed (%s) (normal, this file should not exist)\n", cli_errstr(c1)); } fnum1 = cli_open(c1, lockfname, O_RDWR | O_CREAT | O_EXCL, @@ -410,7 +435,7 @@ static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2) for (i=0;i<numops;i++) { - unsigned buf_size = ((unsigned)sys_random()%(sizeof(buf)-1))+ 1; + size_t buf_size = ((unsigned)sys_random()%(sizeof(buf)-1))+ 1; if (i % 10 == 0) { printf("%d\r", i); fflush(stdout); } @@ -419,56 +444,70 @@ static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2) if (cli_write(c1, fnum1, 0, buf, 0, buf_size) != buf_size) { printf("write failed (%s)\n", cli_errstr(c1)); + correct = False; } - if (cli_read(c2, fnum2, buf_rd, 0, buf_size) != buf_size) { + if ((bytes_read = cli_read(c2, fnum2, buf_rd, 0, buf_size)) != buf_size) { printf("read failed (%s)\n", cli_errstr(c2)); + printf("read %d, expected %d\n", bytes_read, buf_size); + correct = False; } if (memcmp(buf_rd, buf, buf_size) != 0) { printf("read/write compare failed\n"); + correct = False; } } if (!cli_close(c2, fnum2)) { printf("close failed (%s)\n", cli_errstr(c2)); + correct = False; } if (!cli_close(c1, fnum1)) { printf("close failed (%s)\n", cli_errstr(c1)); + correct = False; } if (!cli_unlink(c1, lockfname)) { printf("unlink failed (%s)\n", cli_errstr(c1)); + correct = False; } - return True; + return correct; } -static void run_readwritetest(int dummy) +static BOOL run_readwritetest(int dummy) { static struct cli_state cli1, cli2; - BOOL test; + BOOL test1, test2; if (!open_connection(&cli1) || !open_connection(&cli2)) { - return; + return False; } 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)); + test1 = rw_torture2(&cli1, &cli2); + printf("Passed readwritetest v1: %s\n", BOOLSTR(test1)); - test = rw_torture2(&cli1, &cli1); - printf("Passed readwritetest v2: %s\n", BOOLSTR(test)); + test2 = rw_torture2(&cli1, &cli1); + printf("Passed readwritetest v2: %s\n", BOOLSTR(test2)); - close_connection(&cli1); - close_connection(&cli2); + if (!close_connection(&cli1)) { + test1 = False; + } + + if (!close_connection(&cli2)) { + test2 = False; + } + + return (test1 && test2); } -static void run_readwritemulti(int dummy) +static BOOL run_readwritemulti(int dummy) { static struct cli_state cli; BOOL test; @@ -480,72 +519,87 @@ static void run_readwritemulti(int dummy) printf("run_readwritemulti: fname %s\n", randomfname); test = rw_torture3(&cli, randomfname); - close_connection(&cli); + if (!close_connection(&cli)) { + test = False; + } + + return test; } -static void run_readwritelarge(int dummy) +static BOOL run_readwritelarge(int dummy) { - static struct cli_state cli1; + static struct cli_state cli1; int fnum1; char *lockfname = "\\large.dat"; size_t fsize; char buf[0x10000]; + BOOL correct = True; - if (!open_connection(&cli1)) { - return; - } - cli_sockopt(&cli1, sockops); + if (!open_connection(&cli1)) { + return False; + } + cli_sockopt(&cli1, sockops); memset(buf,'\0',sizeof(buf)); - + cli1.max_xmit = 0x11000; - - printf("starting readwritelarge\n"); + + printf("starting readwritelarge\n"); cli_unlink(&cli1, lockfname); fnum1 = cli_open(&cli1, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE); if (fnum1 == -1) { printf("open read/write of %s failed (%s)\n", lockfname, cli_errstr(&cli1)); - return; + return False; } cli_write(&cli1, fnum1, 0, buf, 0, sizeof(buf)); if (!cli_close(&cli1, fnum1)) { printf("close failed (%s)\n", cli_errstr(&cli1)); + correct = False; } if (!cli_qpathinfo(&cli1, lockfname, NULL, NULL, NULL, &fsize, NULL)) { printf("qpathinfo failed (%s)\n", cli_errstr(&cli1)); + correct = False; } if (fsize == sizeof(buf)) printf("readwritelarge test 1 succeeded (size = %x)\n", fsize); - else + else { printf("readwritelarge test 1 failed (size = %x)\n", fsize); + correct = False; + } if (!cli_unlink(&cli1, lockfname)) { printf("unlink failed (%s)\n", cli_errstr(&cli1)); + correct = False; } fnum1 = cli_open(&cli1, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE); if (fnum1 == -1) { printf("open read/write of %s failed (%s)\n", lockfname, cli_errstr(&cli1)); - return; + return False; } - + cli_smbwrite(&cli1, fnum1, buf, 0, sizeof(buf)); - + if (!cli_close(&cli1, fnum1)) { printf("close failed (%s)\n", cli_errstr(&cli1)); + correct = False; + } + + if (!close_connection(&cli1)) { + correct = False; + } + return correct; } - close_connection(&cli1); -} int line_count = 0; /* run a test that simulates an approximate netbench client load */ -static void run_netbench(int client) +static BOOL run_netbench(int client) { struct cli_state cli; int i; @@ -554,6 +608,7 @@ static void run_netbench(int client) char cname[20]; FILE *f; char *params[20]; + BOOL correct = True; cli = current_cli; @@ -567,7 +622,7 @@ static void run_netbench(int client) if (!f) { perror("client.txt"); - return; + return False; } while (fgets(line, sizeof(line)-1, f)) { @@ -641,15 +696,20 @@ static void run_netbench(int client) printf("+"); - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } + + return correct; } /* run a test that simulates an approximate netbench w9X client load */ -static void run_nbw95(int dummy) +static BOOL run_nbw95(int dummy) { double t; - t = create_procs(run_netbench); + 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 @@ -657,15 +717,18 @@ static void run_nbw95(int dummy) 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 void run_nbwnt(int dummy) +static BOOL run_nbwnt(int dummy) { double t; - t = create_procs(run_netbench); + BOOL correct = True; + 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); + return correct; } @@ -677,7 +740,7 @@ static void run_nbwnt(int dummy) must not use posix semantics) 2) support for lock timeouts */ -static void run_locktest1(int dummy) +static BOOL run_locktest1(int dummy) { static struct cli_state cli1, cli2; char *fname = "\\lockt1.lck"; @@ -685,7 +748,7 @@ static void run_locktest1(int dummy) time_t t1, t2; if (!open_connection(&cli1) || !open_connection(&cli2)) { - return; + return False; } cli_sockopt(&cli1, sockops); cli_sockopt(&cli2, sockops); @@ -697,30 +760,30 @@ static void run_locktest1(int dummy) fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } fnum2 = cli_open(&cli1, fname, O_RDWR, DENY_NONE); if (fnum2 == -1) { printf("open2 of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } fnum3 = cli_open(&cli2, fname, O_RDWR, DENY_NONE); if (fnum3 == -1) { printf("open3 of %s failed (%s)\n", fname, cli_errstr(&cli2)); - return; + return False; } if (!cli_lock(&cli1, fnum1, 0, 4, 0, WRITE_LOCK)) { printf("lock1 failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } if (cli_lock(&cli2, fnum3, 0, 4, 0, WRITE_LOCK)) { printf("lock2 succeeded! This is a locking bug\n"); - return; + return False; } else { - if (!check_error(&cli2, ERRDOS, ERRlock, 0)) return; + if (!check_error(&cli2, ERRDOS, ERRlock, 0)) return False; } @@ -728,9 +791,9 @@ static void run_locktest1(int dummy) t1 = time(NULL); if (cli_lock(&cli2, fnum3, 0, 4, 10*1000, WRITE_LOCK)) { printf("lock3 succeeded! This is a locking bug\n"); - return; + return False; } else { - if (!check_error(&cli2, ERRDOS, ERRlock, 0)) return; + if (!check_error(&cli2, ERRDOS, ERRlock, 0)) return False; } t2 = time(NULL); @@ -740,42 +803,48 @@ static void run_locktest1(int dummy) if (!cli_close(&cli1, fnum2)) { printf("close1 failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } if (cli_lock(&cli2, fnum3, 0, 4, 0, WRITE_LOCK)) { printf("lock4 succeeded! This is a locking bug\n"); - return; + return False; } else { - if (!check_error(&cli2, ERRDOS, ERRlock, 0)) return; + if (!check_error(&cli2, ERRDOS, ERRlock, 0)) return False; } if (!cli_close(&cli1, fnum1)) { printf("close2 failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } if (!cli_close(&cli2, fnum3)) { printf("close3 failed (%s)\n", cli_errstr(&cli2)); - return; + return False; } if (!cli_unlink(&cli1, fname)) { printf("unlink failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } - close_connection(&cli1); - close_connection(&cli2); + if (!close_connection(&cli1)) { + return False; + } + + if (!close_connection(&cli2)) { + return False; + } printf("Passed locktest1\n"); + return True; } /* checks for correct tconX support */ -static void run_tcon_test(int dummy) +static BOOL run_tcon_test(int dummy) { static struct cli_state cli1; char *fname = "\\tcontest.tmp"; @@ -784,7 +853,7 @@ static void run_tcon_test(int dummy) char buf[4]; if (!open_connection(&cli1)) { - return; + return False; } cli_sockopt(&cli1, sockops); @@ -796,7 +865,7 @@ static void run_tcon_test(int dummy) if (fnum1 == -1) { printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } cnum = cli1.cnum; @@ -804,7 +873,7 @@ static void run_tcon_test(int dummy) if (cli_write(&cli1, fnum1, 0, buf, 130, 4) != 4) { printf("write failed (%s)", cli_errstr(&cli1)); - return; + return False; } if (!cli_send_tconX(&cli1, share, "?????", @@ -812,35 +881,38 @@ static void run_tcon_test(int dummy) printf("%s refused 2nd tree connect (%s)\n", host, cli_errstr(&cli1)); cli_shutdown(&cli1); - return ; + return False; } if (cli_write(&cli1, fnum1, 0, buf, 130, 4) == 4) { printf("write succeeded (%s)", cli_errstr(&cli1)); - return; + return False; } if (cli_close(&cli1, fnum1)) { printf("close2 succeeded (%s)\n", cli_errstr(&cli1)); - return; + return False; } if (!cli_tdis(&cli1)) { printf("tdis failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } cli1.cnum = cnum; if (!cli_close(&cli1, fnum1)) { printf("close2 failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } - close_connection(&cli1); + if (!close_connection(&cli1)) { + return False; + } printf("Passed tcontest\n"); + return True; } @@ -855,14 +927,15 @@ static void run_tcon_test(int dummy) 3) the server denies unlock requests by an incorrect client PID */ -static void run_locktest2(int dummy) +static BOOL run_locktest2(int dummy) { static struct cli_state cli; char *fname = "\\lockt2.lck"; int fnum1, fnum2, fnum3; + BOOL correct = True; if (!open_connection(&cli)) { - return; + return False; } cli_sockopt(&cli, sockops); @@ -876,13 +949,13 @@ static void run_locktest2(int dummy) fnum1 = cli_open(&cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { printf("open of %s failed (%s)\n", fname, cli_errstr(&cli)); - return; + return False; } fnum2 = cli_open(&cli, fname, O_RDWR, DENY_NONE); if (fnum2 == -1) { printf("open2 of %s failed (%s)\n", fname, cli_errstr(&cli)); - return; + return False; } cli_setpid(&cli, 2); @@ -890,32 +963,35 @@ static void run_locktest2(int dummy) fnum3 = cli_open(&cli, fname, O_RDWR, DENY_NONE); if (fnum3 == -1) { printf("open3 of %s failed (%s)\n", fname, cli_errstr(&cli)); - return; + return False; } cli_setpid(&cli, 1); if (!cli_lock(&cli, fnum1, 0, 4, 0, WRITE_LOCK)) { printf("lock1 failed (%s)\n", cli_errstr(&cli)); - return; + return False; } if (cli_lock(&cli, fnum1, 0, 4, 0, WRITE_LOCK)) { printf("WRITE lock1 succeeded! This is a locking bug\n"); + correct = False; } else { - if (!check_error(&cli, ERRDOS, ERRlock, 0)) return; + if (!check_error(&cli, ERRDOS, ERRlock, 0)) return False; } if (cli_lock(&cli, fnum2, 0, 4, 0, WRITE_LOCK)) { printf("WRITE lock2 succeeded! This is a locking bug\n"); + correct = False; } else { - if (!check_error(&cli, ERRDOS, ERRlock, 0)) return; + if (!check_error(&cli, ERRDOS, ERRlock, 0)) return False; } if (cli_lock(&cli, fnum2, 0, 4, 0, READ_LOCK)) { printf("READ lock2 succeeded! This is a locking bug\n"); + correct = False; } else { - if (!check_error(&cli, ERRDOS, ERRlock, 0)) return; + if (!check_error(&cli, ERRDOS, ERRlock, 0)) return False; } #if 1 /* JRATEST */ @@ -925,6 +1001,7 @@ static void run_locktest2(int dummy) cli_setpid(&cli, 2); if (cli_unlock(&cli, fnum1, 100, 4)) { printf("unlock at 100 succeeded! This is a locking bug\n"); + correct = False; } else { printf("unlock at 100 failed with error %s\n", cli_errstr(&cli) ); } @@ -933,41 +1010,46 @@ static void run_locktest2(int dummy) if (cli_unlock(&cli, fnum1, 0, 4)) { printf("unlock1 succeeded! This is a locking bug\n"); } else { - if (!check_error(&cli, ERRDOS, ERRnotlocked, 0)) return; + if (!check_error(&cli, ERRDOS, ERRnotlocked, 0)) return False; } if (cli_unlock(&cli, fnum1, 0, 8)) { printf("unlock2 succeeded! This is a locking bug\n"); } else { - if (!check_error(&cli, ERRDOS, ERRnotlocked, 0)) return; + if (!check_error(&cli, ERRDOS, ERRnotlocked, 0)) return False; } if (cli_lock(&cli, fnum3, 0, 4, 0, WRITE_LOCK)) { printf("lock3 succeeded! This is a locking bug\n"); + correct = False; } else { - if (!check_error(&cli, ERRDOS, ERRlock, 0)) return; + if (!check_error(&cli, ERRDOS, ERRlock, 0)) return False; } cli_setpid(&cli, 1); if (!cli_close(&cli, fnum1)) { printf("close1 failed (%s)\n", cli_errstr(&cli)); - return; + return False; } if (!cli_close(&cli, fnum2)) { printf("close2 failed (%s)\n", cli_errstr(&cli)); - return; + return False; } if (!cli_close(&cli, fnum3)) { printf("close3 failed (%s)\n", cli_errstr(&cli)); - return; + return False; } - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } printf("locktest2 finished\n"); + + return correct; } @@ -976,17 +1058,18 @@ static void run_locktest2(int dummy) 1) the server supports the full offset range in lock requests */ -static void run_locktest3(int dummy) +static BOOL run_locktest3(int dummy) { static struct cli_state cli1, cli2; char *fname = "\\lockt3.lck"; int fnum1, fnum2, i; uint32 offset; + BOOL correct = True; #define NEXT_OFFSET offset += (~(uint32)0) / numops if (!open_connection(&cli1) || !open_connection(&cli2)) { - return; + return False; } cli_sockopt(&cli1, sockops); cli_sockopt(&cli2, sockops); @@ -998,12 +1081,12 @@ static void run_locktest3(int dummy) fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } fnum2 = cli_open(&cli2, fname, O_RDWR, DENY_NONE); if (fnum2 == -1) { printf("open2 of %s failed (%s)\n", fname, cli_errstr(&cli2)); - return; + return False; } for (offset=i=0;i<numops;i++) { @@ -1012,14 +1095,14 @@ static void run_locktest3(int dummy) printf("lock1 %d failed (%s)\n", i, cli_errstr(&cli1)); - return; + return False; } if (!cli_lock(&cli2, fnum2, offset-2, 1, 0, WRITE_LOCK)) { printf("lock2 %d failed (%s)\n", i, cli_errstr(&cli1)); - return; + return False; } } @@ -1028,22 +1111,22 @@ static void run_locktest3(int dummy) if (cli_lock(&cli1, fnum1, offset-2, 1, 0, WRITE_LOCK)) { printf("error: lock1 %d succeeded!\n", i); - return; + return False; } if (cli_lock(&cli2, fnum2, offset-1, 1, 0, WRITE_LOCK)) { printf("error: lock2 %d succeeded!\n", i); - return; + return False; } if (cli_lock(&cli1, fnum1, offset-1, 1, 0, WRITE_LOCK)) { printf("error: lock3 %d succeeded!\n", i); - return; + return False; } if (cli_lock(&cli2, fnum2, offset-2, 1, 0, WRITE_LOCK)) { printf("error: lock4 %d succeeded!\n", i); - return; + return False; } } @@ -1054,51 +1137,63 @@ static void run_locktest3(int dummy) printf("unlock1 %d failed (%s)\n", i, cli_errstr(&cli1)); - return; + return False; } if (!cli_unlock(&cli2, fnum2, offset-2, 1)) { printf("unlock2 %d failed (%s)\n", i, cli_errstr(&cli1)); - return; + return False; } } if (!cli_close(&cli1, fnum1)) { printf("close1 failed (%s)\n", cli_errstr(&cli1)); + return False; } if (!cli_close(&cli2, fnum2)) { printf("close2 failed (%s)\n", cli_errstr(&cli2)); + return False; } if (!cli_unlink(&cli1, fname)) { printf("unlink failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } - close_connection(&cli1); - close_connection(&cli2); + if (!close_connection(&cli1)) { + correct = False; + } + + if (!close_connection(&cli2)) { + correct = False; + } printf("finished locktest3\n"); + + return correct; } -#define EXPECTED(ret, v) if ((ret) != (v)) printf("** ") +#define EXPECTED(ret, v) if ((ret) != (v)) { \ + printf("** "); correct = False; \ + } /* looks at overlapping locks */ -static void run_locktest4(int dummy) +static BOOL run_locktest4(int dummy) { static struct cli_state cli1, cli2; char *fname = "\\lockt4.lck"; int fnum1, fnum2, f; BOOL ret; char buf[1000]; + BOOL correct = True; if (!open_connection(&cli1) || !open_connection(&cli2)) { - return; + return False; } cli_sockopt(&cli1, sockops); @@ -1115,6 +1210,7 @@ static void run_locktest4(int dummy) if (cli_write(&cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { printf("Failed to create file\n"); + correct = False; goto fail; } @@ -1243,8 +1339,6 @@ static void run_locktest4(int dummy) EXPECTED(ret, True); printf("the server %s have the NT byte range lock bug\n", !ret?"does":"doesn't"); - - fail: cli_close(&cli1, fnum1); cli_close(&cli2, fnum2); @@ -1253,21 +1347,23 @@ static void run_locktest4(int dummy) close_connection(&cli2); printf("finished locktest4\n"); + return correct; } /* looks at lock upgrade/downgrade. */ -static void run_locktest5(int dummy) +static BOOL run_locktest5(int dummy) { static struct cli_state cli1, cli2; char *fname = "\\lockt5.lck"; int fnum1, fnum2, fnum3; BOOL ret; char buf[1000]; + BOOL correct = True; if (!open_connection(&cli1) || !open_connection(&cli2)) { - return; + return False; } cli_sockopt(&cli1, sockops); @@ -1285,6 +1381,7 @@ static void run_locktest5(int dummy) if (cli_write(&cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { printf("Failed to create file\n"); + correct = False; goto fail; } @@ -1360,21 +1457,28 @@ static void run_locktest5(int dummy) printf("a different processs %s get a write lock on the unlocked stack\n", ret?"can":"cannot"); + fail: cli_close(&cli1, fnum1); cli_close(&cli2, fnum2); cli_unlink(&cli1, fname); - close_connection(&cli1); - close_connection(&cli2); + if (!close_connection(&cli1)) { + correct = False; + } + if (!close_connection(&cli2)) { + correct = False; + } printf("finished locktest5\n"); + + return correct; } /* this produces a matrix of deny mode behaviour */ -static void run_denytest1(int dummy) +static BOOL run_denytest1(int dummy) { static struct cli_state cli1, cli2; int fnum1, fnum2; @@ -1399,9 +1503,10 @@ static void run_denytest1(int dummy) {O_RDONLY, "O_RDONLY"}, {O_WRONLY, "O_WRONLY"}, {-1, NULL}}; + BOOL correct = True; if (!open_connection(&cli1) || !open_connection(&cli2)) { - return; + return False; } cli_sockopt(&cli1, sockops); cli_sockopt(&cli2, sockops); @@ -1454,10 +1559,15 @@ static void run_denytest1(int dummy) cli_unlink(&cli1, fnames[f]); } - close_connection(&cli1); - close_connection(&cli2); + if (!close_connection(&cli1)) { + correct = False; + } + if (!close_connection(&cli2)) { + correct = False; + } printf("finshed denytest1\n"); + return correct; } @@ -1465,7 +1575,7 @@ static void run_denytest1(int dummy) this produces a matrix of deny mode behaviour for two opens on the same connection */ -static void run_denytest2(int dummy) +static BOOL run_denytest2(int dummy) { static struct cli_state cli1; int fnum1, fnum2; @@ -1490,9 +1600,10 @@ static void run_denytest2(int dummy) {O_RDONLY, "O_RDONLY"}, {O_WRONLY, "O_WRONLY"}, {-1, NULL}}; + BOOL correct = True; if (!open_connection(&cli1)) { - return; + return False; } cli_sockopt(&cli1, sockops); @@ -1544,16 +1655,19 @@ static void run_denytest2(int dummy) cli_unlink(&cli1, fnames[f]); } - close_connection(&cli1); + if (!close_connection(&cli1)) { + correct = False; + } printf("finshed denytest2\n"); + return correct; } /* test whether fnums and tids open on one VC are available on another (a major security hole) */ -static void run_fdpasstest(int dummy) +static BOOL run_fdpasstest(int dummy) { static struct cli_state cli1, cli2, cli3; char *fname = "\\fdpass.tst"; @@ -1561,7 +1675,7 @@ static void run_fdpasstest(int dummy) pstring buf; if (!open_connection(&cli1) || !open_connection(&cli2)) { - return; + return False; } cli_sockopt(&cli1, sockops); cli_sockopt(&cli2, sockops); @@ -1573,12 +1687,12 @@ static void run_fdpasstest(int dummy) fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } if (cli_write(&cli1, fnum1, 0, "hello world\n", 0, 13) != 13) { printf("write failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } cli3 = cli2; @@ -1589,7 +1703,7 @@ static void run_fdpasstest(int dummy) if (cli_read(&cli3, fnum1, buf, 0, 13) == 13) { printf("read succeeded! nasty security hole [%s]\n", buf); - return; + return False; } cli_close(&cli1, fnum1); @@ -1599,6 +1713,7 @@ static void run_fdpasstest(int dummy) close_connection(&cli2); printf("finished fdpasstest\n"); + return True; } @@ -1607,14 +1722,15 @@ static void run_fdpasstest(int dummy) 1) the server does not allow an unlink on a file that is open */ -static void run_unlinktest(int dummy) +static BOOL run_unlinktest(int dummy) { static struct cli_state cli; char *fname = "\\unlink.tst"; int fnum; + BOOL correct = True; if (!open_connection(&cli)) { - return; + return False; } cli_sockopt(&cli, sockops); @@ -1628,38 +1744,44 @@ static void run_unlinktest(int dummy) fnum = cli_open(&cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { printf("open of %s failed (%s)\n", fname, cli_errstr(&cli)); - return; + return False; } if (cli_unlink(&cli, fname)) { printf("error: server allowed unlink on an open file\n"); + correct = False; } cli_close(&cli, fnum); cli_unlink(&cli, fname); - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } printf("unlink test finished\n"); + + return correct; } /* test how many open files this server supports on the one socket */ -static void run_maxfidtest(int dummy) +static BOOL run_maxfidtest(int dummy) { static struct cli_state cli; char *template = "\\maxfid.%d.%d"; fstring fname; int fnum; int retries=4; + BOOL correct = True; cli = current_cli; if (retries <= 0) { printf("failed to connect\n"); - return; + return False; } cli_sockopt(&cli, sockops); @@ -1688,11 +1810,15 @@ static void run_maxfidtest(int dummy) if (!cli_unlink(&cli, fname)) { printf("unlink of %s failed (%s)\n", fname, cli_errstr(&cli)); + correct = False; } } printf("maxfid test finished\n"); - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } + return correct; } /* generate a random buffer */ @@ -1705,29 +1831,34 @@ static void rand_buf(char *buf, int len) } /* send smb negprot commands, not reading the response */ -static void run_negprot_nowait(int dummy) +static BOOL run_negprot_nowait(int dummy) { int i; static struct cli_state cli; + BOOL correct = True; printf("starting negprot nowait test\n"); if (!open_nbt_connection(&cli)) { - return; + return False; } for (i=0;i<50000;i++) { cli_negprot_send(&cli); } - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } printf("finished negprot nowait test\n"); + + return correct; } /* send random IPC commands */ -static void run_randomipc(int dummy) +static BOOL run_randomipc(int dummy) { char *rparam = NULL; char *rdata = NULL; @@ -1735,11 +1866,12 @@ static void run_randomipc(int dummy) pstring param; int api, param_len, i; static struct cli_state cli; + BOOL correct = True; printf("starting random ipc test\n"); if (!open_connection(&cli)) { - return; + return False; } for (i=0;i<50000;i++) { @@ -1757,9 +1889,13 @@ static void run_randomipc(int dummy) &rdata, &rdrcnt); } - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } printf("finished random ipc test\n"); + + return correct; } @@ -1776,14 +1912,15 @@ static void browse_callback(const char *sname, uint32 stype, This test checks the browse list code */ -static void run_browsetest(int dummy) +static BOOL run_browsetest(int dummy) { static struct cli_state cli; + BOOL correct = True; printf("starting browse test\n"); if (!open_connection(&cli)) { - return; + return False; } printf("domain list:\n"); @@ -1796,26 +1933,32 @@ static void run_browsetest(int dummy) SV_TYPE_ALL, browse_callback, NULL); - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } printf("browse test finished\n"); + + return correct; + } /* This checks how the getatr calls works */ -static void run_attrtest(int dummy) +static BOOL run_attrtest(int dummy) { static struct cli_state cli; int fnum; time_t t, t2; char *fname = "\\attrib.tst"; + BOOL correct = True; printf("starting attrib test\n"); if (!open_connection(&cli)) { - return; + return False; } cli_unlink(&cli, fname); @@ -1824,42 +1967,51 @@ static void run_attrtest(int dummy) cli_close(&cli, fnum); if (!cli_getatr(&cli, fname, NULL, NULL, &t)) { printf("getatr failed (%s)\n", cli_errstr(&cli)); + correct = False; } if (abs(t - time(NULL)) > 2) { printf("ERROR: SMBgetatr bug. time is %s", ctime(&t)); t = time(NULL); + correct = True; } t2 = t-60*60*24; /* 1 day ago */ if (!cli_setatr(&cli, fname, 0, t2)) { printf("setatr failed (%s)\n", cli_errstr(&cli)); + correct = True; } if (!cli_getatr(&cli, fname, NULL, NULL, &t)) { printf("getatr failed (%s)\n", cli_errstr(&cli)); + correct = True; } if (t != t2) { printf("ERROR: getatr/setatr bug. times are\n%s", ctime(&t)); printf("%s", ctime(&t2)); + correct = True; } cli_unlink(&cli, fname); - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } printf("attrib test finished\n"); + + return correct; } /* This checks a couple of trans2 calls */ -static void run_trans2test(int dummy) +static BOOL run_trans2test(int dummy) { static struct cli_state cli; int fnum; @@ -1868,11 +2020,12 @@ static void run_trans2test(int dummy) char *fname = "\\trans2.tst"; char *dname = "\\trans2"; char *fname2 = "\\trans2\\trans2.tst"; + BOOL correct = True; printf("starting trans2 test\n"); if (!open_connection(&cli)) { - return; + return False; } cli_unlink(&cli, fname); @@ -1881,6 +2034,7 @@ static void run_trans2test(int dummy) if (!cli_qfileinfo(&cli, fnum, NULL, &size, &c_time, &a_time, &m_time, NULL, NULL)) { printf("ERROR: qfileinfo failed (%s)\n", cli_errstr(&cli)); + correct = False; } cli_close(&cli, fnum); @@ -1893,19 +2047,23 @@ static void run_trans2test(int dummy) if (!cli_qpathinfo(&cli, fname, &c_time, &a_time, &m_time, &size, NULL)) { printf("ERROR: qpathinfo failed (%s)\n", cli_errstr(&cli)); + correct = False; } else { if (c_time != m_time) { printf("create time=%s", ctime(&c_time)); printf("modify time=%s", ctime(&m_time)); printf("This system appears to have sticky create times\n"); + correct = False; } if (a_time % (60*60) == 0) { printf("access time=%s", ctime(&a_time)); printf("This system appears to set a midnight access time\n"); + correct = False; } if (abs(m_time - time(NULL)) > 60*60*24*7) { printf("ERROR: totally incorrect times - maybe word reversed?\n"); + correct = False; } } @@ -1917,10 +2075,12 @@ static void run_trans2test(int dummy) if (!cli_qpathinfo2(&cli, fname, &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL)) { printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(&cli)); + correct = False; } else { if (w_time < 60*60*24*2) { printf("write time=%s", ctime(&w_time)); printf("This system appears to set a initial 0 write time\n"); + correct = False; } } @@ -1931,11 +2091,13 @@ static void run_trans2test(int dummy) when creating a new file */ if (!cli_mkdir(&cli, dname)) { printf("ERROR: mkdir failed (%s)\n", cli_errstr(&cli)); + correct = False; } sleep(3); if (!cli_qpathinfo2(&cli, "\\trans2\\", &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL)) { printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(&cli)); + correct = False; } fnum = cli_open(&cli, fname2, @@ -1945,79 +2107,96 @@ static void run_trans2test(int dummy) if (!cli_qpathinfo2(&cli, "\\trans2\\", &c_time, &a_time, &m_time2, &w_time, &size, NULL, NULL)) { printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(&cli)); + correct = False; } else { - if (m_time2 == m_time) + if (m_time2 == m_time) { printf("This system does not update directory modification times\n"); + correct = False; + } } cli_unlink(&cli, fname2); cli_rmdir(&cli, dname); - - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } printf("trans2 test finished\n"); + + return correct; } /* This checks new W2K calls. */ -void new_trans(struct cli_state *pcli, int fnum, int level) +static BOOL new_trans(struct cli_state *pcli, int fnum, int level) { char buf[4096]; + BOOL correct = True; memset(buf, 0xff, sizeof(buf)); if (!cli_qfileinfo_test(pcli, fnum, level, buf)) { printf("ERROR: qfileinfo (%d) failed (%s)\n", level, cli_errstr(pcli)); + correct = False; } else { printf("qfileinfo: level %d\n", level); dump_data(0, buf, 256); printf("\n"); } + return correct; } -static void run_w2ktest(int dummy) +static BOOL run_w2ktest(int dummy) { static struct cli_state cli; int fnum; char *fname = "\\w2ktest\\w2k.tst"; int level; + BOOL correct = True; printf("starting w2k test\n"); if (!open_connection(&cli)) { - return; + return False; } fnum = cli_open(&cli, fname, O_RDWR | O_CREAT , DENY_NONE); - for (level = 1004; level < 1040; level++) - new_trans(&cli, fnum, level); + for (level = 1004; level < 1040; level++) { + if (!new_trans(&cli, fnum, level)) { + correct = False; + } + } cli_close(&cli, fnum); - - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } printf("w2k test finished\n"); + + return correct; } /* this is a harness for some oplock tests */ -static void run_oplock1(int dummy) +static BOOL run_oplock1(int dummy) { static struct cli_state cli1; char *fname = "\\lockt1.lck"; int fnum1; + BOOL correct = True; printf("starting oplock test 1\n"); if (!open_connection(&cli1)) { - return; + return False; } cli_unlink(&cli1, fname); @@ -2029,7 +2208,7 @@ static void run_oplock1(int dummy) fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } cli1.use_oplocks = False; @@ -2039,27 +2218,35 @@ static void run_oplock1(int dummy) if (!cli_close(&cli1, fnum1)) { printf("close2 failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } if (!cli_unlink(&cli1, fname)) { printf("unlink failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } - - close_connection(&cli1); + if (!close_connection(&cli1)) { + correct = False; + } printf("finished oplock test 1\n"); + + return correct; } -static void run_oplock2(int dummy) +static BOOL run_oplock2(int dummy) { static struct cli_state cli1, cli2; char *fname = "\\lockt2.lck"; int fnum1, fnum2; int saved_use_oplocks = use_oplocks; char buf[4]; + BOOL correct = True; + volatile BOOL *shared_correct; + + shared_correct = (volatile BOOL *)shm_setup(sizeof(BOOL)); + *shared_correct = True; use_level_II_oplocks = True; use_oplocks = True; @@ -2069,7 +2256,7 @@ static void run_oplock2(int dummy) if (!open_connection(&cli1)) { use_level_II_oplocks = False; use_oplocks = saved_use_oplocks; - return; + return False; } cli1.use_oplocks = True; @@ -2078,7 +2265,7 @@ static void run_oplock2(int dummy) if (!open_connection(&cli2)) { use_level_II_oplocks = False; use_oplocks = saved_use_oplocks; - return; + return False; } cli2.use_oplocks = True; @@ -2092,7 +2279,7 @@ static void run_oplock2(int dummy) fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } /* Don't need the globals any more. */ @@ -2104,6 +2291,7 @@ static void run_oplock2(int dummy) fnum2 = cli_open(&cli2, fname, O_RDWR, DENY_NONE); if (fnum2 == -1) { printf("second open of %s failed (%s)\n", fname, cli_errstr(&cli1)); + *shared_correct = False; exit(0); } @@ -2111,6 +2299,7 @@ static void run_oplock2(int dummy) if (!cli_close(&cli2, fnum2)) { printf("close2 failed (%s)\n", cli_errstr(&cli1)); + *shared_correct = False; } exit(0); @@ -2122,6 +2311,7 @@ static void run_oplock2(int dummy) if (cli_read(&cli1, fnum1, buf, 0, 4) != 4) { printf("read on fnum1 failed (%s)\n", cli_errstr(&cli1)); + correct = False; } /* Should now be at level II. */ @@ -2129,6 +2319,7 @@ static void run_oplock2(int dummy) if (!cli_lock(&cli1, fnum1, 0, 4, 0, READ_LOCK)) { printf("lock failed (%s)\n", cli_errstr(&cli1)); + correct = False; } cli_unlock(&cli1, fnum1, 0, 4); @@ -2137,6 +2328,7 @@ static void run_oplock2(int dummy) if (!cli_lock(&cli1, fnum1, 0, 4, 0, WRITE_LOCK)) { printf("lock failed (%s)\n", cli_errstr(&cli1)); + correct = False; } cli_unlock(&cli1, fnum1, 0, 4); @@ -2148,107 +2340,121 @@ static void run_oplock2(int dummy) #if 0 if (cli_write(&cli1, fnum1, 0, buf, 0, 4) != 4) { printf("write on fnum1 failed (%s)\n", cli_errstr(&cli1)); + correct = False; } #endif if (!cli_close(&cli1, fnum1)) { printf("close1 failed (%s)\n", cli_errstr(&cli1)); + correct = False; } sleep(4); if (!cli_unlink(&cli1, fname)) { printf("unlink failed (%s)\n", cli_errstr(&cli1)); + correct = False; } - close_connection(&cli1); + if (!close_connection(&cli1)) { + correct = False; + } + + if (!*shared_correct) { + correct = False; + } printf("finished oplock test 2\n"); + + return correct; } + /* Test delete on close semantics. */ -static void run_deletetest(int dummy) +static BOOL run_deletetest(int dummy) { - static struct cli_state cli1; - static struct cli_state cli2; - char *fname = "\\delete.file"; - int fnum1, fnum2; - - printf("starting delete test\n"); - - if (!open_connection(&cli1)) { - return; - } - + static struct cli_state cli1; + static struct cli_state cli2; + char *fname = "\\delete.file"; + int fnum1, fnum2; + BOOL correct = True; + + printf("starting delete test\n"); + + if (!open_connection(&cli1)) { + return False; + } + cli_sockopt(&cli1, sockops); - + /* Test 1 - this should *NOT* delete the file on close. */ - + cli_setatr(&cli1, fname, 0, 0); cli_unlink(&cli1, fname); - + fnum1 = cli_nt_create_full(&cli1, fname, GENERIC_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL, - FILE_SHARE_DELETE, FILE_OVERWRITE_IF, DELETE_ON_CLOSE_FLAG); - + FILE_SHARE_DELETE, FILE_OVERWRITE_IF, DELETE_ON_CLOSE_FLAG); + if (fnum1 == -1) { printf("[1] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; + } + + if (!cli_close(&cli1, fnum1)) { + printf("[1] close failed (%s)\n", cli_errstr(&cli1)); + return False; } - if (!cli_close(&cli1, fnum1)) { - printf("[1] close failed (%s)\n", cli_errstr(&cli1)); - return; - } - - fnum1 = cli_open(&cli1, fname, O_RDWR, DENY_NONE); - if (fnum1 == -1) { - printf("[1] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; - } - - if (!cli_close(&cli1, fnum1)) { - printf("[1] close failed (%s)\n", cli_errstr(&cli1)); - return; - } - + fnum1 = cli_open(&cli1, fname, O_RDWR, DENY_NONE); + if (fnum1 == -1) { + printf("[1] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); + return False; + } + + if (!cli_close(&cli1, fnum1)) { + printf("[1] close failed (%s)\n", cli_errstr(&cli1)); + return False; + } + printf("first delete on close test succeeded.\n"); - + /* Test 2 - this should delete the file on close. */ - + cli_setatr(&cli1, fname, 0, 0); cli_unlink(&cli1, fname); - + fnum1 = cli_nt_create_full(&cli1, fname, GENERIC_ALL_ACCESS, - FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0); - + FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0); + if (fnum1 == -1) { printf("[2] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } - + if (!cli_nt_delete_on_close(&cli1, fnum1, True)) { - printf("[2] setting delete_on_close failed (%s)\n", cli_errstr(&cli1)); - return; - } - - if (!cli_close(&cli1, fnum1)) { - printf("[2] close failed (%s)\n", cli_errstr(&cli1)); - return; - } - - fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_NONE); - if (fnum1 != -1) { + printf("[2] setting delete_on_close failed (%s)\n", cli_errstr(&cli1)); + return False; + } + + if (!cli_close(&cli1, fnum1)) { + printf("[2] close failed (%s)\n", cli_errstr(&cli1)); + return False; + } + + fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_NONE); + if (fnum1 != -1) { printf("[2] open of %s succeeded should have been deleted on close !\n", fname); if (!cli_close(&cli1, fnum1)) { printf("[2] close failed (%s)\n", cli_errstr(&cli1)); + correct = False; } cli_unlink(&cli1, fname); - } else + } else printf("second delete on close test succeeded.\n"); - - + + /* Test 3 - ... */ cli_setatr(&cli1, fname, 0, 0); cli_unlink(&cli1, fname); @@ -2258,7 +2464,7 @@ static void run_deletetest(int dummy) if (fnum1 == -1) { printf("[3] open - 1 of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } /* This should fail with a sharing violation - open for delete is only compatible @@ -2269,7 +2475,7 @@ static void run_deletetest(int dummy) if (fnum2 != -1) { printf("[3] open - 2 of %s succeeded - should have failed.\n", fname); - return; + return False; } /* This should succeed. */ @@ -2279,34 +2485,35 @@ static void run_deletetest(int dummy) if (fnum2 == -1) { printf("[3] open - 2 of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } if (!cli_nt_delete_on_close(&cli1, fnum1, True)) { - printf("[3] setting delete_on_close failed (%s)\n", cli_errstr(&cli1)); - return; - } - - if (!cli_close(&cli1, fnum1)) { - printf("[3] close 1 failed (%s)\n", cli_errstr(&cli1)); - return; - } - - if (!cli_close(&cli1, fnum2)) { - printf("[3] close 2 failed (%s)\n", cli_errstr(&cli1)); - return; - } - + printf("[3] setting delete_on_close failed (%s)\n", cli_errstr(&cli1)); + return False; + } + + if (!cli_close(&cli1, fnum1)) { + printf("[3] close 1 failed (%s)\n", cli_errstr(&cli1)); + return False; + } + + if (!cli_close(&cli1, fnum2)) { + printf("[3] close 2 failed (%s)\n", cli_errstr(&cli1)); + return False; + } + /* This should fail - file should no longer be there. */ - fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_NONE); - if (fnum1 != -1) { + fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_NONE); + if (fnum1 != -1) { printf("[3] open of %s succeeded should have been deleted on close !\n", fname); if (!cli_close(&cli1, fnum1)) { printf("[3] close failed (%s)\n", cli_errstr(&cli1)); } cli_unlink(&cli1, fname); - } else + correct = False; + } else printf("third delete on close test succeeded.\n"); /* Test 4 ... */ @@ -2318,7 +2525,7 @@ static void run_deletetest(int dummy) if (fnum1 == -1) { printf("[4] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } /* This should succeed. */ @@ -2326,339 +2533,349 @@ static void run_deletetest(int dummy) FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OPEN, 0); if (fnum2 == -1) { printf("[4] open - 2 of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } - - if (!cli_close(&cli1, fnum2)) { - printf("[4] close - 1 failed (%s)\n", cli_errstr(&cli1)); - return; - } - + + if (!cli_close(&cli1, fnum2)) { + printf("[4] close - 1 failed (%s)\n", cli_errstr(&cli1)); + return False; + } + if (!cli_nt_delete_on_close(&cli1, fnum1, True)) { - printf("[4] setting delete_on_close failed (%s)\n", cli_errstr(&cli1)); - return; - } - + printf("[4] setting delete_on_close failed (%s)\n", cli_errstr(&cli1)); + return False; + } + /* This should fail - no more opens once delete on close set. */ fnum2 = cli_nt_create_full(&cli1, fname, GENERIC_READ_ACCESS, - FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OPEN, 0); + FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OPEN, 0); if (fnum2 != -1) { printf("[4] open - 3 of %s succeeded ! Should have failed.\n", fname ); - return; - } else + return False; + } else printf("fourth delete on close test succeeded.\n"); - - if (!cli_close(&cli1, fnum1)) { - printf("[4] close - 2 failed (%s)\n", cli_errstr(&cli1)); - return; - } - + + if (!cli_close(&cli1, fnum1)) { + printf("[4] close - 2 failed (%s)\n", cli_errstr(&cli1)); + return False; + } + /* Test 5 ... */ cli_setatr(&cli1, fname, 0, 0); cli_unlink(&cli1, fname); - - fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT, DENY_NONE); + + fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { printf("[5] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } /* This should fail - only allowed on NT opens with DELETE access. */ if (cli_nt_delete_on_close(&cli1, fnum1, True)) { - printf("[5] setting delete_on_close on OpenX file succeeded - should fail !\n"); - return; - } - - if (!cli_close(&cli1, fnum1)) { - printf("[5] close - 2 failed (%s)\n", cli_errstr(&cli1)); - return; - } + printf("[5] setting delete_on_close on OpenX file succeeded - should fail !\n"); + return False; + } + if (!cli_close(&cli1, fnum1)) { + printf("[5] close - 2 failed (%s)\n", cli_errstr(&cli1)); + return False; + } + printf("fifth delete on close test succeeded.\n"); - + /* Test 6 ... */ cli_setatr(&cli1, fname, 0, 0); cli_unlink(&cli1, fname); - + fnum1 = cli_nt_create_full(&cli1, fname, FILE_READ_DATA|FILE_WRITE_DATA, - FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, - FILE_OVERWRITE_IF, 0); - + FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, + FILE_OVERWRITE_IF, 0); + if (fnum1 == -1) { printf("[6] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } - + /* This should fail - only allowed on NT opens with DELETE access. */ - + if (cli_nt_delete_on_close(&cli1, fnum1, True)) { - printf("[6] setting delete_on_close on file with no delete access succeeded - should fail !\n"); - return; - } + printf("[6] setting delete_on_close on file with no delete access succeeded - should fail !\n"); + return False; + } - if (!cli_close(&cli1, fnum1)) { - printf("[6] close - 2 failed (%s)\n", cli_errstr(&cli1)); - return; - } + if (!cli_close(&cli1, fnum1)) { + printf("[6] close - 2 failed (%s)\n", cli_errstr(&cli1)); + return False; + } printf("sixth delete on close test succeeded.\n"); - + /* Test 7 ... */ cli_setatr(&cli1, fname, 0, 0); cli_unlink(&cli1, fname); - + fnum1 = cli_nt_create_full(&cli1, fname, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS, - FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF, 0); + FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF, 0); if (fnum1 == -1) { printf("[7] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } if (!cli_nt_delete_on_close(&cli1, fnum1, True)) { - printf("[7] setting delete_on_close on file failed !\n"); - return; - } - + printf("[7] setting delete_on_close on file failed !\n"); + return False; + } + if (!cli_nt_delete_on_close(&cli1, fnum1, False)) { - printf("[7] unsetting delete_on_close on file failed !\n"); - return; - } - - if (!cli_close(&cli1, fnum1)) { - printf("[7] close - 2 failed (%s)\n", cli_errstr(&cli1)); - return; - } + printf("[7] unsetting delete_on_close on file failed !\n"); + return False; + } + if (!cli_close(&cli1, fnum1)) { + printf("[7] close - 2 failed (%s)\n", cli_errstr(&cli1)); + return False; + } + /* This next open should succeed - we reset the flag. */ - - fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_NONE); + + fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_NONE); if (fnum1 == -1) { printf("[5] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } - if (!cli_close(&cli1, fnum1)) { - printf("[7] close - 2 failed (%s)\n", cli_errstr(&cli1)); - return; - } + if (!cli_close(&cli1, fnum1)) { + printf("[7] close - 2 failed (%s)\n", cli_errstr(&cli1)); + return False; + } printf("seventh delete on close test succeeded.\n"); - + /* Test 7 ... */ cli_setatr(&cli1, fname, 0, 0); cli_unlink(&cli1, fname); - - if (!open_connection(&cli2)) { + + if (!open_connection(&cli2)) { printf("[8] failed to open second connection.\n"); - return; - } + return False; + } cli_sockopt(&cli1, sockops); - + fnum1 = cli_nt_create_full(&cli1, fname, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS, - FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0); - + FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0); + if (fnum1 == -1) { printf("[8] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } fnum2 = cli_nt_create_full(&cli2, fname, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS, - FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OPEN, 0); - + FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OPEN, 0); + if (fnum2 == -1) { printf("[8] open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; + return False; } if (!cli_nt_delete_on_close(&cli1, fnum1, True)) { - printf("[8] setting delete_on_close on file failed !\n"); - return; - } - - if (!cli_close(&cli1, fnum1)) { - printf("[8] close - 1 failed (%s)\n", cli_errstr(&cli1)); - return; - } + printf("[8] setting delete_on_close on file failed !\n"); + return False; + } + + if (!cli_close(&cli1, fnum1)) { + printf("[8] close - 1 failed (%s)\n", cli_errstr(&cli1)); + return False; + } - if (!cli_close(&cli2, fnum2)) { - printf("[8] close - 2 failed (%s)\n", cli_errstr(&cli2)); - return; - } + if (!cli_close(&cli2, fnum2)) { + printf("[8] close - 2 failed (%s)\n", cli_errstr(&cli2)); + return False; + } /* This should fail.. */ - fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_NONE); - if (fnum1 != -1) { + fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_NONE); + if (fnum1 != -1) { printf("[8] open of %s succeeded should have been deleted on close !\n", fname); if (!cli_close(&cli1, fnum1)) { printf("[8] close failed (%s)\n", cli_errstr(&cli1)); } cli_unlink(&cli1, fname); - } else + correct = False; + } else printf("eighth delete on close test succeeded.\n"); - printf("finished delete test\n"); - + printf("finished delete test\n"); + cli_setatr(&cli1, fname, 0, 0); cli_unlink(&cli1, fname); - - close_connection(&cli1); - close_connection(&cli2); + + if (!close_connection(&cli1)) { + correct = False; + } + if (!close_connection(&cli2)) { + correct = False; + } + return correct; } /* Test open mode returns on read-only files. */ -static void run_opentest(int dummy) +static BOOL run_opentest(int dummy) { - static struct cli_state cli1; - char *fname = "\\readonly.file"; - int fnum1, fnum2; + static struct cli_state cli1; + char *fname = "\\readonly.file"; + int fnum1, fnum2; uint8 eclass; uint32 errnum; char buf[20]; size_t fsize; + BOOL correct = True; - printf("starting open test\n"); - - if (!open_connection(&cli1)) { - return; - } - + printf("starting open test\n"); + + if (!open_connection(&cli1)) { + return False; + } + cli_setatr(&cli1, fname, 0, 0); - cli_unlink(&cli1, fname); - - cli_sockopt(&cli1, sockops); - - fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); - if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; - } - - if (!cli_close(&cli1, fnum1)) { - printf("close2 failed (%s)\n", cli_errstr(&cli1)); - return; - } + cli_unlink(&cli1, fname); + + cli_sockopt(&cli1, sockops); + + fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); + if (fnum1 == -1) { + printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); + return False; + } + if (!cli_close(&cli1, fnum1)) { + printf("close2 failed (%s)\n", cli_errstr(&cli1)); + return False; + } + if (!cli_setatr(&cli1, fname, aRONLY, 0)) { printf("cli_setatr failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } - - fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_WRITE); - if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; - } - + + fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_WRITE); + if (fnum1 == -1) { + printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); + return False; + } + /* This will fail - but the error should be ERRnoaccess, not ERRbadshare. */ - fnum2 = cli_open(&cli1, fname, O_RDWR, DENY_ALL); - + fnum2 = cli_open(&cli1, fname, O_RDWR, DENY_ALL); + cli_error( &cli1, &eclass, &errnum, NULL); - + if (eclass != ERRDOS || errnum != ERRnoaccess) { printf("wrong error code (%x,%x) = %s\n", (unsigned int)eclass, - (unsigned int)errnum, cli_errstr(&cli1) ); + (unsigned int)errnum, cli_errstr(&cli1) ); + correct = False; } else { printf("correct error code ERRDOS/ERRnoaccess returned\n"); } - - printf("finished open test 1\n"); - + + printf("finished open test 1\n"); + cli_close(&cli1, fnum1); - + /* Now try not readonly and ensure ERRbadshare is returned. */ - + cli_setatr(&cli1, fname, 0, 0); - - fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_WRITE); - if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; - } - + + fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_WRITE); + if (fnum1 == -1) { + printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1)); + return False; + } + /* This will fail - but the error should be ERRshare. */ - fnum2 = cli_open(&cli1, fname, O_RDWR, DENY_ALL); - + fnum2 = cli_open(&cli1, fname, O_RDWR, DENY_ALL); + cli_error( &cli1, &eclass, &errnum, NULL); if (eclass != ERRDOS || errnum != ERRbadshare) { printf("wrong error code (%x,%x) = %s\n", (unsigned int)eclass, - (unsigned int)errnum, cli_errstr(&cli1) ); + (unsigned int)errnum, cli_errstr(&cli1) ); + correct = False; } else { printf("correct error code ERRDOS/ERRbadshare returned\n"); } - - if (!cli_close(&cli1, fnum1)) { - printf("close2 failed (%s)\n", cli_errstr(&cli1)); - return; - } - + + if (!cli_close(&cli1, fnum1)) { + printf("close2 failed (%s)\n", cli_errstr(&cli1)); + return False; + } + cli_unlink(&cli1, fname); - - printf("finished open test 2\n"); - + + printf("finished open test 2\n"); + /* Test truncate open disposition on file opened for read. */ - - fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); - if (fnum1 == -1) { - printf("(3) open (1) of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; - } - + + fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); + if (fnum1 == -1) { + printf("(3) open (1) of %s failed (%s)\n", fname, cli_errstr(&cli1)); + return False; + } + /* write 20 bytes. */ - + memset(buf, '\0', 20); if (cli_write(&cli1, fnum1, 0, buf, 0, 20) != 20) { printf("write failed (%s)\n", cli_errstr(&cli1)); + correct = False; } - if (!cli_close(&cli1, fnum1)) { - printf("(3) close1 failed (%s)\n", cli_errstr(&cli1)); - return; - } - + if (!cli_close(&cli1, fnum1)) { + printf("(3) close1 failed (%s)\n", cli_errstr(&cli1)); + return False; + } + /* Ensure size == 20. */ if (!cli_getatr(&cli1, fname, NULL, &fsize, NULL)) { printf("(3) getatr failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } - + if (fsize != 20) { printf("(3) file size != 20\n"); - return; + return False; } /* Now test if we can truncate a file opened for readonly. */ - + fnum1 = cli_open(&cli1, fname, O_RDONLY|O_TRUNC, DENY_NONE); - if (fnum1 == -1) { - printf("(3) open (2) of %s failed (%s)\n", fname, cli_errstr(&cli1)); - return; - } - - if (!cli_close(&cli1, fnum1)) { - printf("close2 failed (%s)\n", cli_errstr(&cli1)); - return; - } + if (fnum1 == -1) { + printf("(3) open (2) of %s failed (%s)\n", fname, cli_errstr(&cli1)); + return False; + } + + if (!cli_close(&cli1, fnum1)) { + printf("close2 failed (%s)\n", cli_errstr(&cli1)); + return False; + } /* Ensure size == 0. */ if (!cli_getatr(&cli1, fname, NULL, &fsize, NULL)) { printf("(3) getatr failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } if (fsize != 0) { printf("(3) file size != 0\n"); - return; + return False; } - printf("finished open test 3\n"); - + printf("finished open test 3\n"); + cli_unlink(&cli1, fname); @@ -2668,15 +2885,18 @@ static void run_opentest(int dummy) fnum1 = cli_ctemp(&cli1, "\\", &tmp_path); if (fnum1 == -1) { printf("ctemp failed (%s)\n", cli_errstr(&cli1)); - return; + return False; } printf("ctemp gave path %s\n", tmp_path); cli_close(&cli1, fnum1); cli_unlink(&cli1, tmp_path); } - - close_connection(&cli1); - + + if (!close_connection(&cli1)) { + correct = False; + } + + return correct; } static void list_fn(file_info *finfo, const char *name, void *state) @@ -2687,17 +2907,18 @@ static void list_fn(file_info *finfo, const char *name, void *state) /* test directory listing speed */ -static void run_dirtest(int dummy) +static BOOL run_dirtest(int dummy) { int i; static struct cli_state cli; int fnum; double t1; + BOOL correct = True; printf("starting directory test\n"); if (!open_connection(&cli)) { - return; + return False; } cli_sockopt(&cli, sockops); @@ -2709,7 +2930,7 @@ static void run_dirtest(int dummy) fnum = cli_open(&cli, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { fprintf(stderr,"Failed to open %s\n", fname); - return; + return False; } cli_close(&cli, fnum); } @@ -2729,31 +2950,43 @@ static void run_dirtest(int dummy) cli_unlink(&cli, fname); } - close_connection(&cli); + if (!close_connection(&cli)) { + correct = False; + } printf("finished dirtest\n"); + + return correct; } -static double create_procs(void (*fn)(int)) +static double create_procs(BOOL (*fn)(int), BOOL *result) { int i, status; - volatile int *child_status; + volatile pid_t *child_status; + volatile BOOL *child_status_out; int synccount; int tries = 8; - start_timer(); - synccount = 0; - child_status = (volatile int *)shm_setup(sizeof(int)*nprocs); + child_status = (volatile pid_t *)shm_setup(sizeof(pid_t)*nprocs); if (!child_status) { printf("Failed to setup shared memory\n"); - return end_timer(); + return -1; } - memset((char *)child_status, 0, sizeof(int)*nprocs); + child_status_out = (volatile BOOL *)shm_setup(sizeof(BOOL)*nprocs); + if (!child_status_out) { + printf("Failed to setup result status shared memory\n"); + return -1; + } + + memset(child_status, 0, sizeof(pid_t)*nprocs); + memset(child_status_out, True, sizeof(BOOL)*nprocs); + + start_timer(); for (i=0;i<nprocs;i++) { procnum = i; @@ -2770,14 +3003,14 @@ static double create_procs(void (*fn)(int)) printf("pid %d failed to start\n", (int)getpid()); _exit(1); } - msleep(10); + msleep(10); } child_status[i] = getpid(); while (child_status[i]) msleep(2); - fn(i); + child_status_out[i] = fn(i); _exit(0); } } @@ -2793,6 +3026,7 @@ static double create_procs(void (*fn)(int)) if (synccount != nprocs) { printf("FAILED TO START %d CLIENTS (started %d)\n", nprocs, synccount); + *result = False; return end_timer(); } @@ -2809,7 +3043,14 @@ static double create_procs(void (*fn)(int)) waitpid(0, &status, 0); printf("*"); } + printf("\n"); + + for (i=0;i<nprocs;i++) { + if (!child_status_out[i]) { + *result = False; + } + } return end_timer(); } @@ -2818,7 +3059,7 @@ static double create_procs(void (*fn)(int)) static struct { char *name; - void (*fn)(int); + BOOL (*fn)(int); unsigned flags; } torture_ops[] = { {"FDPASS", run_fdpasstest, 0}, @@ -2856,9 +3097,12 @@ static struct { /**************************************************************************** run a specified test or "ALL" ****************************************************************************/ -static void run_test(char *name) +static BOOL run_test(char *name) { + BOOL ret = True; + BOOL result = True; int i; + double t; if (strequal(name,"ALL")) { for (i=0;torture_ops[i].name;i++) { run_test(torture_ops[i].name); @@ -2866,20 +3110,30 @@ static void run_test(char *name) } for (i=0;torture_ops[i].name;i++) { - fstrcpy(randomfname, "\\XXXXXXX"); - mktemp(randomfname); + snprintf(randomfname, sizeof(randomfname), "\\XX%x", + (unsigned)random()); if (strequal(name, torture_ops[i].name)) { - start_timer(); printf("Running %s\n", name); if (torture_ops[i].flags & FLAG_MULTIPROC) { - create_procs(torture_ops[i].fn); + t = create_procs(torture_ops[i].fn, &result); + if (!result) { + ret = False; + printf("TEST %s FAILED!\n", name); + } + } else { - torture_ops[i].fn(0); + start_timer(); + if (!torture_ops[i].fn(0)) { + ret = False; + printf("TEST %s FAILED!\n", name); + } + t = end_timer(); } - printf("%s took %g secs\n\n", name, end_timer()); + printf("%s took %g secs\n\n", name, t); } } + return ret; } @@ -2927,15 +3181,19 @@ static void usage(void) extern int optind; extern FILE *dbf; static pstring servicesf = CONFIGFILE; + BOOL correct = True; dbf = stdout; +#ifdef HAVE_SETBUFFER setbuffer(stdout, NULL, 0); - +#endif charset_initialise(); - + codepage_initialise(lp_client_code_page()); - + + codepage_initialise(lp_client_code_page()); + lp_load(servicesf,True,False,False); load_interfaces(); @@ -3025,12 +3283,18 @@ static void usage(void) host, share, username, myname); if (argc == 1) { - run_test("ALL"); + correct = run_test("ALL"); } else { for (i=1;i<argc;i++) { - run_test(argv[i]); + if (!run_test(argv[i])) { + correct = False; + } } } - return(0); + if (correct) { + return(0); + } else { + return(1); + } } |