From e8ae833287d6813305ac676508cb3dbaaf483eeb Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 16 Apr 2009 15:06:49 +0000 Subject: [PATCH] 100% code coverage for threads. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@902 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testthd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/testthd.c b/test/testthd.c index 92f0bfe9f..cac77a43a 100644 --- a/test/testthd.c +++ b/test/testthd.c @@ -88,6 +88,31 @@ static void thd3_execute(void) { p1 = chThdSetPriority(p1); test_assert(p1 == prio + 1, "#3"); test_assert(chThdGetPriority() == prio, "#4"); + +#if CH_USE_MUTEXES + /* Simulates a priority boost situation (p_prio > p_realprio).*/ + chSysLock(); + chThdSelf()->p_prio += 2; + chSysUnlock(); + test_assert(chThdGetPriority() == prio + 2, "#5"); + + /* Tries to raise but below the boost level. */ + p1 = chThdSetPriority(prio + 1); + test_assert(p1 == prio, "#6"); + test_assert(chThdSelf()->p_prio == prio + 2, "#7"); + test_assert(chThdSelf()->p_realprio == prio + 1, "#8"); + + /* Tries to raise above the boost level. */ + p1 = chThdSetPriority(prio + 3); + test_assert(p1 == prio + 1, "#9"); + test_assert(chThdSelf()->p_prio == prio + 3, "#10"); + test_assert(chThdSelf()->p_realprio == prio + 3, "#11"); + + chSysLock(); + chThdSelf()->p_prio = prio; + chThdSelf()->p_realprio = prio; + chSysUnlock(); +#endif } const struct testcase testthd3 = {