apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <...@rkbloom.net>
Subject Re: cvs commit: apr/test abts.c globalmutexchild.c testglobalmutex.c
Date Sat, 05 Jun 2004 22:07:22 GMT

On 4 Jun 2004 jerenkrantz@apache.org wrote:

> 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.

In the future, please make these two separate commits.  The changes to
abts are very different from the changes to the global mutex tests.  I am
manually keeping the changes to ABTS files in sync with the master abts
repo.  That is much easier todo if I can flag commits as hitting ABTS and
save them aside as complete patches.


>   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"
>

<snipped for brevity>

>
>   +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

This is much more complex than it needs to be.  You can remove all of the
test_*_exclusive functions, and use the data pointer to pass the correct
lockmech_e.  This is the point of the data pointer, to allow a single
function to be run in different modes and have each call to the function
be a separate test.  So, for example:

lockmech_e type;
type = APR_LOCK_FLOCK;
abts_run_test(suite, test_exclusive, &type);
type = APR_LOCK_FCNTL;
abts_run_test(suite, test_exclusive, &type);

etc.

If nobody beats me to it, I'll make this change sometime.

Ryan


Mime
View raw message