You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ko...@apache.org on 2021/02/21 17:08:52 UTC
svn commit: r1886758 - in /subversion/trunk/subversion/tests:
libsvn_subr/io-test.c svn_test.h
Author: kotkov
Date: Sun Feb 21 17:08:51 2021
New Revision: 1886758
URL: http://svn.apache.org/viewvc?rev=1886758&view=rev
Log:
In test_install_stream_set_affected_time(), compare the timestamps with
proximity.
The filesystem that we are running on might not support the microsecond
timestamp precision, but that should not cause the test to fail.
* subversion/tests/svn_test.h
(): Include svn_time.h.
(SVN_TEST_TIME_ASSERT): New helper macro.
* subversion/tests/libsvn_subr/io-test.c
(test_install_stream_set_affected_time): Compare the resulting timestamp
with proximity.
Modified:
subversion/trunk/subversion/tests/libsvn_subr/io-test.c
subversion/trunk/subversion/tests/svn_test.h
Modified: subversion/trunk/subversion/tests/libsvn_subr/io-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/io-test.c?rev=1886758&r1=1886757&r2=1886758&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/io-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/io-test.c Sun Feb 21 17:08:51 2021
@@ -1120,7 +1120,9 @@ test_install_stream_set_affected_time(ap
SVN_TEST_STRING_ASSERT(actual_content->data, "stream1 content");
SVN_ERR(svn_io_stat(&finfo, final_abspath, APR_FINFO_MTIME, pool));
- SVN_TEST_INT_ASSERT(finfo.mtime, expected_timestamp);
+ /* The actual filesystem might have a different timestamp precision,
+ so compare with proximity. */
+ SVN_TEST_TIME_ASSERT(finfo.mtime, expected_timestamp, apr_time_from_sec(10));
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/tests/svn_test.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test.h?rev=1886758&r1=1886757&r2=1886758&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test.h (original)
+++ subversion/trunk/subversion/tests/svn_test.h Sun Feb 21 17:08:51 2021
@@ -37,6 +37,7 @@
#include "svn_error.h"
#include "svn_string.h"
#include "svn_auth.h"
+#include "svn_time.h"
#ifdef __cplusplus
extern "C" {
@@ -147,6 +148,40 @@ extern "C" {
tst_int2, tst_int1, __FILE__, __LINE__); \
} while(0)
+/** Handy macro for testing apr_time_t equality.
+ *
+ * WITHIN_EXPR specifies the proximity of the comparison.
+ */
+#define SVN_TEST_TIME_ASSERT(expr, expected_expr, within_expr) \
+ do { \
+ apr_time_t actual_time = (expr); \
+ apr_time_t expected_time = (expected_expr); \
+ apr_interval_time_t within_time = (within_expr); \
+ \
+ if (actual_time < expected_time - within_time || \
+ actual_time > expected_time + within_time) \
+ { \
+ svn_error_t *err = \
+ svn_error_create(SVN_ERR_TEST_FAILED, NULL, NULL); \
+ \
+ err->message = apr_psprintf( \
+ err->pool, \
+ "Time values not equal\n" \
+ " Expected: %s (%" APR_TIME_T_FMT ")\n" \
+ " Found: %s (%" APR_TIME_T_FMT ")\n" \
+ " Proximity: %" APR_TIME_T_FMT "ms\n" \
+ " at %s:%d", \
+ svn_time_to_cstring(expected_time, err->pool), \
+ expected_time, \
+ svn_time_to_cstring(actual_time, err->pool), \
+ actual_time, \
+ apr_time_as_msec(within_time), \
+ __FILE__, __LINE__); \
+ \
+ return err; \
+ } \
+ } while(0)
+
/* Baton for any arguments that need to be passed from main() to svn
* test functions.