aboutsummaryrefslogtreecommitdiffstats
path: root/test/testcond.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-03-09 11:17:02 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-03-09 11:17:02 +0000
commita2bab9c63d848ccfce1440afd40e1eed7b2955ef (patch)
tree4ea1f9626299ab6aa751f0e283fb5279ea1e60c9 /test/testcond.c
parent18a4e9013ef9d822c9b6a35cbac4cd3eea20eb51 (diff)
downloadChibiOS-a2bab9c63d848ccfce1440afd40e1eed7b2955ef.tar.gz
ChibiOS-a2bab9c63d848ccfce1440afd40e1eed7b2955ef.tar.bz2
ChibiOS-a2bab9c63d848ccfce1440afd40e1eed7b2955ef.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@825 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/testcond.c')
-rw-r--r--test/testcond.c113
1 files changed, 0 insertions, 113 deletions
diff --git a/test/testcond.c b/test/testcond.c
deleted file mode 100644
index dff5d2c29..000000000
--- a/test/testcond.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
-
- This file is part of ChibiOS/RT.
-
- ChibiOS/RT is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS/RT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <ch.h>
-
-#include "test.h"
-
-#if CH_USE_CONDVARS && CH_USE_MUTEXES
-
-static Mutex m1;
-static CondVar c1;
-
-static char *cond1_gettest(void) {
-
- return "CondVar, signal test";
-}
-
-static void cond1_setup(void) {
-
- chCondInit(&c1);
- chMtxInit(&m1);
-}
-
-static msg_t thread1(void *p) {
-
- chMtxLock(&m1);
- chCondWait(&c1);
- test_emit_token(*(char *)p);
- chMtxUnlock();
- return 0;
-}
-
-static void cond1_execute(void) {
-
- // Bacause priority inheritance.
- tprio_t prio = chThdGetPriority();
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread1, "E");
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread1, "D");
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C");
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B");
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
- test_assert(prio == chThdGetPriority(), "#1"); /* Priority return failure.*/
- chCondSignal(&c1);
- chCondSignal(&c1);
- chCondSignal(&c1);
- chCondSignal(&c1);
- chCondSignal(&c1);
- test_wait_threads();
- test_assert_sequence("ABCDE");
-}
-
-const struct testcase testcond1 = {
- cond1_gettest,
- cond1_setup,
- NULL,
- cond1_execute
-};
-
-static char *cond2_gettest(void) {
-
- return "CondVar, broadcast test";
-}
-
-static void cond2_execute(void) {
-
- // Bacause priority inheritance.
- tprio_t prio = chThdGetPriority();
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread1, "E");
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread1, "D");
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread1, "C");
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, prio+4, thread1, "B");
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
- test_assert(prio == chThdGetPriority(), "#1"); /* Priority return failure.*/
- chCondBroadcast(&c1);
- test_wait_threads();
- test_assert_sequence("ABCDE");
-}
-
-const struct testcase testcond2 = {
- cond2_gettest,
- NULL,
- NULL,
- cond2_execute
-};
-
-#endif /* CH_USE_CONDVARS && CH_USE_MUTEXES */
-
-/*
- * Test sequence for condvars pattern.
- */
-const struct testcase * const patterncond[] = {
-#if CH_USE_CONDVARS && CH_USE_MUTEXES
- &testcond1,
- &testcond2,
-#endif
- NULL
-};