You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by gr...@apache.org on 2007/02/09 01:01:22 UTC
svn commit: r505091 - /apr/apr/trunk/test/testatomic.c
Author: gregames
Date: Thu Feb 8 16:01:21 2007
New Revision: 505091
URL: http://svn.apache.org/viewvc?view=rev&rev=505091
Log:
add a test for apr_atomic_casptr, used in the
httpd worker and event MPMs
Modified:
apr/apr/trunk/test/testatomic.c
Modified: apr/apr/trunk/test/testatomic.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testatomic.c?view=diff&rev=505091&r1=505090&r2=505091
==============================================================================
--- apr/apr/trunk/test/testatomic.c (original)
+++ apr/apr/trunk/test/testatomic.c Thu Feb 8 16:01:21 2007
@@ -111,6 +111,39 @@
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_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);