[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r19215 - trunk/subversion/tests

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-04-07 16:24:33 CEST

Hi Mike,

Sorry my mistake. Thought that 'make check' only runs the python testsuite.
Just ran repos-test C test prog which worked and thought things are fine.

Find the attached patch which ignores the invalid option error to
facilitate recieving arbitary args for testcases.

With regards
Kamesh Jayachandran

[[[
   Fix issue #2532, Make svn C test harness to behave the same way as
   python test harness w.r.t --fs-type, --list switches.

* subversion/tests/svn_test_main.c
  (main): Using apr_getopt to parse the command line switches.
          Thanks to apr_getopt now the svn 'C' test programs,
          can be called with --fs-type [bdb/fsfs].
          The --list switch has been implemented to list the tests.
          Removed the notice message printed, on non-numeric arguments
          beyond argv[1].
]]]
C. Michael Pilato wrote:
> cmpilato@tigris.org wrote:
>
>> Author: cmpilato
>> Date: Thu Apr 6 14:14:51 2006
>> New Revision: 19215
>>
>> Modified:
>> trunk/subversion/tests/svn_test_main.c
>>
>> Log:
>> Revert r19197. Despite all the things I did to review and test this
>> patch, I never actually ran 'make check', which fails instantly. Need
>> to find a way to allow custom options to the C test programs if this
>> is going to work, because libsvn_subr/config-test wants a --srcdir
>> parameter, and libsvn_delta/random-test has a whole slew of things it
>> wants.
>>
>
> *That's* embarrassing.
>
> Kamesh, I think a little more work is needed here. (And once again, a task
> dubbed "bite-sized" by a CollabNet engineer turns out to be larger than
> expected. What else is new?)
>
>

Index: subversion/tests/svn_test_main.c
===================================================================
--- subversion/tests/svn_test_main.c (revision 19185)
+++ subversion/tests/svn_test_main.c (working copy)
@@ -26,6 +26,8 @@
 #include <apr_general.h>
 #include <apr_lib.h>
 
+#include "svn_cmdline.h"
+#include "svn_opt.h"
 #include "svn_pools.h"
 #include "svn_error.h"
 #include "svn_test.h"
@@ -37,7 +39,7 @@
 /* Some Subversion test programs may want to parse options in the
    argument list, so we remember it here. */
 int test_argc;
-char **test_argv;
+const char **test_argv;
 
 
 /* Test option: Print more output */
@@ -46,7 +48,28 @@
 /* Test option: Remove test directories after success */
 static int cleanup_mode = 0;
 
+/* Option parsing enums and structures */
+enum {
+ cleanup_opt = SVN_OPT_FIRST_LONGOPT_ID,
+ fstype_opt,
+ list_opt,
+ verbose_opt
+};
 
+static const apr_getopt_option_t cl_options[] =
+{
+ {"cleanup", cleanup_opt, 0,
+ N_("remove test directories after success")},
+ {"fs-type", fstype_opt, 1,
+ N_("specify a filesystem backend type ARG")},
+ {"list", list_opt, 0,
+ N_("lists all the tests with their short description")},
+ {"verbose", verbose_opt, 0,
+ N_("print extra information")},
+ {0, 0, 0, 0}
+};
+
+
 /* ================================================================= */
 /* Stuff for cleanup processing */
 
@@ -199,15 +222,20 @@
 
 /* Standard svn test program */
 int
-main(int argc, char *argv[])
+main(int argc, const char *argv[])
 {
- char *prog_name;
+ const char *prog_name;
   int test_num;
   int i;
   int got_error = 0;
   apr_pool_t *pool, *test_pool;
   int ran_a_test = 0;
- char **arg;
+ int list_mode = 0;
+ int opt_id;
+ apr_status_t apr_err;
+ apr_getopt_t *os;
+ svn_error_t *err;
+ char errmsg[200];
   /* How many tests are there? */
   int array_size = get_array_size();
   
@@ -244,15 +272,40 @@
   test_argc = argc;
   test_argv = argv;
 
- /* Scan the command line for the --verbose and --cleanup flags */
- for (arg = &argv[1]; *arg; ++arg)
+ err = svn_cmdline__getopt_init(&os, pool, argc, argv);
+ if (err)
+ return svn_cmdline_handle_exit_error(err, pool, prog_name);
+ while (1)
     {
- if (strcmp(*arg, "--cleanup") == 0)
- cleanup_mode = 1;
- else if (strcmp(*arg, "--verbose") == 0)
- verbose_mode = 1;
- else if (strncmp(*arg, "--fs-type=", 10) == 0)
- opts.fs_type = apr_pstrdup(pool, (*arg) + 10);
+ const char *opt_arg;
+
+ /* Parse the next option. */
+ apr_err = apr_getopt_long(os, cl_options, &opt_id, &opt_arg);
+ if (APR_STATUS_IS_EOF(apr_err))
+ break;
+ else if (apr_err && (apr_err != APR_BADCH))
+ {
+ //ignore invalid option error to allow passing arbitary options
+ //for testcases linking against this.
+ fprintf(stderr,"apr_getopt_long failed : [%d] %s\n",
+ apr_err, apr_strerror(apr_err, (char*)errmsg, 200));
+ exit(1);
+ }
+
+ switch (opt_id) {
+ case cleanup_opt:
+ cleanup_mode = 1;
+ break;
+ case fstype_opt:
+ opts.fs_type = apr_pstrdup(pool, opt_arg);
+ break;
+ case list_opt:
+ list_mode = 1;
+ break;
+ case verbose_opt:
+ verbose_mode = 1;
+ break;
+ }
     }
 
   /* Create an iteration pool for the tests */
@@ -261,7 +314,7 @@
 
   if (argc >= 2) /* notice command-line arguments */
     {
- if (! strcmp(argv[1], "list"))
+ if (! strcmp(argv[1], "list") || list_mode)
         {
           ran_a_test = 1;
 
@@ -294,11 +347,6 @@
                   svn_pool_clear(test_pool);
                   svn_pool_clear(cleanup_pool);
                 }
- else if (argv[i][0] != '-')
- {
- /* (probably) a source directory pathname */
- printf("notice: ignoring argument %d: '%s'\n", i, argv[i]);
- }
             }
         }
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Apr 7 16:25:31 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.