You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2013/07/01 16:36:41 UTC
svn commit: r1498484 - /subversion/trunk/subversion/tests/libsvn_fs/fs-test.c
Author: danielsh
Date: Mon Jul 1 14:36:40 2013
New Revision: 1498484
URL: http://svn.apache.org/r1498484
Log:
Improve a regression test.
* subversion/tests/libsvn_fs/fs-test.c
(svn_hash.h): Include.
(filename_trailing_newline): Switch from a blacklist approach to
to a whitelist approach, for defining backends that don't implement
the API correctly. Also extend the test to actually commit the files and
dirs, and verify the commit.
Modified:
subversion/trunk/subversion/tests/libsvn_fs/fs-test.c
Modified: subversion/trunk/subversion/tests/libsvn_fs/fs-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_fs/fs-test.c?rev=1498484&r1=1498483&r2=1498484&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_fs/fs-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_fs/fs-test.c Mon Jul 1 14:36:40 2013
@@ -27,6 +27,7 @@
#include "../svn_test.h"
+#include "svn_hash.h"
#include "svn_pools.h"
#include "svn_time.h"
#include "svn_string.h"
@@ -4958,11 +4959,13 @@ filename_trailing_newline(const svn_test
svn_revnum_t youngest_rev = 0;
svn_error_t *err;
svn_boolean_t allow_newlines;
+ static const char contents[] = "foo\003bar";
- /* Some filesystem implementations can handle newlines in filenames
- * and can be white-listed here.
- * Currently, only BDB supports \n in filenames. */
- allow_newlines = (strcmp(opts->fs_type, "bdb") == 0);
+ /* The FS API wants \n to be permitted, but FSFS never implemented that,
+ * so for FSFS we expect errors rather than successes in some of the commits.
+ * Use a blacklist approach so that new FSes default to implementing the API
+ * as originally defined. */
+ allow_newlines = (!!strcmp(opts->fs_type, SVN_FS_TYPE_FSFS));
SVN_ERR(svn_test__create_fs(&fs, "test-repo-filename-trailing-newline",
opts, pool));
@@ -4991,6 +4994,48 @@ filename_trailing_newline(const svn_test
SVN_TEST_ASSERT(err == SVN_NO_ERROR);
else
SVN_TEST_ASSERT_ERROR(err, SVN_ERR_FS_PATH_SYNTAX);
+
+
+ /* Create another file, with contents. */
+ if (allow_newlines)
+ {
+ SVN_ERR(svn_fs_make_file(txn_root, "/bar\n/baz\n", subpool));
+ SVN_ERR(svn_test__set_file_contents(txn_root, "bar\n/baz\n",
+ contents, pool));
+ }
+
+ if (allow_newlines)
+ {
+ svn_revnum_t after_rev;
+ static svn_test__tree_entry_t expected_entries[] = {
+ { "foo", NULL },
+ { "bar\n", NULL },
+ { "foo/baz\n", "" },
+ { "bar\n/baz\n", contents },
+ { NULL, NULL }
+ };
+ const char *expected_changed_paths[] = {
+ "/bar\n",
+ "/foo/baz\n",
+ "/bar\n/baz\n",
+ NULL
+ };
+ apr_hash_t *expected_changes = apr_hash_make(pool);
+ int i;
+
+ SVN_ERR(svn_fs_commit_txn(NULL, &after_rev, txn, subpool));
+ SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(after_rev));
+
+ /* Validate the DAG. */
+ SVN_ERR(svn_fs_revision_root(&root, fs, after_rev, pool));
+ SVN_ERR(svn_test__validate_tree(root, expected_entries, 4, pool));
+
+ /* Validate changed-paths, where the problem originally occurred. */
+ for (i = 0; expected_changed_paths[i]; i++)
+ svn_hash_sets(expected_changes, expected_changed_paths[i],
+ "undefined value");
+ SVN_ERR(svn_test__validate_changes(root, expected_changes, pool));
+ }
return SVN_NO_ERROR;
}