You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by br...@apache.org on 2002/10/19 21:06:44 UTC
cvs commit: apr/test testatomic.c
brianp 2002/10/19 12:06:44
Modified: test testatomic.c
Log:
updated testatomic to cover apr_atomic_casptr
Revision Changes Path
1.18 +28 -1 apr/test/testatomic.c
Index: testatomic.c
===================================================================
RCS file: /home/cvs/apr/test/testatomic.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- testatomic.c 22 Sep 2002 03:47:01 -0000 1.17
+++ testatomic.c 19 Oct 2002 19:06:44 -0000 1.18
@@ -83,7 +83,11 @@
static apr_status_t check_basic_atomics(volatile apr_atomic_t*p)
{
apr_atomic_t oldval;
- apr_atomic_t casval = 0;
+ apr_uint32_t casval = 0;
+ float object1, object2;
+ void *casptr;
+ void *oldptr;
+
apr_atomic_set(&y, 2);
printf("%-60s", "testing apr_atomic_dec");
if (apr_atomic_dec(&y) == 0) {
@@ -118,6 +122,29 @@
if (oldval != 23) {
fprintf(stderr, "Failed\noldval =%d should be 23 y=%d\n",
oldval, casval);
+ return APR_EGENERAL;
+ }
+ printf("OK\n");
+
+ printf("%-60s", "testing CAS for pointers");
+ casptr = NULL;
+ oldptr = apr_atomic_casptr(&casptr, &object1, 0);
+ if (oldptr != 0) {
+ fprintf(stderr, "Failed\noldval =%p should be zero\n", oldptr);
+ return APR_EGENERAL;
+ }
+ printf("OK\n");
+ printf("%-60s", "testing CAS for pointers - match non-null");
+ oldptr = apr_atomic_casptr(&casptr, &object2, &object1);
+ if (oldptr != &object1) {
+ fprintf(stderr, "Failed\noldval =%p should be %p\n", oldptr, &object1);
+ return APR_EGENERAL;
+ }
+ printf("OK\n");
+ printf("%-60s", "testing CAS - no match");
+ oldptr = apr_atomic_casptr(&casptr, &object2, &object1);
+ if (oldptr != &object2) {
+ fprintf(stderr, "Failed\noldval =%p should be %p\n", oldptr, &object2);
return APR_EGENERAL;
}
printf("OK\n");