r10656: BIG merge from trunk. Features not copied over
[amitay/samba.git] / source3 / torture / torture.c
index 84755a781a463f18067fd97ab6351b5bc51eccfb..8ad567f17781c79682298d1317346afe43c2b3a7 100644 (file)
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-#define NO_SYSLOG
-
 #include "includes.h"
 
+extern char *optarg;
+extern int optind;
+
 static fstring host, workgroup, share, password, username, myname;
 static int max_protocol = PROTOCOL_NT1;
 static const char *sockops="TCP_NODELAY";
@@ -207,16 +208,16 @@ static BOOL check_error(int line, struct cli_state *c,
                        uint8 eclass, uint32 ecode, NTSTATUS nterr)
 {
         if (cli_is_dos_error(c)) {
-                uint8 class;
+                uint8 cclass;
                 uint32 num;
 
                 /* Check DOS error */
 
-                cli_dos_error(c, &class, &num);
+                cli_dos_error(c, &cclass, &num);
 
-                if (eclass != class || ecode != num) {
+                if (eclass != cclass || ecode != num) {
                         printf("unexpected error code class=%d code=%d\n", 
-                               (int)class, (int)num);
+                               (int)cclass, (int)num);
                         printf(" expected %d/%d %s (line=%d)\n", 
                                (int)eclass, (int)ecode, nt_errstr(nterr), line);
                         return False;
@@ -537,7 +538,7 @@ static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2)
 static BOOL run_readwritetest(int dummy)
 {
        static struct cli_state *cli1, *cli2;
-       BOOL test1, test2;
+       BOOL test1, test2 = False;
 
        if (!torture_open_connection(&cli1) || !torture_open_connection(&cli2)) {
                return False;
@@ -590,7 +591,7 @@ static BOOL run_readwritelarge(int dummy)
        static struct cli_state *cli1;
        int fnum1;
        const char *lockfname = "\\large.dat";
-       size_t fsize;
+       SMB_OFF_T fsize;
        char buf[126*1024];
        BOOL correct = True;
  
@@ -697,7 +698,6 @@ static BOOL run_netbench(int client)
 {
        struct cli_state *cli;
        int i;
-       fstring fname;
        pstring line;
        char cname[20];
        FILE *f;
@@ -712,7 +712,7 @@ static BOOL run_netbench(int client)
 
        nb_setup(cli);
 
-       slprintf(cname,sizeof(fname), "client%d", client);
+       slprintf(cname,sizeof(cname)-1, "client%d", client);
 
        f = fopen(client_txt, "r");
 
@@ -2111,7 +2111,7 @@ test how many open files this server supports on the one socket
 static BOOL run_maxfidtest(int dummy)
 {
        struct cli_state *cli;
-       const char *template = "\\maxfid.%d.%d";
+       const char *ftemplate = "\\maxfid.%d.%d";
        fstring fname;
        int fnums[0x11000], i;
        int retries=4;
@@ -2127,7 +2127,7 @@ static BOOL run_maxfidtest(int dummy)
        cli_sockopt(cli, sockops);
 
        for (i=0; i<0x11000; i++) {
-               slprintf(fname,sizeof(fname)-1,template, i,(int)getpid());
+               slprintf(fname,sizeof(fname)-1,ftemplate, i,(int)getpid());
                if ((fnums[i] = cli_open(cli, fname, 
                                        O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) ==
                    -1) {
@@ -2143,7 +2143,7 @@ static BOOL run_maxfidtest(int dummy)
 
        printf("cleaning up\n");
        for (;i>=0;i--) {
-               slprintf(fname,sizeof(fname)-1,template, i,(int)getpid());
+               slprintf(fname,sizeof(fname)-1,ftemplate, i,(int)getpid());
                cli_close(cli, fnums[i]);
                if (!cli_unlink(cli, fname)) {
                        printf("unlink of %s failed (%s)\n", 
@@ -2360,7 +2360,7 @@ static BOOL run_trans2test(int dummy)
 {
        struct cli_state *cli;
        int fnum;
-       size_t size;
+       SMB_OFF_T size;
        time_t c_time, a_time, m_time, w_time, m_time2;
        const char *fname = "\\trans2.tst";
        const char *dname = "\\trans2";
@@ -2666,9 +2666,10 @@ static BOOL run_oplock2(int dummy)
 
        sleep(2);
 
-       /* Ensure cli1 processes the break. */
+       /* Ensure cli1 processes the break. Empty file should always return 0
+        * bytes.  */
 
-       if (cli_read(cli1, fnum1, buf, 0, 4) != 4) {
+       if (cli_read(cli1, fnum1, buf, 0, 4) != 0) {
                printf("read on fnum1 failed (%s)\n", cli_errstr(cli1));
                correct = False;
        }
@@ -3590,7 +3591,7 @@ static BOOL run_opentest(int dummy)
        const char *fname = "\\readonly.file";
        int fnum1, fnum2;
        char buf[20];
-       size_t fsize;
+       SMB_OFF_T fsize;
        BOOL correct = True;
        char *tmp_path;
 
@@ -4860,6 +4861,9 @@ static void usage(void)
 {
        int i;
 
+       printf("WARNING samba4 test suite is much more complete nowadays.\n");
+       printf("Please use samba4 torture.\n\n");
+
        printf("Usage: smbtorture //server/share <options> TEST1 TEST2 ...\n");
 
        printf("\t-d debuglevel\n");
@@ -4898,8 +4902,6 @@ static void usage(void)
        char *p;
        int gotuser = 0;
        int gotpass = 0;
-       extern char *optarg;
-       extern int optind;
        BOOL correct = True;
 
        dbf = x_stdout;