summaryrefslogtreecommitdiff
path: root/test/testlock.c
diff options
context:
space:
mode:
authorRyan Bloom <rbb@apache.org>2004-05-13 00:50:20 +0000
committerRyan Bloom <rbb@apache.org>2004-05-13 00:50:20 +0000
commita2aae73a6bdbaf646c2b835d5df49df7defb7dfd (patch)
tree7efbac56f447f9a37ff68adec5fe28a9ec5cbb79 /test/testlock.c
parent0de2e2b698a1ee2fff07f9962441d63ecf35b13d (diff)
downloadapr-a2aae73a6bdbaf646c2b835d5df49df7defb7dfd.tar.gz
Move the APR test suite from CuTest to abts. The output is cleaner,
and it prints output while running the test. Also, if a test fails the rest of the test function is run, allowing for proper cleanup. Finally, it is possible to call the same function multiple times with different data, and each call is considered a separate test. This is the first of a multi-step process to get a more useful test suite. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@65091 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testlock.c')
-rw-r--r--test/testlock.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/test/testlock.c b/test/testlock.c
index 0bd226a46..7609c7ec1 100644
--- a/test/testlock.c
+++ b/test/testlock.c
@@ -21,7 +21,7 @@
#include "apr_errno.h"
#include "apr_general.h"
#include "apr_getopt.h"
-#include "test_apr.h"
+#include "testutil.h"
#if APR_HAS_THREADS
@@ -148,43 +148,43 @@ static void *APR_THREAD_FUNC thread_cond_consumer(apr_thread_t *thd, void *data)
return NULL;
}
-static void test_thread_mutex(CuTest *tc)
+static void test_thread_mutex(abts_case *tc, void *data)
{
apr_thread_t *t1, *t2, *t3, *t4;
apr_status_t s1, s2, s3, s4;
s1 = apr_thread_mutex_create(&thread_mutex, APR_THREAD_MUTEX_DEFAULT, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s1);
- CuAssertPtrNotNull(tc, thread_mutex);
+ abts_int_equal(tc, APR_SUCCESS, s1);
+ abts_ptr_notnull(tc, thread_mutex);
i = 0;
x = 0;
s1 = apr_thread_create(&t1, NULL, thread_mutex_function, NULL, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s1);
+ abts_int_equal(tc, APR_SUCCESS, s1);
s2 = apr_thread_create(&t2, NULL, thread_mutex_function, NULL, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s2);
+ abts_int_equal(tc, APR_SUCCESS, s2);
s3 = apr_thread_create(&t3, NULL, thread_mutex_function, NULL, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s3);
+ abts_int_equal(tc, APR_SUCCESS, s3);
s4 = apr_thread_create(&t4, NULL, thread_mutex_function, NULL, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s4);
+ abts_int_equal(tc, APR_SUCCESS, s4);
apr_thread_join(&s1, t1);
apr_thread_join(&s2, t2);
apr_thread_join(&s3, t3);
apr_thread_join(&s4, t4);
- CuAssertIntEquals(tc, MAX_ITER, x);
+ abts_int_equal(tc, MAX_ITER, x);
}
-static void test_thread_rwlock(CuTest *tc)
+static void test_thread_rwlock(abts_case *tc, void *data)
{
apr_thread_t *t1, *t2, *t3, *t4;
apr_status_t s1, s2, s3, s4;
s1 = apr_thread_rwlock_create(&rwlock, p);
apr_assert_success(tc, "rwlock_create", s1);
- CuAssertPtrNotNull(tc, rwlock);
+ abts_ptr_notnull(tc, rwlock);
i = 0;
x = 0;
@@ -203,10 +203,10 @@ static void test_thread_rwlock(CuTest *tc)
apr_thread_join(&s3, t3);
apr_thread_join(&s4, t4);
- CuAssertIntEquals(tc, MAX_ITER, x);
+ abts_int_equal(tc, MAX_ITER, x);
}
-static void test_cond(CuTest *tc)
+static void test_cond(abts_case *tc, void *data)
{
apr_thread_t *p1, *p2, *p3, *p4, *c1;
apr_status_t s0, s1, s2, s3, s4;
@@ -216,16 +216,16 @@ static void test_cond(CuTest *tc)
apr_assert_success(tc, "create put mutex",
apr_thread_mutex_create(&put.mutex,
APR_THREAD_MUTEX_DEFAULT, p));
- CuAssertPtrNotNull(tc, put.mutex);
+ abts_ptr_notnull(tc, put.mutex);
apr_assert_success(tc, "create nready mutex",
apr_thread_mutex_create(&nready.mutex,
APR_THREAD_MUTEX_DEFAULT, p));
- CuAssertPtrNotNull(tc, nready.mutex);
+ abts_ptr_notnull(tc, nready.mutex);
apr_assert_success(tc, "create condvar",
apr_thread_cond_create(&nready.cond, p));
- CuAssertPtrNotNull(tc, nready.cond);
+ abts_ptr_notnull(tc, nready.cond);
count1 = count2 = count3 = count4 = 0;
put.nput = put.nval = 0;
@@ -234,15 +234,15 @@ static void test_cond(CuTest *tc)
x = 0;
s0 = apr_thread_create(&p1, NULL, thread_cond_producer, &count1, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s0);
+ abts_int_equal(tc, APR_SUCCESS, s0);
s1 = apr_thread_create(&p2, NULL, thread_cond_producer, &count2, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s1);
+ abts_int_equal(tc, APR_SUCCESS, s1);
s2 = apr_thread_create(&p3, NULL, thread_cond_producer, &count3, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s2);
+ abts_int_equal(tc, APR_SUCCESS, s2);
s3 = apr_thread_create(&p4, NULL, thread_cond_producer, &count4, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s3);
+ abts_int_equal(tc, APR_SUCCESS, s3);
s4 = apr_thread_create(&c1, NULL, thread_cond_consumer, NULL, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s4);
+ abts_int_equal(tc, APR_SUCCESS, s4);
apr_thread_join(&s0, p1);
apr_thread_join(&s1, p2);
@@ -258,10 +258,10 @@ static void test_cond(CuTest *tc)
printf("count1 = %d count2 = %d count3 = %d count4 = %d\n",
count1, count2, count3, count4);
*/
- CuAssertIntEquals(tc, MAX_COUNTER, sum);
+ abts_int_equal(tc, MAX_COUNTER, sum);
}
-static void test_timeoutcond(CuTest *tc)
+static void test_timeoutcond(abts_case *tc, void *data)
{
apr_status_t s;
apr_interval_time_t timeout;
@@ -269,12 +269,12 @@ static void test_timeoutcond(CuTest *tc)
int i;
s = apr_thread_mutex_create(&timeout_mutex, APR_THREAD_MUTEX_DEFAULT, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s);
- CuAssertPtrNotNull(tc, timeout_mutex);
+ abts_int_equal(tc, APR_SUCCESS, s);
+ abts_ptr_notnull(tc, timeout_mutex);
s = apr_thread_cond_create(&timeout_cond, p);
- CuAssertIntEquals(tc, APR_SUCCESS, s);
- CuAssertPtrNotNull(tc, timeout_cond);
+ abts_int_equal(tc, APR_SUCCESS, s);
+ abts_ptr_notnull(tc, timeout_cond);
timeout = apr_time_from_sec(5);
@@ -289,34 +289,34 @@ static void test_timeoutcond(CuTest *tc)
if (s != APR_SUCCESS && !APR_STATUS_IS_TIMEUP(s)) {
continue;
}
- CuAssertIntEquals(tc, 1, APR_STATUS_IS_TIMEUP(s));
- CuAssert(tc, "Timer returned too late", end - begin - timeout < 100000);
+ abts_int_equal(tc, 1, APR_STATUS_IS_TIMEUP(s));
+ abts_assert(tc, "Timer returned too late", end - begin - timeout < 100000);
break;
}
- CuAssert(tc, "Too many retries", i < MAX_RETRY);
+ abts_assert(tc, "Too many retries", i < MAX_RETRY);
}
#endif /* !APR_HAS_THREADS */
#if !APR_HAS_THREADS
-static void threads_not_impl(CuTest *tc)
+static void threads_not_impl(abts_case *tc, void *data)
{
- CuNotImpl(tc, "Threads not implemented on this platform");
+ abts_not_impl(tc, "Threads not implemented on this platform");
}
#endif
-CuSuite *testlock(void)
+abts_suite *testlock(abts_suite *suite)
{
- CuSuite *suite = CuSuiteNew("Thread Locks");
+ suite = ADD_SUITE(suite)
#if !APR_HAS_THREADS
- SUITE_ADD_TEST(suite, threads_not_impl);
+ abts_run_test(suite, threads_not_impl, NULL);
#else
- SUITE_ADD_TEST(suite, test_thread_mutex);
- SUITE_ADD_TEST(suite, test_thread_rwlock);
- SUITE_ADD_TEST(suite, test_cond);
- SUITE_ADD_TEST(suite, test_timeoutcond);
+ abts_run_test(suite, test_thread_mutex, NULL);
+ abts_run_test(suite, test_thread_rwlock, NULL);
+ abts_run_test(suite, test_cond, NULL);
+ abts_run_test(suite, test_timeoutcond, NULL);
#endif
return suite;