You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/07/30 19:08:13 UTC

svn commit: r1508526 - in /subversion/branches/fsx: build.conf subversion/tests/libsvn_subr/ subversion/tests/libsvn_subr/packed-data-test.c

Author: stefan2
Date: Tue Jul 30 17:08:13 2013
New Revision: 1508526

URL: http://svn.apache.org/r1508526
Log:
On the fsx branch: add an initial test for the svn_packed__* API.

* build.conf
  (packed-data-test): new target
  (__ALL_TESTS__): register new target

* subversion/tests/libsvn_subr
  (svn:ignore): ignore new test binary

* subversion/tests/libsvn_subr/packed-data-test.c
  (): new test

Added:
    subversion/branches/fsx/subversion/tests/libsvn_subr/packed-data-test.c
Modified:
    subversion/branches/fsx/build.conf
    subversion/branches/fsx/subversion/tests/libsvn_subr/   (props changed)

Modified: subversion/branches/fsx/build.conf
URL: http://svn.apache.org/viewvc/subversion/branches/fsx/build.conf?rev=1508526&r1=1508525&r2=1508526&view=diff
==============================================================================
--- subversion/branches/fsx/build.conf (original)
+++ subversion/branches/fsx/build.conf Tue Jul 30 17:08:13 2013
@@ -946,6 +946,14 @@ sources = named_atomic-test-proc.c
 install = sub-test
 libs = libsvn_subr apr
 
+[packed-data-test]
+description = Test path library
+type = exe
+path = subversion/tests/libsvn_subr
+sources = packed-data-test.c
+install = test
+libs = libsvn_test libsvn_subr apriconv apr
+
 [path-test]
 description = Test path library
 type = exe
@@ -1348,8 +1356,8 @@ libs = __ALL__
        string-table-test
        skel-test strings-reps-test changes-test locks-test repos-test
        checksum-test compat-test config-test hashdump-test mergeinfo-test
-       opt-test path-test prefix-string-test priority-queue-test stream-test
-       string-test time-test utf-test
+       opt-test packed-data-test path-test prefix-string-test
+       priority-queue-test stream-test string-test time-test utf-test
        error-test error-code-test cache-test spillbuf-test crypto-test
        named_atomic-test named_atomic-proc-test revision-test
        subst_translate-test io-test

Propchange: subversion/branches/fsx/subversion/tests/libsvn_subr/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Jul 30 17:08:13 2013
@@ -44,3 +44,4 @@ io-test-temp
 auth-clear
 prefix-string-test
 priority-queue-test
+packed-data-test

Added: subversion/branches/fsx/subversion/tests/libsvn_subr/packed-data-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx/subversion/tests/libsvn_subr/packed-data-test.c?rev=1508526&view=auto
==============================================================================
--- subversion/branches/fsx/subversion/tests/libsvn_subr/packed-data-test.c (added)
+++ subversion/branches/fsx/subversion/tests/libsvn_subr/packed-data-test.c Tue Jul 30 17:08:13 2013
@@ -0,0 +1,81 @@
+/*
+ * packed-data-test.c:  a collection of svn_packed__* tests
+ *
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ */
+
+/* ====================================================================
+   To add tests, look toward the bottom of this file.
+
+*/
+
+
+
+#include <stdio.h>
+#include <string.h>
+#include <apr_pools.h>
+
+#include "../svn_test.h"
+
+#include "svn_error.h"
+#include "svn_string.h"   /* This includes <apr_*.h> */
+#include "private/svn_packed_data.h"
+
+static svn_error_t*
+get_read_root(svn_packed__data_root_t **read_root,
+              svn_packed__data_root_t *write_root,
+              apr_pool_t *pool)
+{
+  svn_stringbuf_t *stream_buffer = svn_stringbuf_create_empty(pool);
+  svn_stream_t *stream;
+
+  stream = svn_stream_from_stringbuf(stream_buffer, pool);
+  SVN_ERR(svn_packed__data_write(stream, write_root, pool));
+  SVN_ERR(svn_stream_close(stream));
+
+  stream = svn_stream_from_stringbuf(stream_buffer, pool);
+  SVN_ERR(svn_packed__data_read(read_root, stream, pool, pool));
+  SVN_ERR(svn_stream_close(stream));
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+test_empty_container(apr_pool_t *pool)
+{
+  /* create an empty, readable container */
+  svn_packed__data_root_t *root = svn_packed__data_create_root(pool);
+  SVN_ERR(get_read_root(&root, root, pool));
+
+  /* there should be no sub-streams */
+  SVN_TEST_ASSERT(svn_packed__first_int_stream(root) == NULL);
+  SVN_TEST_ASSERT(svn_packed__first_byte_stream(root) == NULL);
+
+  return SVN_NO_ERROR;
+}
+
+/* An array of all test functions */
+struct svn_test_descriptor_t test_funcs[] =
+  {
+    SVN_TEST_NULL,
+    SVN_TEST_PASS2(test_empty_container,
+                   "test empty container"),
+    SVN_TEST_NULL
+  };