diff options
author | Greg Ames <gregames@apache.org> | 2007-02-09 00:01:21 +0000 |
---|---|---|
committer | Greg Ames <gregames@apache.org> | 2007-02-09 00:01:21 +0000 |
commit | c78a47d05841c905eef18873af1c7468ea43d08f (patch) | |
tree | 760404d1a7aba2e1b8e801b664afaced28315dd7 /test/testatomic.c | |
parent | ca3b4365c498e44b1d21d3855698c114f13e2937 (diff) | |
download | apr-c78a47d05841c905eef18873af1c7468ea43d08f.tar.gz |
add a test for apr_atomic_casptr, used in the
httpd worker and event MPMs
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@505091 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testatomic.c')
-rw-r--r-- | test/testatomic.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/testatomic.c b/test/testatomic.c index b2c8d16df..fff0fa937 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -111,6 +111,39 @@ static void test_cas_notequal(abts_case *tc, void *data) ABTS_INT_EQUAL(tc, 12, casval); } +static void test_casptr_equal(abts_case *tc, void *data) +{ + int a; + volatile void *target_ptr = NULL; + void *old_ptr; + + old_ptr = apr_atomic_casptr(&target_ptr, &a, NULL); + ABTS_PTR_EQUAL(tc, NULL, old_ptr); + ABTS_PTR_EQUAL(tc, &a, (void *) target_ptr); +} + +static void test_casptr_equal_nonnull(abts_case *tc, void *data) +{ + int a, b; + volatile void *target_ptr = &a; + void *old_ptr; + + old_ptr = apr_atomic_casptr(&target_ptr, &b, &a); + ABTS_PTR_EQUAL(tc, &a, old_ptr); + ABTS_PTR_EQUAL(tc, &b, (void *) target_ptr); +} + +static void test_casptr_notequal(abts_case *tc, void *data) +{ + int a, b; + volatile void *target_ptr = &a; + void *old_ptr; + + old_ptr = apr_atomic_casptr(&target_ptr, &a, &b); + ABTS_PTR_EQUAL(tc, &a, old_ptr); + ABTS_PTR_EQUAL(tc, &a, (void *) target_ptr); +} + static void test_add32(abts_case *tc, void *data) { apr_uint32_t oldval; @@ -290,6 +323,9 @@ abts_suite *testatomic(abts_suite *suite) abts_run_test(suite, test_cas_equal, NULL); abts_run_test(suite, test_cas_equal_nonnull, NULL); abts_run_test(suite, test_cas_notequal, NULL); + abts_run_test(suite, test_casptr_equal, NULL); + abts_run_test(suite, test_casptr_equal_nonnull, NULL); + abts_run_test(suite, test_casptr_notequal, NULL); abts_run_test(suite, test_add32, NULL); abts_run_test(suite, test_inc32, NULL); abts_run_test(suite, test_set_add_inc_sub, NULL); |