apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r582493 - /apr/apr/branches/1.2.x/test/testatomic.c
Date Sat, 06 Oct 2007 12:46:08 GMT
Author: trawick
Date: Sat Oct  6 05:46:08 2007
New Revision: 582493

URL: http://svn.apache.org/viewvc?rev=582493&view=rev
Log:
merge r505091 and r552360 from trunk

  r505091: add a test for apr_atomic_casptr, used in the
           httpd worker and event MPMs

           gregames

  r552360: Fix assertion message, function tests apr_atomic_inc32(-1).

           davi
    

Modified:
    apr/apr/branches/1.2.x/test/testatomic.c

Modified: apr/apr/branches/1.2.x/test/testatomic.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/test/testatomic.c?rev=582493&r1=582492&r2=582493&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/test/testatomic.c (original)
+++ apr/apr/branches/1.2.x/test/testatomic.c Sat Oct  6 05:46:08 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;
@@ -169,7 +202,7 @@
 
     rv = apr_atomic_inc32(&y32);
 
-    ABTS_ASSERT(tc, "apr_atomic_dec32 on zero returned zero.", rv == minus1);
+    ABTS_ASSERT(tc, "apr_atomic_inc32 on zero returned zero.", rv == minus1);
     str = apr_psprintf(p, "zero wrap failed: -1 + 1 = %d", y32);
     ABTS_ASSERT(tc, str, y32 == 0);
 }
@@ -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);



Mime
View raw message