2008-06-26 10:54:55 +00:00
|
|
|
/*
|
|
|
|
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"
|
|
|
|
|
|
|
|
static msg_t thread(void *p) {
|
|
|
|
|
|
|
|
test_emit_token(*(char *)p);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *rdy1_gettest(void) {
|
|
|
|
|
|
|
|
return "Ready List, priority enqueuing test #1";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rdy1_execute(void) {
|
|
|
|
|
2008-11-29 10:54:24 +00:00
|
|
|
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E");
|
|
|
|
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D");
|
|
|
|
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C");
|
|
|
|
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B");
|
|
|
|
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A");
|
2008-06-26 10:54:55 +00:00
|
|
|
test_wait_threads();
|
|
|
|
test_assert_sequence("ABCDE");
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct testcase testrdy1 = {
|
|
|
|
rdy1_gettest,
|
2009-02-16 18:22:49 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2008-06-26 10:54:55 +00:00
|
|
|
rdy1_execute
|
|
|
|
};
|
|
|
|
|
|
|
|
static char *rdy2_gettest(void) {
|
|
|
|
|
|
|
|
return "Ready List, priority enqueuing test #2";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rdy2_execute(void) {
|
|
|
|
|
2008-11-29 10:54:24 +00:00
|
|
|
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D");
|
|
|
|
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E");
|
|
|
|
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A");
|
|
|
|
threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B");
|
|
|
|
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C");
|
2008-06-26 10:54:55 +00:00
|
|
|
test_wait_threads();
|
|
|
|
test_assert_sequence("ABCDE");
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct testcase testrdy2 = {
|
|
|
|
rdy2_gettest,
|
2009-02-16 18:22:49 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2008-06-26 10:54:55 +00:00
|
|
|
rdy2_execute
|
|
|
|
};
|
2009-02-16 18:22:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Test sequence for ready list pattern.
|
|
|
|
*/
|
|
|
|
const struct testcase *patternrdy[] = {
|
|
|
|
&testrdy1,
|
|
|
|
&testrdy2,
|
|
|
|
NULL
|
|
|
|
};
|