Author: stefan2
Date: Mon Apr 16 17:25:18 2012
New Revision: 1326688

URL: http://svn.apache.org/viewvc?rev=1326688&view=rev
Log:
Skip named_atomics tests if the user does not have the necessary
privileges under Windows.

* subversion/tests/libsvn_subr/named_atomic-test.c
  (has_sufficient_privileges): new function
  (test_basics, test_bignums, test_multiple_atomics,
   test_namespaces, test_multithreaded, test_multiprocess): call it

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

Modified: subversion/trunk/subversion/tests/libsvn_subr/named_atomic-test.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/named_atomic-test.c?rev=1326688&r1=1326687&r2=1326688&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/named_atomic-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/named_atomic-test.c Mon Apr 
16 17:25:18 2012
@@ -341,6 +341,35 @@ calibrate_concurrency(apr_pool_t *pool)
   return SVN_NO_ERROR;
 }
 
+static svn_boolean_t
+has_sufficient_privileges(void)
+{
+#ifdef _WIN32
+  static svn_tristate_t result = svn_tristate_unknown;
+
+  if (result == svn_tristate_unknown)
+    {
+      HANDLE handle = CreateFileMappingA(INVALID_HANDLE_VALUE,
+                                         NULL,
+                                         PAGE_READONLY,
+                                         0,
+                                         1,
+                                         "Global\\__RandomXZY_svn");
+      if (handle != NULL)
+        {
+          CloseHandle(handle);
+          result = svn_tristate_true;
+        }
+      else
+        result = svn_tristate_false;
+    }
+
+  return result == svn_tristate_true ? TRUE : FALSE;
+#else
+  return TRUE;
+#endif
+}
+
 /* The individual tests */
 
 static svn_error_t *
@@ -350,6 +379,10 @@ test_basics(apr_pool_t *pool)
   svn_named_atomic__t *atomic;
   apr_int64_t value;
 
+  /* skip tests if the current user does not have the requried privileges */
+  if (!has_sufficient_privileges())
+    return SVN_NO_ERROR;
+
   SVN_ERR(init_test_shm(pool));
   
   /* Use a separate namespace for our tests isolate them from production */
@@ -430,6 +463,10 @@ test_bignums(apr_pool_t *pool)
   svn_named_atomic__t *atomic;
   apr_int64_t value;
 
+  /* skip tests if the current user does not have the requried privileges */
+  if (!has_sufficient_privileges())
+    return SVN_NO_ERROR;
+
   /* Use a separate namespace for our tests isolate them from production */
   SVN_ERR(svn_atomic_namespace__create(&ns, TEST_NAMESPACE, pool));
 
@@ -480,6 +517,10 @@ test_multiple_atomics(apr_pool_t *pool)
   apr_int64_t value1;
   apr_int64_t value2;
 
+  /* skip tests if the current user does not have the requried privileges */
+  if (!has_sufficient_privileges())
+    return SVN_NO_ERROR;
+
   /* Use a separate namespace for our tests isolate them from production */
   SVN_ERR(svn_atomic_namespace__create(&ns, TEST_NAMESPACE, pool));
 
@@ -545,6 +586,10 @@ test_namespaces(apr_pool_t *pool)
   svn_named_atomic__t *atomic_default;
   apr_int64_t value;
 
+  /* skip tests if the current user does not have the requried privileges */
+  if (!has_sufficient_privileges())
+    return SVN_NO_ERROR;
+
   /* Use a separate namespace for our tests isolate them from production */
   SVN_ERR(svn_atomic_namespace__create(&test_namespace1, TEST_NAMESPACE "1", 
pool));
   SVN_ERR(svn_atomic_namespace__create(&test_namespace1_alias, TEST_NAMESPACE 
"1", pool));
@@ -590,6 +635,10 @@ test_namespaces(apr_pool_t *pool)
 static svn_error_t *
 test_multithreaded(apr_pool_t *pool)
 {
+  /* skip tests if the current user does not have the requried privileges */
+  if (!has_sufficient_privileges())
+    return SVN_NO_ERROR;
+
   SVN_ERR(calibrate_concurrency(pool));
 
   SVN_ERR(init_concurrency_test_shm(pool, hw_thread_count));
@@ -602,6 +651,10 @@ test_multithreaded(apr_pool_t *pool)
 static svn_error_t *
 test_multiprocess(apr_pool_t *pool)
 {
+  /* skip tests if the current user does not have the requried privileges */
+  if (!has_sufficient_privileges())
+    return SVN_NO_ERROR;
+
   SVN_ERR(calibrate_concurrency(pool));
 
   SVN_ERR(init_concurrency_test_shm(pool, hw_thread_count));


Reply via email to