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/19 18:32:15 UTC

svn commit: r1886695 - /subversion/trunk/subversion/tests/libsvn_subr/io-test.c

Author: kotkov
Date: Fri Feb 19 18:32:14 2021
New Revision: 1886695

URL: http://svn.apache.org/viewvc?rev=1886695&view=rev
Log:
Add a test for svn_stream__install_stream_get_info().

* subversion/tests/libsvn_subr/io-test.c
  (test_install_stream_get_info): New test.
  (test_funcs): Run the new test.

Modified:
    subversion/trunk/subversion/tests/libsvn_subr/io-test.c

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=1886695&r1=1886694&r2=1886695&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/io-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/io-test.c Fri Feb 19 18:32:14 2021
@@ -1119,6 +1119,47 @@ test_install_stream_set_affected_time(ap
 }
 
 static svn_error_t *
+test_install_stream_get_info(apr_pool_t *pool)
+{
+  const char *tmp_dir;
+  const char *final_abspath;
+  svn_stream_t *stream;
+  apr_time_t mtime;
+  apr_off_t size;
+  svn_stringbuf_t *actual_content;
+  apr_finfo_t finfo;
+
+  /* Create an empty directory. */
+  SVN_ERR(svn_test_make_sandbox_dir(&tmp_dir,
+                                    "test_install_stream_get_info",
+                                    pool));
+
+  final_abspath = svn_dirent_join(tmp_dir, "stream1", pool);
+
+  SVN_ERR(svn_stream__create_for_install(&stream, tmp_dir, pool, pool));
+  SVN_ERR(svn_stream_puts(stream, "stream1 content"));
+  SVN_ERR(svn_stream_close(stream));
+  SVN_ERR(svn_stream__install_get_info(&mtime, &size, stream, pool));
+  SVN_ERR(svn_stream__install_stream(stream,
+                                     final_abspath,
+                                     TRUE,
+                                     pool));
+  /* Should see the same values as before the install. */
+  SVN_ERR(svn_io_stat(&finfo, final_abspath,
+                      APR_FINFO_MTIME | APR_FINFO_SIZE,
+                      pool));
+  SVN_TEST_INT_ASSERT(mtime, finfo.mtime);
+  SVN_TEST_INT_ASSERT(size, finfo.size);
+
+  SVN_ERR(svn_stringbuf_from_file2(&actual_content,
+                                   final_abspath,
+                                   pool));
+  SVN_TEST_STRING_ASSERT(actual_content->data, "stream1 content");
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
 test_file_size_get(apr_pool_t *pool)
 {
   const char *tmp_dir, *path;
@@ -1334,6 +1375,8 @@ static struct svn_test_descriptor_t test
                    "test svn_stream__install_stream_set_read_only"),
     SVN_TEST_PASS2(test_install_stream_set_affected_time,
                    "test svn_stream__install_stream_set_affected_time"),
+    SVN_TEST_PASS2(test_install_stream_get_info,
+                   "test svn_stream__install_stream_get_info"),
     SVN_TEST_PASS2(test_file_size_get,
                    "test svn_io_file_size_get"),
     SVN_TEST_PASS2(test_file_rename2,