[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Fri Oct 3 03:01:02 MDT 2014


The branch, master has been updated
       via  5e43cec Fix typo in samba-tool manpage
       via  ca9e46d s4:torture:basic: eliminate potential for false failures in delayed_write_update1c
       via  95d333f s4:torture:basic: use assert in the second loop in delayed_write_update1b
       via  8d19876 s4:torture:basic: add check for size after initial write in delayed_write_update1c
       via  874788f s4:torture:basic: add update into past as error condition in delayed_write_update1c
       via  884f747 s4:torture:basic: make use of torture_assert macros in delayed_write_update1c
       via  641a8a2 s4:torture:basic: whitespace cleanup in delayed_write_update1c
       via  970ae65 s4:torture:basic: eliminate potential for false failures in delayed_write_update1b
       via  2907950 s4:torture:basic: use assert in the second loop in delayed_write_update1b
       via  08432cd s4:torture:basic: add check for size after initial write in delayed_write_update1b
       via  339f2fb s4:torture:basic: add update into past as error condition in delayed_write_update1b
       via  dbb3a54 s4:torture:basic: make use of torture_assert macros in delayed_write_update1b
       via  c0cbad7 s4:torture:basic: whitespace cleanup in delayed_write_update1b
       via  372d91b s4:torture:basic: eliminate potential for false failures in delayed_write_update1a
       via  2e1cb12 s4:torture:basic: use assert in the second loop in delayed_write_update1a
       via  de8dcde s4:torture:basic: add check for size after initial write in delayed_write_update1a
       via  17c78b9 s4:torture:basic: add update into past as error condition in delayed_write_update1a
       via  218a14f s4:torture:basic: make use of torture_assert macros in delayed_write_update1a
       via  e99a550 s4:torture:basic: fix spacing in the delayed_write_update1a test.
       via  1d2d0bc s4:torture:basic: eliminate potential for false failures in delayed_write_update1
       via  bc93c82 s4:torture:basic: use assert in the second loop in delayed_write_update1
       via  91c5940 s4:torture:basic: add check for size after initial write to delayed_write_update1
       via  32dee45 s4:torture:basic: add update into past as error condition in delayed_write_update1
       via  4808e3d s4:torture:basic: make use of torture_assert macros in delayed_write_update1
       via  5d8a498 s4:torture:basic: whitespace fix in delayed_write_update1
       via  dc9ea4f8 s4:torture:basic: remove two unused variables from delayed_write_update3c
       via  4df9406 s4:torture:basic: use torture_assert macros in delayed_write_update
       via  6cb9d97 s4:torture:basic: whitespace cleanup in delayed_write_update
       via  23cd60f torture: add torture_assert_u64_not_equal()
       via  fae589b torture: add torture_assert_int_not_equal
      from  7f242d0 idl: declare frstrans_VersionVector public so that we can dump it to blob and vice versa

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5e43cec37548c510f6b135b58a436e8f8e7544b4
Author: Андрей Черепанов <cas at altlinux.ru>
Date:   Thu Oct 2 19:23:09 2014 +0400

    Fix typo in samba-tool manpage
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Fri Oct  3 11:00:58 CEST 2014 on sn-devel-104

commit ca9e46d1309c08b96a58b4260ff1512020626b12
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 17:15:04 2014 +0200

    s4:torture:basic: eliminate potential for false failures in delayed_write_update1c
    
    We want to test that the write did update the write time immediately.
    We check this by getting the file info in a loop for a few seconds.
    There are several result cases:
    
    - the server updated the write time immediately - success
    - the server updated the write time, but not immediately - failure
    - the server did not update the write time - failure
    
    The loop is only there to be able to discern between the two
    failure cases. The check for success is whether the first
    getinfo has reportet the updated write time.
    
    The potential for false failures was the additional timing check.
    So if the first fileinfo call just took too long (e.g. due to a
    busy system), this was reported as failure.
    
    This patch should eliminate interemittent autobuild failures.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 95d333f03dcd07f62b06ea34f7d1421b4cc913bc
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 17:13:21 2014 +0200

    s4:torture:basic: use assert in the second loop in delayed_write_update1b
    
    We can hence replace the assert after the loop by a success torture_comment.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 8d198769d4550f26c7c6efb34316128d1017a18a
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 17:10:32 2014 +0200

    s4:torture:basic: add check for size after initial write in delayed_write_update1c
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 874788f4ce8f6d508f2327dfd93de07921d20d05
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 17:09:18 2014 +0200

    s4:torture:basic: add update into past as error condition in delayed_write_update1c
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 884f7476785a519772c5f871704159207c19847b
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 17:08:12 2014 +0200

    s4:torture:basic: make use of torture_assert macros in delayed_write_update1c
    
    This does not change the logic except for adding early
    returns in failure cases.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 641a8a25752d6c0faead3939784a3f665de03645
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 17:02:38 2014 +0200

    s4:torture:basic: whitespace cleanup in delayed_write_update1c
    
    no diff with git diff -w
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 970ae65a9dd9a2d64937b805e7afefef204ee4b4
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 16:48:40 2014 +0200

    s4:torture:basic: eliminate potential for false failures in delayed_write_update1b
    
    We want to test that the write did update the write time immediately.
    We check this by getting the file info in a loop for a few seconds.
    There are several result cases:
    
    - the server updated the write time immediately - success
    - the server updated the write time, but not immediately - failure
    - the server did not update the write time - failure
    
    The loop is only there to be able to discern between the two
    failure cases. The check for success is whether the first
    getinfo has reportet the updated write time.
    
    The potential for false failures was the additional timing check.
    So if the first fileinfo call just took too long (e.g. due to a
    busy system), this was reported as failure.
    
    This patch should eliminate interemittent autobuild failures.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 2907950f13506a0ca2160b72824e315772a4424f
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 16:46:18 2014 +0200

    s4:torture:basic: use assert in the second loop in delayed_write_update1b
    
    We can hence replace the assert after the loop by a success torture_comment.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 08432cd88f8764eb87545f193f8db4750104bfce
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 16:53:26 2014 +0200

    s4:torture:basic: add check for size after initial write in delayed_write_update1b
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 339f2fb589a9edcc26125d9cfa43035568a041e3
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 16:44:34 2014 +0200

    s4:torture:basic: add update into past as error condition in delayed_write_update1b
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit dbb3a546a5cc7919c08782489b5a1b24a4a22c53
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 16:40:26 2014 +0200

    s4:torture:basic: make use of torture_assert macros in delayed_write_update1b
    
    This does not change the logic except for adding early
    returns in failure cases.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit c0cbad78923f72b3d7991e086f2455e276bd0cb0
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 16:34:19 2014 +0200

    s4:torture:basic: whitespace cleanup in delayed_write_update1b
    
    no diff with git diff -w
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 372d91b38be45a11482bea5e464f1012384012ee
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 13:56:43 2014 +0200

    s4:torture:basic: eliminate potential for false failures in delayed_write_update1a
    
    We want to test that the write did update the write time immediately.
    We check this by getting the file info in a loop for a few seconds.
    There are several result cases:
    
    - the server updated the write time immediately - success
    - the server updated the write time, but not immediately - failure
    - the server did not update the write time - failure
    
    The loop is only there to be able to discern between the two
    failure cases. The check for success is whether the first
    getinfo has reportet the updated write time.
    
    The potential for false failures was the additional timing check.
    So if the first fileinfo call just took too long (e.g. due to a
    busy system), this was reported as failure.
    
    This patch should eliminate interemittent autobuild failures.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 2e1cb1284820caa5920d26f6b859b0287e82670c
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 13:46:29 2014 +0200

    s4:torture:basic: use assert in the second loop in delayed_write_update1a
    
    We can hence replace the assert after the loop by a success torture_comment.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit de8dcdef3ee42e88a50fe689e11d0b4448019ba5
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 16:33:13 2014 +0200

    s4:torture:basic: add check for size after initial write in delayed_write_update1a
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 17c78b9711468c2ad8f3f717d2518511d48cdd28
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 15:49:07 2014 +0200

    s4:torture:basic: add update into past as error condition in delayed_write_update1a
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 218a14f1a396a1511a5a69436f8c037de3606642
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 13:37:02 2014 +0200

    s4:torture:basic: make use of torture_assert macros in delayed_write_update1a
    
    This does not change the logic except for adding early
    returns in failure cases.
    But it makes the code more compact and obvious.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit e99a550ccb3a42606150f6eba39222939edf26b2
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 13:32:59 2014 +0200

    s4:torture:basic: fix spacing in the delayed_write_update1a test.
    
    No diff visible with git diff -w
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 1d2d0bc78f080693a11ed2a9a90a4f67d22f6edf
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 16:11:27 2014 +0200

    s4:torture:basic: eliminate potential for false failures in delayed_write_update1
    
    We want to test that the write did update the write time immediately.
    We check this by getting the file info in a loop for a few seconds.
    There are several result cases:
    
    - the server updated the write time immediately - success
    - the server updated the write time, but not immediately - failure
    - the server did not update the write time - failure
    
    The loop is only there to be able to discern between the two
    failure cases. The check for success is whether the first
    getinfo has reportet the updated write time.
    
    The potential for false failures was the additional timing check.
    So if the first fileinfo call just took too long (e.g. due to a
    busy system), this was reported as failure.
    
    This patch should eliminate interemittent autobuild failures.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit bc93c8249b4ad93bebc590dede241d80f86f0291
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 15:58:05 2014 +0200

    s4:torture:basic: use assert in the second loop in delayed_write_update1
    
    We can hence replace the assert after the loop by a success torture_comment.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 91c59404217a7b5811c2ec694df1c6843344e57a
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 16:32:41 2014 +0200

    s4:torture:basic: add check for size after initial write to delayed_write_update1
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 32dee459dc45e89d6bf33e9a881c936971f07087
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 15:52:57 2014 +0200

    s4:torture:basic: add update into past as error condition in delayed_write_update1
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 4808e3d3ee292da765a75a19ba0ad3f3af70ed0b
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 15:35:09 2014 +0200

    s4:torture:basic: make use of torture_assert macros in delayed_write_update1
    
    No logic change except for adding early returns.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 5d8a498536f562384b8d03aae458e2a8a5fd5b8a
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 15:25:34 2014 +0200

    s4:torture:basic: whitespace fix in delayed_write_update1
    
    No diff with git diff -w
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit dc9ea4f84912494645b5f4ad8fabc768634bc1f2
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 14:53:01 2014 +0200

    s4:torture:basic: remove two unused variables from delayed_write_update3c
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 4df94065c773fbfe17c85ae18aa5207d88de0df3
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 15:19:49 2014 +0200

    s4:torture:basic: use torture_assert macros in delayed_write_update
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 6cb9d976cf65a2cdb5c21a8c038699003a5ddfca
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 15:17:13 2014 +0200

    s4:torture:basic: whitespace cleanup in delayed_write_update
    
    git diff -w shows no diff
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 23cd60f0a3e37a0a5f2212431855428e8340b5c0
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 13:03:05 2014 +0200

    torture: add torture_assert_u64_not_equal()
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit fae589be2af8efe36713536203ae715d29d78b5b
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 2 13:02:48 2014 +0200

    torture: add torture_assert_int_not_equal
    
    Signed-off-by: Michael Adam <obnox at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/manpages/samba-tool.8.xml |    2 +-
 lib/torture/torture.h              |   21 ++
 source4/torture/basic/delaywrite.c |  606 ++++++++++++++++--------------------
 3 files changed, 284 insertions(+), 345 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/samba-tool.8.xml b/docs-xml/manpages/samba-tool.8.xml
index c1bc7d9..9cb304b 100644
--- a/docs-xml/manpages/samba-tool.8.xml
+++ b/docs-xml/manpages/samba-tool.8.xml
@@ -466,7 +466,7 @@
 
 <refsect3>
 	<title>sites remove <replaceable>site</replaceable> [options]</title>
-	<para>Delete an esxisting site.</para>
+	<para>Delete an existing site.</para>
 </refsect3>
 
 <refsect2>
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index 3a08042..d6a9217 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -414,6 +414,16 @@ void torture_result(struct torture_context *test,
 	} \
 	} while(0)
 
+#define torture_assert_int_not_equal(torture_ctx,got,not_expected,cmt)\
+	do { int __got = (got), __not_expected = (not_expected); \
+	if (__got == __not_expected) { \
+		torture_result(torture_ctx, TORTURE_FAIL, \
+			__location__": "#got" was %d (0x%X), expected a different number: %s", \
+			__got, __got, cmt); \
+		return false; \
+	} \
+	} while(0)
+
 #define torture_assert_u64_equal(torture_ctx,got,expected,cmt)\
 	do { uint64_t __got = (got), __expected = (expected); \
 	if (__got != __expected) { \
@@ -439,6 +449,17 @@ void torture_result(struct torture_context *test,
 	} \
 	} while(0)
 
+#define torture_assert_u64_not_equal(torture_ctx,got,not_expected,cmt)\
+	do { uint64_t __got = (got), __not_expected = (not_expected); \
+	if (__got == __not_expected) { \
+		torture_result(torture_ctx, TORTURE_FAIL, \
+			__location__": "#got" was %llu (0x%llX), expected a different number: %s", \
+			(unsigned long long)__got, (unsigned long long)__got, \
+			cmt); \
+		return false; \
+	} \
+	} while(0)
+
 #define torture_assert_errno_equal(torture_ctx,expected,cmt)\
 	do { int __expected = (expected); \
 	if (errno != __expected) { \
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index 12d95e2..67788f4 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -53,52 +53,44 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
 	torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
 
 	fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-	if (fnum1 == -1) {
-		torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname);
-		return false;
-	}
+	torture_assert_int_not_equal(tctx, fnum1, -1, talloc_asprintf(tctx,
+				     "Failed to open %s", fname));
 
 	finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO;
 	finfo1.basic_info.in.file.fnum = fnum1;
 	finfo2 = finfo1;
 
 	status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
-
 	torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
-	
-	torture_comment(tctx, "Initial write time %s\n", 
-	       nt_time_string(tctx, finfo1.basic_info.out.write_time));
 
-	written =  smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
+	torture_comment(tctx, "Initial write time %s\n",
+			nt_time_string(tctx, finfo1.basic_info.out.write_time));
 
-	if (written != 1) {
-		torture_result(tctx, TORTURE_FAIL, 
-					   "write failed - wrote %d bytes (%s)\n", 
-					   (int)written, __location__);
-		return false;
-	}
+	written =  smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
+	torture_assert_int_equal(tctx, written, 1,
+				 "unexpected number of bytes written");
 
 	start = timeval_current();
 	end = timeval_add(&start, (120 * sec), 0);
 	while (!timeval_expired(&end)) {
 		status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
 
-		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
-			ret = false;
-			break;
-		}
-		torture_comment(tctx, "write time %s\n", 
-		       nt_time_string(tctx, finfo2.basic_info.out.write_time));
-		if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
+		torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
+
+		torture_comment(tctx, "write time %s\n",
+			nt_time_string(tctx, finfo2.basic_info.out.write_time));
+
+		if (finfo1.basic_info.out.write_time !=
+		    finfo2.basic_info.out.write_time)
+		{
 			double diff = timeval_elapsed(&start);
-			if (diff < (used_delay / (double)1000000)) {
-				torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds"
-						"(expected > %.2f) (wrong!)\n",
-						diff, used_delay / (double)1000000);
-				ret = false;
-				break;
-			}
+
+			torture_assert(tctx,
+				       diff >= (used_delay / (double)1000000),
+				       talloc_asprintf(tctx,
+					"Server updated write_time after %.2f "
+					"seconds (expected >= %.2f)\n",
+					diff, used_delay/(double)1000000));
 
 			torture_comment(tctx, "Server updated write_time after %.2f seconds (correct)\n",
 					diff);
@@ -107,13 +99,12 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
 		fflush(stdout);
 		smb_msleep(1 * msec);
 	}
-	
-	if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
-		torture_result(tctx, TORTURE_FAIL, 
-					   "Server did not update write time (wrong!)");
-		ret = false;
-	}
 
+	torture_assert_u64_not_equal(tctx,
+				     finfo2.basic_info.out.write_time,
+				     finfo1.basic_info.out.write_time,
+				     "Server did not update write time within "
+				     "120 seconds");
 
 	if (fnum1 != -1)
 		smbcli_close(cli->tree, fnum1);
@@ -138,16 +129,16 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 	double sec = ((double)used_delay) / ((double)normal_delay);
 	int msec = 1000 * sec;
 	char buf[2048];
+	bool first;
+	bool updated;
 
 	torture_comment(tctx, "\nRunning test_delayed_write_update1\n");
 
 	torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
 
 	fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-	if (fnum1 == -1) {
-		torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname);
-		return false;
-	}
+	torture_assert_int_not_equal(tctx, fnum1, -1, talloc_asprintf(tctx,
+				     "Failed to open %s", fname));
 
 	memset(buf, 'x', 2048);
 	written =  smbcli_write(cli->tree, fnum1, 0, buf, 0, 2048);
@@ -167,8 +158,11 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 
 	torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
 
-	torture_comment(tctx, "Initial write time %s\n", 
-	       nt_time_string(tctx, finfo1.all_info.out.write_time));
+	torture_assert_u64_equal(tctx, finfo1.all_info.out.size, 2048,
+				 "file size not as expected after write(2048)");
+
+	torture_comment(tctx, "Initial write time %s\n",
+			nt_time_string(tctx, finfo1.all_info.out.write_time));
 
 	/* 3 second delay to ensure we get past any 2 second time
 	   granularity (older systems may have that) */
@@ -176,112 +170,82 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 
 	/* Do a zero length SMBwrite call to truncate. */
 	written = smbcli_smbwrite(cli->tree, fnum1, "x", 1024, 0);
-
-	if (written != 0) {
-		torture_result(tctx, TORTURE_FAIL, 
-					   "write failed - wrote %d bytes (%s)\n",
-					   (int)written, __location__);
-		return false;
-	}
+	torture_assert_int_equal(tctx, written, 0,
+				 "unexpected number of bytes written");
 
 	start = timeval_current();
 	end = timeval_add(&start, (120 * sec), 0);
+	first = true;
+	updated = false;
 	while (!timeval_expired(&end)) {
 		status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
 
-		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
-			ret = false;
-			break;
-		}
+		torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
 
-		if (finfo2.all_info.out.size != 1024) {
-			torture_result(tctx, TORTURE_FAIL, 
-						   "file not truncated, size = %u (should be 1024)",
-				(unsigned int)finfo2.all_info.out.size);
-			ret = false;
-			break;
-		}
+		torture_assert_u64_equal(tctx, finfo2.all_info.out.size, 1024,
+					 "file not truncated to expected size "
+					 "(1024)");
 
 		torture_comment(tctx, "write time %s\n",
-		       nt_time_string(tctx, finfo2.all_info.out.write_time));
-		if (finfo1.all_info.out.write_time != finfo2.all_info.out.write_time) {
-			double diff = timeval_elapsed(&start);
-			if (diff > (0.25 * (used_delay / (double)1000000))) {
-				torture_result(tctx, TORTURE_FAIL, "After SMBwrite truncate "
-					"server updated write_time after %.2f seconds"
-					"(write time update dealy == %.2f)(wrong!)\n",
-					       diff, used_delay / (double)1000000);
-				ret = false;
-				break;
-			}
+			nt_time_string(tctx, finfo2.all_info.out.write_time));
 
-			torture_comment(tctx, "After SMBwrite truncate "
-					"server updated write_time after %.2f seconds"
-					"(1 sec == %.2f)(correct)\n",
-					diff, used_delay / (double)1000000);
+		if (finfo1.all_info.out.write_time !=
+		    finfo2.all_info.out.write_time)
+		{
+			updated = true;
 			break;
 		}
+
 		fflush(stdout);
 		smb_msleep(1 * msec);
+		first = false;
 	}
 
-	if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
-		torture_result(tctx, TORTURE_FAIL, 
-					   "Server did not update write time (wrong!)");
-		ret = false;
-	}
+	torture_assert(tctx, updated,
+		       "Server did not update write time within 120 seconds");
+
+	torture_assert(tctx, first, talloc_asprintf(tctx,
+		       "Server did not update write time immediately but only "
+		       "after %.2f seconds!", timeval_elapsed(&start)));
+
+	torture_comment(tctx, "Server updated write time immediately. Good!\n");
 
 	fflush(stdout);
 	smb_msleep(2 * msec);
 
 	/* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
 	written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
-
-	if (written != 1) {
-		torture_result(tctx, TORTURE_FAIL, 
-					   "write failed - wrote %d bytes (%s)",
-					   (int)written, __location__);
-		return false;
-	}
+	torture_assert_int_equal(tctx, written, 1,
+				 "unexpected number of bytes written");
 
 	start = timeval_current();
 	end = timeval_add(&start, (10*sec), 0);
 	while (!timeval_expired(&end)) {
 		status = smb_raw_fileinfo(cli->tree, tctx, &finfo3);
 
-		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
-			ret = false;
-			break;
-		}
+		torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
 
-		if (finfo3.all_info.out.size != 1024) {
-			DEBUG(0, ("file not truncated, size = %u (should be 1024)\n",
-				(unsigned int)finfo3.all_info.out.size));
-			ret = false;
-			break;
-		}
+		torture_assert_u64_equal(tctx, finfo3.all_info.out.size, 1024,
+					 "file not truncated to expected size "
+					 "(1024)");
 
 		torture_comment(tctx, "write time %s\n",
-		       nt_time_string(tctx, finfo3.all_info.out.write_time));
-		if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
-			double diff = timeval_elapsed(&start);
+			nt_time_string(tctx, finfo3.all_info.out.write_time));
+
+		torture_assert_u64_equal(tctx,
+					 finfo3.all_info.out.write_time,
+					 finfo2.all_info.out.write_time,
+					 talloc_asprintf(tctx,
+						"Server updated write time "
+						"after %.2f seconds (wrong!)",
+						timeval_elapsed(&start)));
 
-			torture_comment(tctx, "server updated write_time after %.2f seconds"
-					"(wrong)\n",
-					diff);
-			break;
-		}
 		fflush(stdout);
 		smb_msleep(1 * msec);
 	}
 
-	if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
-		torture_result(tctx, TORTURE_FAIL, 
-					   "Server updated write time (wrong!)");
-		ret = false;
-	}
+	torture_comment(tctx, "Server did not update write time within 10 "
+			"seconds. Good!\n");
 
 	fflush(stdout);
 	smb_msleep(2 * msec);
@@ -293,13 +257,17 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
 	status = smb_raw_pathinfo(cli->tree, tctx, &pinfo4);
 	torture_assert_ntstatus_ok(tctx, status, "pathinfo failed");
 
-	if (finfo3.all_info.out.write_time == pinfo4.all_info.out.write_time) {
-		torture_result(tctx, TORTURE_FAIL,
-					   "Server did not update write time on close (wrong!)");
-		ret = false;
-	} else if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) {
-		torture_comment(tctx, "Server updated write time on close (correct)\n");
-	}
+	torture_assert_u64_not_equal(tctx,
+				     pinfo4.all_info.out.write_time,
+				     finfo3.all_info.out.write_time,
+				     "Server did not update write time on "
+				     "close (wrong!)");
+	torture_assert(tctx,
+		pinfo4.all_info.out.write_time > finfo3.all_info.out.write_time,
+		"Server updated write time on close, but to an earlier point "
+		"in time");
+
+	torture_comment(tctx, "Server updated write time on close (correct)\n");
 
 	if (fnum1 != -1)
 		smbcli_close(cli->tree, fnum1);
@@ -327,16 +295,16 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
 	double sec = ((double)used_delay) / ((double)normal_delay);
 	int msec = 1000 * sec;
 	char buf[2048];
+	bool first;
+	bool updated;
 
 	torture_comment(tctx, "\nRunning test_delayed_write_update1a\n");
 
 	torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
 
 	fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-	if (fnum1 == -1) {
-		torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname);
-		return false;
-	}
+	torture_assert_int_not_equal(tctx, fnum1, -1, talloc_asprintf(tctx,
+				     "Failed to open %s", fname));
 
 	memset(buf, 'x', 2048);
 	written =  smbcli_write(cli->tree, fnum1, 0, buf, 0, 2048);
@@ -356,66 +324,54 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
 
 	torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
 
-	torture_comment(tctx, "Initial write time %s\n", 
-	       nt_time_string(tctx, finfo1.all_info.out.write_time));
+	torture_assert_u64_equal(tctx, finfo1.all_info.out.size, 2048,
+				 "file size not as expected after write(2048)");
+
+	torture_comment(tctx, "Initial write time %s\n",
+			nt_time_string(tctx, finfo1.all_info.out.write_time));
 
 	/* Do a zero length SMBwrite call to truncate. */
 	written = smbcli_smbwrite(cli->tree, fnum1, "x", 10240, 0);
 
-	if (written != 0) {
-		torture_result(tctx, TORTURE_FAIL, "write failed - wrote %d bytes (%s)",
-		       (int)written, __location__);
-		return false;
-	}
+	torture_assert_int_equal(tctx, written, 0,
+				 "unexpected number of bytes written");
 
 	start = timeval_current();
 	end = timeval_add(&start, (120*sec), 0);
+	first = true;
+	updated = false;
 	while (!timeval_expired(&end)) {
 		status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
 
-		if (!NT_STATUS_IS_OK(status)) {
-			torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s", 
-						   nt_errstr(status));
-			ret = false;
-			break;
-		}
+		torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
 
-		if (finfo2.all_info.out.size != 10240) {
-			torture_result(tctx, TORTURE_FAIL, 
-						   "file not truncated, size = %u (should be 10240)",
-				(unsigned int)finfo2.all_info.out.size);
-			ret = false;
-			break;
-		}
+		torture_assert_u64_equal(tctx, finfo2.all_info.out.size, 10240,
+					 "file not truncated to expected size "
+					 "(10240)");
 
 		torture_comment(tctx, "write time %s\n",
-		       nt_time_string(tctx, finfo2.all_info.out.write_time));
-		if (finfo1.all_info.out.write_time != finfo2.all_info.out.write_time) {
-			double diff = timeval_elapsed(&start);
-			if (diff > (0.25 * (used_delay / (double)1000000))) {
-				torture_result(tctx, TORTURE_FAIL, "After SMBwrite truncate "
-					"server updated write_time after %.2f seconds"
-					"(write time update delay == %.2f)(wrong!)\n",
-					diff, used_delay / (double)1000000);
-				ret = false;
-				break;
-			}
+			nt_time_string(tctx, finfo2.all_info.out.write_time));
 
-			torture_comment(tctx, "After SMBwrite truncate "
-					"server updated write_time after %.2f seconds"
-					"(write time update delay == %.2f)(correct)\n",
-					diff, used_delay / (double)1000000);
+		if (finfo1.all_info.out.write_time !=
+		    finfo2.all_info.out.write_time)
+		{
+			updated = true;
 			break;
 		}
+
 		fflush(stdout);
 		smb_msleep(1 * msec);
+		first = false;
 	}
 
-	if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
-		torture_result(tctx, TORTURE_FAIL, 
-					   "Server did not update write time (wrong!)");
-		ret = false;
-	}
+	torture_assert(tctx, updated,
+		       "Server did not update write time within 120 seconds");
+
+	torture_assert(tctx, first, talloc_asprintf(tctx,
+		       "Server did not update write time immediately but only "
+		       "after %.2f seconds!", timeval_elapsed(&start)));
+
+	torture_comment(tctx, "Server updated write time immediately. Good!\n");
 
 	fflush(stdout);
 	smb_msleep(2 * msec);
@@ -423,48 +379,37 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb
 	/* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
 	written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
 
-	torture_assert_int_equal(tctx, written, 1, 
-							 "unexpected number of bytes written");
+	torture_assert_int_equal(tctx, written, 1,
+				 "unexpected number of bytes written");
 
 	start = timeval_current();
 	end = timeval_add(&start, (10*sec), 0);
 	while (!timeval_expired(&end)) {
 		status = smb_raw_fileinfo(cli->tree, tctx, &finfo3);
 
-		if (!NT_STATUS_IS_OK(status)) {
-			torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s\n", 
-						   nt_errstr(status));
-			ret = false;
-			break;
-		}
+		torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");


-- 
Samba Shared Repository


More information about the samba-cvs mailing list