subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1498042 - /subversion/branches/fsfs-format7/subversion/tests/libsvn_fs_fs/fs-pack-test.c
Date Sun, 30 Jun 2013 00:09:34 GMT
Author: stefan2
Date: Sun Jun 30 00:09:34 2013
New Revision: 1498042

URL: http://svn.apache.org/r1498042
Log:
On the fsfs-format7 branch: add a very simple test for the reps container.

* subversion/tests/libsvn_fs_fs/fs-pack-test.c
  (test_reps): new test
  (test_funcs): register new test

Modified:
    subversion/branches/fsfs-format7/subversion/tests/libsvn_fs_fs/fs-pack-test.c

Modified: subversion/branches/fsfs-format7/subversion/tests/libsvn_fs_fs/fs-pack-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/tests/libsvn_fs_fs/fs-pack-test.c?rev=1498042&r1=1498041&r2=1498042&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/tests/libsvn_fs_fs/fs-pack-test.c (original)
+++ subversion/branches/fsfs-format7/subversion/tests/libsvn_fs_fs/fs-pack-test.c Sun Jun
30 00:09:34 2013
@@ -26,6 +26,7 @@
 
 #include "../svn_test.h"
 #include "../../libsvn_fs_fs/fs.h"
+#include "../../libsvn_fs_fs/reps.h"
 
 #include "svn_pools.h"
 #include "svn_props.h"
@@ -846,6 +847,61 @@ test_info(const svn_test_opts_t *opts,
 #undef MAX_REV
 
 /* ------------------------------------------------------------------------ */
+#define REPO_NAME "test-repo-fsfs-rev-container"
+#define SHARD_SIZE 3
+#define MAX_REV 5
+static svn_error_t *
+test_reps(const svn_test_opts_t *opts,
+          apr_pool_t *pool)
+{
+  svn_fs_t *fs = NULL;
+  svn_fs_fs__reps_builder_t *builder;
+  svn_fs_fs__reps_t *container;
+  svn_stringbuf_t *serialized;
+  svn_stream_t *stream;
+  svn_stringbuf_t *contents = svn_stringbuf_create_ensure(10000, pool);
+
+  int i;
+  for (i = 0; i < 10000; ++i)
+    {
+      int v, s = 0;
+      for (v = i; v > 0; v /= 10)
+        s += v % 10;
+
+      svn_stringbuf_appendbyte(contents, (char)(s + ' '));
+    }
+
+  SVN_ERR(create_packed_filesystem(REPO_NAME, opts, MAX_REV, SHARD_SIZE,
+                                   pool));
+
+  SVN_ERR(svn_fs_open(&fs, REPO_NAME, NULL, pool));
+
+  builder = svn_fs_fs__reps_builder_create(fs, pool);
+  for (i = 10000; i > 10; --i)
+    {
+      svn_string_t string;
+      string.data = contents->data;
+      string.len = i;
+
+      svn_fs_fs__reps_add(builder, &string);
+    }
+
+  serialized = svn_stringbuf_create_empty(pool);
+  stream = svn_stream_from_stringbuf(serialized, pool);
+  SVN_ERR(svn_fs_fs__write_reps_container(stream, builder, pool));
+
+  SVN_ERR(svn_stream_reset(stream));
+  SVN_ERR(svn_fs_fs__read_reps_container(&container, stream, pool, pool));
+  SVN_ERR(svn_stream_close(stream));
+
+  return SVN_NO_ERROR;
+}
+
+#undef REPO_NAME
+#undef SHARD_SIZE
+#undef MAX_REV
+
+/* ------------------------------------------------------------------------ */
 
 /* The test table.  */
 
@@ -872,5 +928,7 @@ struct svn_test_descriptor_t test_funcs[
                        "test file hint at shard boundary"),
     SVN_TEST_OPTS_PASS(test_info,
                        "test svn_fs_info"),
+    SVN_TEST_OPTS_PASS(test_reps,
+                       "test representations container"),
     SVN_TEST_NULL
   };



Mime
View raw message