diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-11-23 20:26:17 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-11-23 20:26:17 +0000 |
commit | d973c3f25a6ab56e12b9f858b0692ec4297d84c9 (patch) | |
tree | 3a28d4ddb63bd852867237ca6bfd8e013a5663b7 /test/testdyn.c | |
parent | a5bdf86e5b89a7abb281ac5514c7d6cb4d64c365 (diff) | |
download | ChibiOS-d973c3f25a6ab56e12b9f858b0692ec4297d84c9.tar.gz ChibiOS-d973c3f25a6ab56e12b9f858b0692ec4297d84c9.tar.bz2 ChibiOS-d973c3f25a6ab56e12b9f858b0692ec4297d84c9.zip |
Fixed bug 3116888.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2425 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/testdyn.c')
-rw-r--r-- | test/testdyn.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/test/testdyn.c b/test/testdyn.c index 69a1c3312..2035224a1 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -190,16 +190,16 @@ ROMCONST struct testcase testdyn2 = { * coverage.
*/
-static unsigned regscan(void) {
- Thread *tp;
- unsigned i = 0;
+static bool_t regfind(Thread *tp) {
+ Thread *ftp;
+ bool_t found = FALSE;
- tp = chRegFirstThread();
+ ftp = chRegFirstThread();
do {
- i++;
- tp = chRegNextThread(tp);
- } while (tp != NULL);
- return i;
+ found |= ftp == tp;
+ ftp = chRegNextThread(ftp);
+ } while (ftp != NULL);
+ return found;
}
static void dyn3_setup(void) {
@@ -208,15 +208,9 @@ static void dyn3_setup(void) { }
static void dyn3_execute(void) {
- unsigned n1, n2, n3;
Thread *tp;
tprio_t prio = chThdGetPriority();
- /* Current number of threads in the system, two times just in case some
- external detached thread terminated.*/
- (void)regscan();
- n1 = regscan();
-
/* Testing references increase/decrease and final detach.*/
tp = chThdCreateFromHeap(&heap1, WA_SIZE, prio-1, thread, "A");
test_assert(1, tp->p_refs == 1, "wrong initial reference counter");
@@ -226,18 +220,21 @@ static void dyn3_execute(void) { test_assert(3, tp->p_refs == 1, "references decrease failure");
/* Verify the new threads count.*/
- n2 = regscan();
- test_assert(4, n1 == n2 - 1, "unexpected threads count");
+ test_assert(4, regfind(tp), "thread missing from registry");
+ test_assert(5, regfind(tp), "thread disappeared");
/* Detach and let the thread execute and terminate.*/
chThdRelease(tp);
- test_assert(5, tp->p_refs == 0, "detach failure");
+ test_assert(6, tp->p_refs == 0, "detach failure");
+ test_assert(7, tp->p_state == THD_STATE_READY, "invalid state");
+ test_assert(8, regfind(tp), "thread disappeared");
+ test_assert(9, regfind(tp), "thread disappeared");
chThdSleepMilliseconds(50); /* The thread just terminates. */
- test_assert(6, tp->p_state == THD_STATE_FINAL, "invalid state");
+ test_assert(10, tp->p_state == THD_STATE_FINAL, "invalid state");
/* Clearing the zombie by scanning the registry.*/
- n3 = regscan();
- test_assert(7, n1 == n3, "unexpected threads count");
+ test_assert(11, regfind(tp), "thread disappeared");
+ test_assert(12, !regfind(tp), "thread still in registry");
}
ROMCONST struct testcase testdyn3 = {
|