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 2015/09/16 11:12:54 UTC

svn commit: r1703370 - in /subversion/branches/ra_serf-stream-commit/subversion: include/svn_delta.h libsvn_delta/svndiff.c tests/libsvn_delta/random-test.c

Author: kotkov
Date: Wed Sep 16 09:12:54 2015
New Revision: 1703370

URL: http://svn.apache.org/r1703370
Log:
On the ra_serf-stream-commit branch: Declare the new API that turns a given
svn_txdelta_stream_t delta stream into a readable svn_stream_t and add a
test for it.  As the core of this API it not yet implemented, the test fails.

* subversion\include\svn_delta.h
  (svn_txdelta_to_svndiff_stream): Declare.

* subversion\libsvn_delta\svndiff.c
  (svn_txdelta_to_svndiff_stream): Add a stub implementation that currently
   does nothing.

* subversion\tests\libsvn_delta\random-test.c
  (do_random_txdelta_to_stream_test): Core of the new test.  Mostly takes
   the ideas from random_test().
  (random_txdelta_to_stream_test): Execute core of the new test and output
   the random seed if it fails.
  (test_funcs): Add the new test, marked as XFAIL.

Modified:
    subversion/branches/ra_serf-stream-commit/subversion/include/svn_delta.h
    subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/svndiff.c
    subversion/branches/ra_serf-stream-commit/subversion/tests/libsvn_delta/random-test.c

Modified: subversion/branches/ra_serf-stream-commit/subversion/include/svn_delta.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra_serf-stream-commit/subversion/include/svn_delta.h?rev=1703370&r1=1703369&r2=1703370&view=diff
==============================================================================
--- subversion/branches/ra_serf-stream-commit/subversion/include/svn_delta.h (original)
+++ subversion/branches/ra_serf-stream-commit/subversion/include/svn_delta.h Wed Sep 16 09:12:54 2015
@@ -554,6 +554,21 @@ svn_txdelta_to_svndiff(svn_stream_t *out
                        svn_txdelta_window_handler_t *handler,
                        void **handler_baton);
 
+/** Return a readable generic stream which will produce svndiff-encoded
+ * text delta from the delta stream @a txstream. The svndiff version is
+ * @a svndiff_version. @a compression_level is the zlib compression
+ * level from 0 (no compression) and 9 (maximum compression).
+ *
+ * Allocate the stream in @a pool.
+ *
+ * @since New in 1.10.
+ */
+svn_stream_t *
+svn_txdelta_to_svndiff_stream(svn_txdelta_stream_t *txstream,
+                              int svndiff_version,
+                              int compression_level,
+                              apr_pool_t *pool);
+
 /** Return a writable generic stream which will parse svndiff-format
  * data into a text delta, invoking @a handler with @a handler_baton
  * whenever a new window is ready.

Modified: subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/svndiff.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/svndiff.c?rev=1703370&r1=1703369&r2=1703370&view=diff
==============================================================================
--- subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/svndiff.c (original)
+++ subversion/branches/ra_serf-stream-commit/subversion/libsvn_delta/svndiff.c Wed Sep 16 09:12:54 2015
@@ -954,3 +954,11 @@ svn_txdelta__read_raw_window_len(apr_siz
   return SVN_NO_ERROR;
 }
 
+svn_stream_t *
+svn_txdelta_to_svndiff_stream(svn_txdelta_stream_t *txstream,
+                              int svndiff_version,
+                              int compression_level,
+                              apr_pool_t *pool)
+{
+  return NULL;
+}

Modified: subversion/branches/ra_serf-stream-commit/subversion/tests/libsvn_delta/random-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra_serf-stream-commit/subversion/tests/libsvn_delta/random-test.c?rev=1703370&r1=1703369&r2=1703370&view=diff
==============================================================================
--- subversion/branches/ra_serf-stream-commit/subversion/tests/libsvn_delta/random-test.c (original)
+++ subversion/branches/ra_serf-stream-commit/subversion/tests/libsvn_delta/random-test.c Wed Sep 16 09:12:54 2015
@@ -515,6 +515,96 @@ random_combine_test(apr_pool_t *pool)
 }
 
 
+
+/* (Note: *LAST_SEED is an output parameter.) */
+static svn_error_t *
+do_random_txdelta_to_stream_test(apr_pool_t *pool,
+                                 apr_uint32_t *last_seed)
+{
+  apr_uint32_t seed;
+  apr_uint32_t maxlen;
+  apr_size_t bytes_range;
+  int i;
+  int iterations;
+  int dump_files;
+  int print_windows;
+  const char *random_bytes;
+  apr_pool_t *iterpool = svn_pool_create(pool);
+
+  /* Initialize parameters and print out the seed in case we dump core
+     or something. */
+  init_params(&seed, &maxlen, &iterations, &dump_files, &print_windows,
+              &random_bytes, &bytes_range, pool);
+
+  for (i = 0; i < iterations; i++)
+    {
+      apr_uint32_t subseed_base;
+      apr_file_t *source;
+      apr_file_t *target;
+      apr_file_t *source_copy;
+      apr_file_t *new_target;
+      svn_txdelta_stream_t *txstream;
+      svn_stream_t *delta_stream;
+      svn_txdelta_window_handler_t handler;
+      void *handler_baton;
+      svn_stream_t *push_stream;
+
+      svn_pool_clear(iterpool);
+
+      /* Generate source and target for the delta and its application. */
+      *last_seed = seed;
+      subseed_base = svn_test_rand(&seed);
+      source = generate_random_file(maxlen, subseed_base, &seed,
+                                    random_bytes, bytes_range,
+                                    dump_files, iterpool);
+      target = generate_random_file(maxlen, subseed_base, &seed,
+                                    random_bytes, bytes_range,
+                                    dump_files, iterpool);
+      source_copy = copy_tempfile(source, pool);
+      new_target = open_tempfile(NULL, iterpool);
+
+      /* Create a txdelta stream that turns the source into target;
+         turn it into a generic readable svn_stream_t. */
+      svn_txdelta2(&txstream,
+                   svn_stream_from_aprfile2(source, TRUE, iterpool),
+                   svn_stream_from_aprfile2(target, TRUE, iterpool),
+                   FALSE, iterpool);
+      delta_stream = svn_txdelta_to_svndiff_stream(txstream, 1, i % 10,
+                                                   iterpool);
+
+      /* Apply it to a copy of the source file to see if we get the
+         same target back. */
+      svn_txdelta_apply(svn_stream_from_aprfile2(source_copy, TRUE, iterpool),
+                        svn_stream_from_aprfile2(new_target, TRUE, iterpool),
+                        NULL, NULL, iterpool, &handler, &handler_baton);
+      push_stream = svn_txdelta_parse_svndiff(handler, handler_baton, TRUE,
+                                              iterpool);
+      SVN_ERR(svn_stream_copy3(delta_stream, push_stream, NULL, NULL,
+                               iterpool));
+
+      SVN_ERR(compare_files(target, new_target, dump_files));
+
+      apr_file_close(source);
+      apr_file_close(target);
+      apr_file_close(source_copy);
+      apr_file_close(new_target);
+    }
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
+
+/* Implements svn_test_driver_t. */
+static svn_error_t *
+random_txdelta_to_stream_test(apr_pool_t *pool)
+{
+  apr_uint32_t seed;
+  svn_error_t *err = do_random_txdelta_to_stream_test(pool, &seed);
+  if (err)
+    fprintf(stderr, "SEED: %lu\n", (unsigned long)seed);
+  return err;
+}
+
 /* Change to 1 to enable the unit test for the delta combiner's range index: */
 #if 0
 #include "range-index-test.h"
@@ -533,6 +623,8 @@ static struct svn_test_descriptor_t test
                    "random delta test"),
     SVN_TEST_PASS2(random_combine_test,
                    "random combine delta test"),
+    SVN_TEST_XFAIL2(random_txdelta_to_stream_test,
+                    "random txdelta to svndiff stream test"),
 #ifdef SVN_RANGE_INDEX_TEST_H
     SVN_TEST_PASS2(random_range_index_test,
                    "random range index test"),