s4 torture: Convert an error to a warning in RAW-OPLOCK-BATCH22
authorTim Prouty <tprouty@samba.org>
Thu, 3 Dec 2009 02:39:05 +0000 (18:39 -0800)
committerTim Prouty <tprouty@samba.org>
Fri, 4 Dec 2009 02:54:52 +0000 (18:54 -0800)
Some servers choose to mark a client as bad if they fail an oplock
break request by timing out (win7 is an example).  Once the client is
marked as bad, future oplock requests will timeout instantly.  This
causes subsequent runs of this test to fail, so rather than erroring
out as a failure, a warning is printed instead.

There is also a bug in w2k3 where it was incorrectly returning
contending a share mode lock.  It worked in XP and has been re-fixed
in win7.

This can also now be run against samba3.

source4/torture/raw/oplock.c

index 85362d126f7a2d92a3c7e252b853d450ccce048f..2531989b8c5cdceef42e7c0fbc2a9010290bae79 100644 (file)
                ret = false; \
        }} while (0)
 
-#define CHECK_RANGE(v, min, max) do { \
-       if ((v) < (min) || (v) > (max)) { \
-               torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got %d - should be between %d and %d\n", \
-                               __location__, #v, (int)v, (int)min, (int)max); \
-               ret = false; \
+#define CHECK_RANGE(v, min, max) do {                                  \
+       if ((v) < (min) || (v) > (max)) {                               \
+               torture_warning(tctx, "(%s): wrong value for %s got "   \
+                   "%d - should be between %d and %d\n",               \
+                   __location__, #v, (int)v, (int)min, (int)max);      \
        }} while (0)
 
 #define CHECK_STRMATCH(v, correct) do { \
@@ -2632,10 +2632,6 @@ static bool test_raw_oplock_batch22(struct torture_context *tctx, struct smbcli_
        int timeout = torture_setting_int(tctx, "oplocktimeout", 30);
        int te;
 
-       if (torture_setting_bool(tctx, "samba3", false)) {
-               torture_skip(tctx, "BATCH22 disabled against samba3\n");
-       }
-
        if (!torture_setup_dir(cli1, BASEDIR)) {
                return false;
        }
@@ -2644,7 +2640,6 @@ static bool test_raw_oplock_batch22(struct torture_context *tctx, struct smbcli_
        smbcli_unlink(cli1->tree, fname);
 
        smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
-
        /*
          base ntcreatex parms
        */
@@ -2681,9 +2676,23 @@ static bool test_raw_oplock_batch22(struct torture_context *tctx, struct smbcli_
        tv = timeval_current();
        smbcli_oplock_handler(cli1->transport, oplock_handler_timeout, cli1->tree);
        status = smb_raw_open(cli1->tree, tctx, &io);
-       CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
+
+       if (TARGET_IS_W2K3(tctx)) {
+               /* 2k3 has an issue here. xp/win7 are ok. */
+               CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
+       } else {
+               CHECK_STATUS(tctx, status, NT_STATUS_OK);
+       }
+
        torture_wait_for_oplock_break(tctx);
        te = (int)timeval_elapsed(&tv);
+
+       /*
+        * Some servers detect clients that let oplocks timeout, so this check
+        * only shows a warning message instead failing the test to eliminate
+        * failures from repeated runs of the test.  This isn't ideal, but
+        * it's better than not running the test at all.
+        */
        CHECK_RANGE(te, timeout - 1, timeout + 15);
 
        CHECK_VAL(break_info.count, 1);
@@ -2698,7 +2707,13 @@ static bool test_raw_oplock_batch22(struct torture_context *tctx, struct smbcli_
        smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
        status = smb_raw_open(cli1->tree, tctx, &io);
        CHECK_STATUS(tctx, status, NT_STATUS_OK);
-       CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
+       if (TARGET_IS_SAMBA3(tctx)) {
+               /* samba3 doesn't grant additional oplocks to bad clients. */
+               CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN);
+       } else {
+               CHECK_VAL(io.ntcreatex.out.oplock_level,
+                         LEVEL_II_OPLOCK_RETURN);
+       }
        torture_wait_for_oplock_break(tctx);
        te = (int)timeval_elapsed(&tv);
        /* it should come in without delay */