subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phi...@apache.org
Subject svn commit: r1728464 - /subversion/trunk/subversion/tests/svn_test_main.c
Date Thu, 04 Feb 2016 13:04:48 GMT
Author: philip
Date: Thu Feb  4 13:04:47 2016
New Revision: 1728464

URL: http://svn.apache.org/viewvc?rev=1728464&view=rev
Log:
* subversion/tests/svn_test_main.c
  (do_test_num): Introduce a local variable and set another variable later
   to avoid potential setjmp/longjmp clobbers.

Modified:
    subversion/trunk/subversion/tests/svn_test_main.c

Modified: subversion/trunk/subversion/tests/svn_test_main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_main.c?rev=1728464&r1=1728463&r2=1728464&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_main.c (original)
+++ subversion/trunk/subversion/tests/svn_test_main.c Thu Feb  4 13:04:47 2016
@@ -407,26 +407,29 @@ do_test_num(const char *progname,
             apr_pool_t *pool)
 {
   svn_boolean_t skip, xfail, wimp;
-  svn_error_t *err = NULL;
+  svn_error_t *err;
   const char *msg = NULL;  /* the message this individual test prints out */
   const struct svn_test_descriptor_t *desc;
   const int array_size = get_array_size(test_funcs);
   svn_boolean_t run_this_test; /* This test's mode matches DESC->MODE. */
   enum svn_test_mode_t test_mode;
+  volatile int adjusted_num = test_num; /* volatile for setjmp */
+
+  /* This allows './some-test -- -1' to run the last test. */
+  if (adjusted_num < 0)
+    adjusted_num += array_size + 1;
 
   /* Check our array bounds! */
-  if (test_num < 0)
-    test_num += array_size + 1;
-  if ((test_num > array_size) || (test_num <= 0))
+  if ((adjusted_num > array_size) || (adjusted_num <= 0))
     {
       if (header_msg && *header_msg)
         printf("%s", *header_msg);
-      printf("FAIL: %s: THERE IS NO TEST NUMBER %2d\n", progname, test_num);
+      printf("FAIL: %s: THERE IS NO TEST NUMBER %2d\n", progname, adjusted_num);
       skip_cleanup = TRUE;
       return TRUE;  /* BAIL, this test number doesn't exist. */
     }
 
-  desc = &test_funcs[test_num];
+  desc = &test_funcs[adjusted_num];
   /* Check the test predicate. */
   if (desc->predicate.func
       && desc->predicate.func(opts, desc->predicate.value, pool))
@@ -462,7 +465,7 @@ do_test_num(const char *progname,
     {
       /* Do test */
       if (msg_only || skip || !run_this_test)
-        ; /* pass */
+        err = NULL; /* pass */
       else if (desc->func2)
         err = (*desc->func2)(pool);
       else
@@ -480,7 +483,7 @@ do_test_num(const char *progname,
     }
 
   /* Failure means unexpected results -- FAIL or XPASS. */
-  skip_cleanup = log_results(progname, test_num, msg_only, run_this_test,
+  skip_cleanup = log_results(progname, adjusted_num, msg_only, run_this_test,
                              skip, xfail, wimp, err, msg, desc);
 
   return skip_cleanup;



Mime
View raw message