summaryrefslogtreecommitdiff
path: root/test/testatomic.c
diff options
context:
space:
mode:
authorgregames <gregames@13f79535-47bb-0310-9956-ffa450edef68>2007-02-09 00:01:21 +0000
committergregames <gregames@13f79535-47bb-0310-9956-ffa450edef68>2007-02-09 00:01:21 +0000
commitb5fa979c5bf178199c15dabc19518e9f2cc931a7 (patch)
tree760404d1a7aba2e1b8e801b664afaced28315dd7 /test/testatomic.c
parent051fa34e12c6e612da35f900cbcbeebc1332c1f5 (diff)
downloadlibapr-b5fa979c5bf178199c15dabc19518e9f2cc931a7.tar.gz
add a test for apr_atomic_casptr, used in the
httpd worker and event MPMs git-svn-id: http://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.c36
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);