apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: apr/test abts.c globalmutexchild.c testglobalmutex.c
Date Fri, 04 Jun 2004 08:44:15 GMT
jerenkrantz    2004/06/04 01:44:15

  Modified:    test     abts.c globalmutexchild.c testglobalmutex.c
  Log:
  Various test suite improvements to actually test the global mutex code with all
  of the available methods.
  
  abts.c: Properly strip prefix and .c extension (was broken if . character is
          in your path!); specify 'testfoo' rather than 'path/to/testfoo' now
  globalmutexchild.c: Pass along the mutex mechanism to the child via args[1].
  testglobalmutex.c: Invoke test for every global mutex method available.
  
  Revision  Changes    Path
  1.9       +8 -2      apr/test/abts.c
  
  Index: abts.c
  ===================================================================
  RCS file: /home/cvs/apr/test/abts.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -u -r1.8 -r1.9
  --- abts.c	24 May 2004 18:39:50 -0000	1.8
  +++ abts.c	4 Jun 2004 08:44:15 -0000	1.9
  @@ -85,10 +85,11 @@
       }
   }
   
  -abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name)
  +abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full)
   {
       sub_suite *subsuite;
       char *p;
  +    const char *suite_name;
       curr_char = 0;
       
       /* Only end the suite if we actually ran it */
  @@ -100,7 +101,12 @@
       subsuite->num_test = 0;
       subsuite->failed = 0;
       subsuite->next = NULL;
  -    p = strchr(suite_name, '.');
  +    /* suite_name_full is the complete path of the source code; strip out. */
  +    suite_name = strrchr(suite_name_full, '/') + 1;
  +    if (!suite_name) {
  +        suite_name = suite_name_full;
  +    }
  +    p = strrchr(suite_name, '.');
       if (p)
           subsuite->name = memcpy(calloc(p - suite_name + 1, 1),
                                   suite_name, p - suite_name);
  
  
  
  1.2       +12 -1     apr/test/globalmutexchild.c
  
  Index: globalmutexchild.c
  ===================================================================
  RCS file: /home/cvs/apr/test/globalmutexchild.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -u -r1.1 -r1.2
  --- globalmutexchild.c	15 Mar 2004 18:33:30 -0000	1.1
  +++ globalmutexchild.c	4 Jun 2004 08:44:15 -0000	1.2
  @@ -29,13 +29,24 @@
   {
       apr_pool_t *p;
       int i = 0;
  +    apr_lockmech_e mech;
       apr_global_mutex_t *global_lock;
  +    apr_status_t rv;
   
       apr_initialize();
       atexit(apr_terminate);
       
       apr_pool_create(&p, NULL);
  -    apr_global_mutex_create(&global_lock, LOCKNAME, APR_LOCK_DEFAULT, p);
  +    if (argc >= 2) {
  +        mech = (apr_lockmech_e)apr_strtoi64(argv[1], NULL, 0);
  +    }
  +    else {
  +        mech = APR_LOCK_DEFAULT;
  +    }
  +    rv = apr_global_mutex_create(&global_lock, LOCKNAME, mech, p);
  +    if (rv != APR_SUCCESS) {
  +        exit(-rv);
  +    }
       apr_global_mutex_child_init(&global_lock, LOCKNAME, p);
       
       while (1) {
  
  
  
  1.10      +57 -11    apr/test/testglobalmutex.c
  
  Index: testglobalmutex.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testglobalmutex.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -u -r1.9 -r1.10
  --- testglobalmutex.c	14 May 2004 14:43:22 -0000	1.9
  +++ testglobalmutex.c	4 Jun 2004 08:44:15 -0000	1.10
  @@ -19,10 +19,11 @@
   #include "apr_errno.h"
   #include "testutil.h"
   
  -static void launch_child(abts_case *tc, apr_proc_t *proc, apr_pool_t *p)
  +static void launch_child(abts_case *tc, apr_lockmech_e mech,
  +                         apr_proc_t *proc, apr_pool_t *p)
   {
       apr_procattr_t *procattr;
  -    const char *args[2];
  +    const char *args[3];
       apr_status_t rv;
   
       rv = apr_procattr_create(&procattr, p);
  @@ -36,7 +37,8 @@
       apr_assert_success(tc, "Couldn't set error check in procattr", rv);
   
       args[0] = "globalmutexchild" EXTENSION;
  -    args[1] = NULL;
  +    args[1] = (const char*)apr_itoa(p, (int)mech);
  +    args[2] = NULL;
       rv = apr_proc_create(proc, "./globalmutexchild" EXTENSION, args, NULL,
               procattr, p);
       apr_assert_success(tc, "Couldn't launch program", rv);
  @@ -54,21 +56,20 @@
       return exitcode;
   }
   
  -static void test_exclusive(abts_case *tc, void *data)
  +static void test_exclusive(abts_case *tc, void *data, apr_lockmech_e mech)
   {
       apr_proc_t p1, p2, p3, p4;
       apr_status_t rv;
       apr_global_mutex_t *global_lock;
       int x = 0;
    
  -    rv = apr_global_mutex_create(&global_lock, LOCKNAME, APR_LOCK_DEFAULT, p);
  +    rv = apr_global_mutex_create(&global_lock, LOCKNAME, mech, p);
       apr_assert_success(tc, "Error creating mutex", rv);
   
  -
  -    launch_child(tc, &p1, p);
  -    launch_child(tc, &p2, p);
  -    launch_child(tc, &p3, p);
  -    launch_child(tc, &p4, p);
  +    launch_child(tc, mech, &p1, p);
  +    launch_child(tc, mech, &p2, p);
  +    launch_child(tc, mech, &p3, p);
  +    launch_child(tc, mech, &p4, p);
    
       x += wait_child(tc, &p1);
       x += wait_child(tc, &p2);
  @@ -78,11 +79,56 @@
       ABTS_INT_EQUAL(tc, MAX_COUNTER, x);
   }
   
  +static void test_exclusive_default(abts_case *tc, void *data)
  +{
  +    test_exclusive(tc, data, APR_LOCK_DEFAULT);
  +}
  +
  +static void test_exclusive_posixsem(abts_case *tc, void *data)
  +{
  +    test_exclusive(tc, data, APR_LOCK_POSIXSEM);
  +}
  +
  +static void test_exclusive_sysvsem(abts_case *tc, void *data)
  +{
  +    test_exclusive(tc, data, APR_LOCK_SYSVSEM);
  +}
  +
  +static void test_exclusive_proc_pthread(abts_case *tc, void *data)
  +{
  +    test_exclusive(tc, data, APR_LOCK_PROC_PTHREAD);
  +}
  +
  +static void test_exclusive_fcntl(abts_case *tc, void *data)
  +{
  +    test_exclusive(tc, data, APR_LOCK_FCNTL);
  +}
  +
  +static void test_exclusive_flock(abts_case *tc, void *data)
  +{
  +    test_exclusive(tc, data, APR_LOCK_FLOCK);
  +}
  +
   abts_suite *testglobalmutex(abts_suite *suite)
   {
       suite = ADD_SUITE(suite)
   
  -    abts_run_test(suite, test_exclusive, NULL);
  +    abts_run_test(suite, test_exclusive_default, NULL);
  +#if APR_HAS_POSIXSEM_SERIALIZE
  +    abts_run_test(suite, test_exclusive_posixsem, NULL);
  +#endif
  +#if APR_HAS_SYSVSEM_SERIALIZE
  +    abts_run_test(suite, test_exclusive_sysvsem, NULL);
  +#endif
  +#if APR_HAS_PROC_PTHREAD_SERIALIZE
  +    abts_run_test(suite, test_exclusive_proc_pthread, NULL);
  +#endif
  +#if APR_HAS_FCNTL_SERIALIZE
  +    abts_run_test(suite, test_exclusive_fcntl, NULL);
  +#endif
  +#if APR_HAS_FLOCK_SERIALIZE
  +    abts_run_test(suite, test_exclusive_flock, NULL);
  +#endif
   
       return suite;
   }
  
  
  

Mime
View raw message