subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1696222 - /subversion/trunk/subversion/tests/libsvn_ra/ra-test.c
Date Mon, 17 Aug 2015 09:30:19 GMT
Author: rhuijben
Date: Mon Aug 17 09:30:18 2015
New Revision: 1696222

URL: http://svn.apache.org/r1696222
Log:
Improve tunnel callback tests to include more scenarios and to stop allocating
a baton on the stack that is referenced from cleanup functions.

This test ensures that we try to poll the connection at least once; which
currently fails on Windows.

* subversion/tests/libsvn_ra/ra-test.c
  (check_tunnel_callback_test): Allocate baton in pool. Ensure specific error.
  (tunnel_callback_test): Don't ignore some errors for FAIL reporting.
  (tunnel_run_checkout): New test.
  (test_funcs): Add new test.

Modified:
    subversion/trunk/subversion/tests/libsvn_ra/ra-test.c

Modified: subversion/trunk/subversion/tests/libsvn_ra/ra-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_ra/ra-test.c?rev=1696222&r1=1696221&r2=1696222&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_ra/ra-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_ra/ra-test.c Mon Aug 17 09:30:18 2015
@@ -332,15 +332,16 @@ static svn_error_t *
 check_tunnel_callback_test(const svn_test_opts_t *opts,
                            apr_pool_t *pool)
 {
-  tunnel_baton_t b = { TUNNEL_MAGIC };
+  tunnel_baton_t *b = apr_pcalloc(pool, sizeof(*b));
   svn_ra_callbacks2_t *cbtable;
   svn_ra_session_t *session;
-  svn_error_t *err;
+
+  b->magic = TUNNEL_MAGIC;
 
   SVN_ERR(svn_ra_create_callbacks(&cbtable, pool));
   cbtable->check_tunnel_func = check_tunnel;
   cbtable->open_tunnel_func = open_tunnel;
-  cbtable->tunnel_baton = &b;
+  cbtable->tunnel_baton = b;
   SVN_ERR(svn_cmdline_create_auth_baton2(&cbtable->auth_baton,
                                          TRUE  /* non_interactive */,
                                          "jrandom", "rayjandom",
@@ -350,12 +351,12 @@ check_tunnel_callback_test(const svn_tes
                                          FALSE, FALSE, FALSE, FALSE,
                                          NULL, NULL, NULL, pool));
 
-  b.last_check = TRUE;
-  err = svn_ra_open4(&session, NULL, "svn+foo://localhost/no-repo",
-                     NULL, cbtable, NULL, NULL, pool);
-  svn_error_clear(err);
-  SVN_TEST_ASSERT(err);
-  SVN_TEST_ASSERT(!b.last_check);
+  b->last_check = TRUE;
+  SVN_TEST_ASSERT_ERROR(svn_ra_open4(&session, NULL,
+                                     "svn+foo://localhost/no-repo",
+                                     NULL, cbtable, NULL, NULL, pool),
+                        SVN_ERR_RA_CANNOT_CREATE_SESSION);
+  SVN_TEST_ASSERT(!b->last_check);
   return SVN_NO_ERROR;
 }
 
@@ -363,14 +364,15 @@ static svn_error_t *
 tunnel_callback_test(const svn_test_opts_t *opts,
                      apr_pool_t *pool)
 {
-  tunnel_baton_t b = { TUNNEL_MAGIC };
+  tunnel_baton_t *b = apr_pcalloc(pool, sizeof(*b));
   apr_pool_t *scratch_pool = svn_pool_create(pool);
   const char *url;
   svn_ra_callbacks2_t *cbtable;
   svn_ra_session_t *session;
-  svn_error_t *err;
   const char tunnel_repos_name[] = "test-repo-tunnel";
 
+  b->magic = TUNNEL_MAGIC;
+
   SVN_ERR(svn_test__create_repos(NULL, tunnel_repos_name, opts, scratch_pool));
 
   /* Immediately close the repository to avoid race condition with svnserve
@@ -382,7 +384,7 @@ tunnel_callback_test(const svn_test_opts
   SVN_ERR(svn_ra_create_callbacks(&cbtable, pool));
   cbtable->check_tunnel_func = check_tunnel;
   cbtable->open_tunnel_func = open_tunnel;
-  cbtable->tunnel_baton = &b;
+  cbtable->tunnel_baton = b;
   SVN_ERR(svn_cmdline_create_auth_baton2(&cbtable->auth_baton,
                                          TRUE  /* non_interactive */,
                                          "jrandom", "rayjandom",
@@ -392,20 +394,13 @@ tunnel_callback_test(const svn_test_opts
                                          FALSE, FALSE, FALSE, FALSE,
                                          NULL, NULL, NULL, pool));
 
-  b.last_check = FALSE;
-  err = svn_ra_open4(&session, NULL, url, NULL, cbtable, NULL, NULL,
-                     scratch_pool);
-  if (err && err->apr_err == SVN_ERR_TEST_FAILED)
-    {
-      svn_handle_error2(err, stderr, FALSE, "svn_tests: ");
-      svn_error_clear(err);
-      return SVN_NO_ERROR;
-    }
-  SVN_ERR(err);
-  SVN_TEST_ASSERT(b.last_check);
-  SVN_TEST_ASSERT(b.open_count > 0);
+  b->last_check = FALSE;
+  SVN_ERR(svn_ra_open4(&session, NULL, url, NULL, cbtable, NULL, NULL,
+                        scratch_pool));
+  SVN_TEST_ASSERT(b->last_check);
+  SVN_TEST_ASSERT(b->open_count > 0);
   svn_pool_destroy(scratch_pool);
-  SVN_TEST_ASSERT(b.open_count == 0);
+  SVN_TEST_ASSERT(b->open_count == 0);
   return SVN_NO_ERROR;
 }
 
@@ -1517,6 +1512,66 @@ ra_list_has_props(const svn_test_opts_t
   return SVN_NO_ERROR;
 }
 
+/* Test ra_svn tunnel editor handling, including polling. */
+
+static svn_error_t *
+tunnel_run_checkout(const svn_test_opts_t *opts,
+                       apr_pool_t *pool)
+{
+  tunnel_baton_t *b = apr_pcalloc(pool, sizeof(*b));
+  apr_pool_t *scratch_pool = svn_pool_create(pool);
+  const char *url;
+  svn_ra_callbacks2_t *cbtable;
+  svn_ra_session_t *session;
+  const char tunnel_repos_name[] = "test-run_checkout";
+  svn_ra_reporter3_t *reporter;
+  void *report_baton;
+
+  b->magic = TUNNEL_MAGIC;
+
+  SVN_ERR(svn_test__create_repos(NULL, tunnel_repos_name, opts, scratch_pool));
+
+  /* Immediately close the repository to avoid race condition with svnserve
+  (and then the cleanup code) with BDB when our pool is cleared. */
+  svn_pool_clear(scratch_pool);
+
+  url = apr_pstrcat(pool, "svn+test://localhost/", tunnel_repos_name,
+    SVN_VA_NULL);
+  SVN_ERR(svn_ra_create_callbacks(&cbtable, pool));
+  cbtable->check_tunnel_func = check_tunnel;
+  cbtable->open_tunnel_func = open_tunnel;
+  cbtable->tunnel_baton = b;
+  SVN_ERR(svn_cmdline_create_auth_baton2(&cbtable->auth_baton,
+    TRUE  /* non_interactive */,
+    "jrandom", "rayjandom",
+    NULL,
+    TRUE  /* no_auth_cache */,
+    FALSE /* trust_server_cert */,
+    FALSE, FALSE, FALSE, FALSE,
+    NULL, NULL, NULL, pool));
+
+  b->last_check = FALSE;
+
+  SVN_ERR(svn_ra_open4(&session, NULL, url, NULL, cbtable, NULL, NULL,
+                       scratch_pool));
+
+  SVN_ERR(commit_changes(session, pool));
+
+  SVN_ERR(svn_ra_do_update3(session,
+                            &reporter, &report_baton,
+                            1, "",
+                            svn_depth_infinity, FALSE, FALSE,
+                            svn_delta_default_editor(pool), NULL,
+                            pool, pool));
+
+  SVN_ERR(reporter->set_path(report_baton, "", 0, svn_depth_infinity, FALSE,
+                             NULL, pool));
+
+  SVN_ERR(reporter->finish_report(report_baton, pool));
+
+  return SVN_NO_ERROR;
+}
+
 
 /* The test table.  */
 
@@ -1547,7 +1602,14 @@ static struct svn_test_descriptor_t test
                        "check how ra layers handle errors from callbacks"),
     SVN_TEST_OPTS_PASS(ra_list_has_props,
                        "check list has_props performance"),
-    SVN_TEST_NULL
+#ifndef WIN32
+    SVN_TEST_OPTS_PASS(tunnel_run_checkout,
+                       "verify checkout over a tunnel"),
+#else
+    SVN_TEST_OPTS_XFAIL(tunnel_run_checkout,
+                       "verify checkout over a tunnel"),
+#endif
+  SVN_TEST_NULL
   };
 
 SVN_TEST_MAIN



Mime
View raw message