You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by rb...@apache.org on 2002/10/22 20:10:27 UTC
cvs commit: apr/test Makefile.in test_apr.h testall.c testsleep.c
rbb 2002/10/22 11:10:27
Modified: test Makefile.in test_apr.h testall.c testsleep.c
Log:
Port testsleep to the new test suite.
Revision Changes Path
1.96 +2 -2 apr/test/Makefile.in
Index: Makefile.in
===================================================================
RCS file: /home/cvs/apr/test/Makefile.in,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- Makefile.in 22 Oct 2002 05:44:12 -0000 1.95
+++ Makefile.in 22 Oct 2002 18:10:26 -0000 1.96
@@ -209,8 +209,8 @@
testtable@EXEEXT@: testtable.lo $(LOCAL_LIBS)
$(LINK) testtable.lo $(LOCAL_LIBS) $(ALL_LIBS)
-testall: testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo testud.lo testtable.lo CuTest.lo $(LOCAL_LIBS)
- $(LINK) testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo testud.lo testtable.lo CuTest.lo $(LOCAL_LIBS) $(ALL_LIBS)
+testall: testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo testud.lo testtable.lo testsleep.lo CuTest.lo $(LOCAL_LIBS)
+ $(LINK) testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo testud.lo testtable.lo testsleep.lo CuTest.lo $(LOCAL_LIBS) $(ALL_LIBS)
# DO NOT REMOVE
1.16 +1 -0 apr/test/test_apr.h
Index: test_apr.h
===================================================================
RCS file: /home/cvs/apr/test/test_apr.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- test_apr.h 22 Oct 2002 05:44:12 -0000 1.15
+++ test_apr.h 22 Oct 2002 18:10:26 -0000 1.16
@@ -73,6 +73,7 @@
CuSuite *testmmap(void);
CuSuite *testud(void);
CuSuite *testtable(void);
+CuSuite *testsleep(void);
1.8 +1 -0 apr/test/testall.c
Index: testall.c
===================================================================
RCS file: /home/cvs/apr/test/testall.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- testall.c 22 Oct 2002 05:44:12 -0000 1.7
+++ testall.c 22 Oct 2002 18:10:26 -0000 1.8
@@ -71,6 +71,7 @@
testmmap,
testud,
testtable,
+ testsleep,
NULL
};
1.9 +25 -59 apr/test/testsleep.c
Index: testsleep.c
===================================================================
RCS file: /home/cvs/apr/test/testsleep.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- testsleep.c 5 Jul 2002 00:11:11 -0000 1.8
+++ testsleep.c 22 Oct 2002 18:10:26 -0000 1.9
@@ -52,7 +52,7 @@
* <http://www.apache.org/>.
*/
-#include "apr_time.h"
+#include "time.h"
#include "apr_thread_proc.h"
#include "apr_errno.h"
#include "apr_general.h"
@@ -62,73 +62,39 @@
#include <stdlib.h>
#include "test_apr.h"
+#define SLEEP_INTERVAL 5
-static void do_sleep(int howlong)
+static void sleep_one(CuTest *tc)
{
- apr_time_t then, now, diff;
- apr_time_t interval = apr_time_from_sec(howlong);
-
- printf(" I'm about to go to sleep!\n");
-
- then = apr_time_now();
- apr_sleep(interval);
- now = apr_time_now();
-
- diff = now - then;
-
- printf("%-60s"," Just woken up, checking how long I've been asleep");
- if (diff < interval * 0.99 || diff > interval * 1.01) {
- printf("Failed!\n\t(actual: %" APR_TIME_T_FMT
- ", wanted: %" APR_TIME_T_FMT")\n", diff, interval);
- } else {
- printf("OK\n");
- }
+ time_t pretime = time(NULL);
+ time_t posttime;
+ time_t timediff;
+
+ apr_sleep(apr_time_from_sec(SLEEP_INTERVAL));
+ posttime = time(NULL);
+
+ /* normalize the timediff. We should have slept for SLEEP_INTERVAL, so
+ * we should just subtract that out.
+ */
+ timediff = posttime - pretime - SLEEP_INTERVAL;
+ CuAssertTrue(tc, timediff >= 0);
+ CuAssertTrue(tc, timediff <= 1);
}
-#if APR_HAS_THREADS
-static void * APR_THREAD_FUNC time_a_thread(apr_thread_t *thd, void *data)
+CuSuite *testsleep(void)
{
- do_sleep(15);
+ CuSuite *suite = CuSuiteNew("Test Sleep");
+
+ SUITE_ADD_TEST(suite, sleep_one);
- return NULL;
+ return suite;
}
-#define OUTPUT_LINES 8
-#else
-#define OUTPUT_LINES 2
-#endif /* APR_HAS_THREADS */
-int main(void)
+#ifdef SINGLE_PROG
+CuSuite *getsuite(void)
{
- apr_pool_t *p;
-#if APR_HAS_THREADS
- apr_thread_t *t1, *t2, *t3;
- apr_status_t rv;
-#endif
-
- apr_initialize();
-
- printf("Testing apr_sleep()\n===================\n\n");
-
- STD_TEST_NEQ("Creating a pool to use", apr_pool_create(&p, NULL))
-
-#if APR_HAS_THREADS
- printf("\nI will now start 3 threads, each of which should sleep for\n"
- "15 seconds, then exit.\n");
-#endif
-
- printf("The main app will sleep for 45 seconds then wake up.\n");
- printf("All tests will check how long they've been in the land of nod.\n\n");
- printf("If all is working you should see %d lines below within 45 seconds.\n\n",
- OUTPUT_LINES);
-
-#if APR_HAS_THREADS
- rv = apr_thread_create(&t1, NULL, time_a_thread, NULL, p);
- rv = apr_thread_create(&t2, NULL, time_a_thread, NULL, p);
- rv = apr_thread_create(&t3, NULL, time_a_thread, NULL, p);
+ return testsleep();
+}
#endif
- do_sleep(45);
-
- return 0;
-}
Re: cvs commit: apr/test Makefile.in test_apr.h testall.c testsleep.c
Posted by rb...@apache.org.
On 22 Oct 2002 rbb@apache.org wrote:
> rbb 2002/10/22 11:10:27
>
> Modified: test Makefile.in test_apr.h testall.c testsleep.c
> Log:
> Port testsleep to the new test suite.
This test has actually shown a problem with the new test
suite. Basically, it runs all of the tests, and then prints all of the
output. There are a couple of ways to fix this, and I will fix it in the
next week or so. The way that this manifests itself, is that the test
suite now pauses for 5 seconds at the start of running the tests and then
prints the results.
Ryan
_______________________________________________________________________________
Ryan Bloom rbb@apache.org
550 Jean St
Oakland CA 94610
-------------------------------------------------------------------------------
Re: cvs commit: apr/test Makefile.in test_apr.h testall.c testsleep.c
Posted by rb...@apache.org.
On 22 Oct 2002 rbb@apache.org wrote:
> rbb 2002/10/22 11:10:27
>
> Modified: test Makefile.in test_apr.h testall.c testsleep.c
> Log:
> Port testsleep to the new test suite.
This test has actually shown a problem with the new test
suite. Basically, it runs all of the tests, and then prints all of the
output. There are a couple of ways to fix this, and I will fix it in the
next week or so. The way that this manifests itself, is that the test
suite now pauses for 5 seconds at the start of running the tests and then
prints the results.
Ryan
_______________________________________________________________________________
Ryan Bloom rbb@apache.org
550 Jean St
Oakland CA 94610
-------------------------------------------------------------------------------