[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-1382-ga32f4dd

Andrew Tridgell tridge at samba.org
Fri Sep 4 18:10:27 MDT 2009


The branch, master has been updated
       via  a32f4dd3cfd43022ab3224366e026664b238429e (commit)
       via  5afa115f2ad150563fdf8ba978e5f165d75eba4b (commit)
      from  ab6e82910af87ca4c4572d973fb657c4004b443b (commit)

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


- Log -----------------------------------------------------------------
commit a32f4dd3cfd43022ab3224366e026664b238429e
Author: Andrew Kroeger <andrew at id10ts.net>
Date:   Fri Sep 4 16:45:01 2009 -0500

    util:tests: Correct time tests for negative UTC offsets.
    
    All:
    
    Please find attached a patch to fix the timestring and http_timestring
    tests on hosts that have a negative UTC offset (west of the Prime Meridian).
    
    Sincerely,
    Andrew Kroeger
    
    >From 8a8ca35edccf64aa98f2f3ae1469c4c27db8215e Mon Sep 17 00:00:00 2001
    From: Andrew Kroeger <andrew at id10ts.net>
    Date: Fri, 4 Sep 2009 01:31:50 -0500
    Subject: [PATCH] util:tests: Correct time tests for negative UTC offsets.
    
    The timestring and http_timestring tests were failing on hosts with negative
    offsets from UTC.  Due to the timezone offset, the returned values were back in
    the year 1969 (before the epoch) and did not match the test patterns.
    
    The correction computes the offset from UTC, and if it is negative that offset
    is added onto the value given to the timestring() and http_timestring() calls so
    that the returned values fall on 01-Jan-1970 and match the test pattern.

commit 5afa115f2ad150563fdf8ba978e5f165d75eba4b
Author: Andrew Kroeger <andrew at id10ts.net>
Date:   Fri Sep 4 16:42:28 2009 -0500

    selftest: Account for 0-based months in date parsing and printing.
    
    All:
    
    Please find attached 2 patches to correct date/time parsing and output
    in the Subunit processing.  The first patch corrects the logic to
    account for months being 0-based.  The second corrects the time
    formatting, as it is dealing with local, not "Z"ulu (UTC) time.
    
    Sincerely,
    Andrew Kroeger
    
    >From 3cf81eea1309084a973359c7f6a2375d5d20a3f0 Mon Sep 17 00:00:00 2001
    From: Andrew Kroeger <andrew at id10ts.net>
    Date: Fri, 4 Sep 2009 01:24:00 -0500
    Subject: [PATCH] selftest: Account for 0-based months in date parsing and printing.

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

Summary of changes:
 lib/util/tests/time.c |   25 +++++++++++++++++++++++--
 selftest/Subunit.pm   |    6 +++---
 2 files changed, 26 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/tests/time.c b/lib/util/tests/time.c
index b7cb608..d08a4e7 100644
--- a/lib/util/tests/time.c
+++ b/lib/util/tests/time.c
@@ -44,7 +44,17 @@ static bool test_http_timestring(struct torture_context *tctx)
 {
 	const char *start = "Thu, 01 Jan 1970";
 	char *result;
-	result = http_timestring(tctx, 42);
+	/*
+	 * Correct test for negative UTC offset.  Without the correction, the
+	 * test fails when run on hosts with negative UTC offsets, as the date
+	 * returned is back in 1969 (pre-epoch).
+	 */
+	time_t now = time(NULL);
+	struct tm local = *localtime(&now);
+	struct tm gmt = *gmtime(&now);
+	time_t utc_offset = mktime(&local) - mktime(&gmt);
+
+	result = http_timestring(tctx, 42 - (utc_offset < 0 ? utc_offset : 0));
 	torture_assert(tctx, !strncmp(start, result, 
 				      strlen(start)), result);
 	torture_assert_str_equal(tctx, "never", 
@@ -55,7 +65,18 @@ static bool test_http_timestring(struct torture_context *tctx)
 static bool test_timestring(struct torture_context *tctx)
 {
 	const char *start = "Thu Jan  1";
-	char *result = timestring(tctx, 42);
+	char *result;
+	/*
+	 * Correct test for negative UTC offset.  Without the correction, the
+	 * test fails when run on hosts with negative UTC offsets, as the date
+	 * returned is back in 1969 (pre-epoch).
+	 */
+	time_t now = time(NULL);
+	struct tm local = *localtime(&now);
+	struct tm gmt = *gmtime(&now);
+	time_t utc_offset = mktime(&local) - mktime(&gmt);
+
+	result = timestring(tctx, 42 - (utc_offset < 0 ? utc_offset : 0));
 	torture_assert(tctx, !strncmp(start, result, strlen(start)),
 				   result);
 	return true;
diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm
index ecd712a..9d67c81 100644
--- a/selftest/Subunit.pm
+++ b/selftest/Subunit.pm
@@ -36,8 +36,8 @@ sub parse_results($$$)
 			$msg_ops->control_msg($_);
 			$msg_ops->start_test($1);
 			push (@$open_tests, $1);
-		} elsif (/^time: (\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)Z\n/) {
-			$msg_ops->report_time(mktime($6, $5, $4, $3, $2, $1-1900));
+		} elsif (/^time: (\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)\n/) {
+			$msg_ops->report_time(mktime($6, $5, $4, $3, $2-1, $1-1900));
 		} elsif (/^(success|successful|failure|fail|skip|knownfail|error|xfail|skip-testsuite|testsuite-failure|testsuite-xfail|testsuite-success|testsuite-error): (.*?)( \[)?([ \t]*)\n/) {
 			$msg_ops->control_msg($_);
 			my $result = $1;
@@ -170,7 +170,7 @@ sub report_time($)
 {
 	my ($time) = @_;
 	my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time);
-	printf "time: %04d-%02d-%02d %02d:%02d:%02dZ\n", $year+1900, $mon, $mday, $hour, $min, $sec;
+	printf "time: %04d-%02d-%02d %02d:%02d:%02d\n", $year+1900, $mon+1, $mday, $hour, $min, $sec;
 }
 
 # The following are Samba extensions:


-- 
Samba Shared Repository


More information about the samba-cvs mailing list