git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@773 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2009-02-16 18:22:49 +00:00
parent cae6f99028
commit dd85cc143d
24 changed files with 227 additions and 178 deletions

View File

@ -80,6 +80,9 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- FIX: Fixed a small problem in the chcore.c template file.
- NEW: Mode flexible debug configuration options, removed the old CH_USE_DEBUG
and CH_USE_TRACE.
- Improvements to the test suite, added a new level of indirection that allows
to make tests depend on the configuration options without have to put #ifs
into the test main module.
*** 1.1.0unstable ***
- FIX: Modified the default value for the STM32 HSI setup it was 1, it should

View File

@ -32,50 +32,19 @@
#include "testbmk.h"
/*
* Array of all the test cases.
* Array of all the test patterns.
*/
static const struct testcase *tests[] = {
&testrdy1,
&testrdy2,
#if CH_USE_SEMAPHORES
&testsem1,
&testsem2,
#endif
#if CH_USE_MUTEXES
&testmtx1,
&testmtx2,
&testmtx3,
#if CH_USE_CONDVARS
&testcond1,
&testcond2,
#endif
#endif
#if CH_USE_MESSAGES
&testmsg1,
#endif
#if CH_USE_EVENTS
&testevt1,
#endif
#if CH_USE_HEAP
&testheap1,
#endif
#if CH_USE_MEMPOOLS
&testpools1,
#endif
#if CH_USE_DYNAMIC && CH_USE_HEAP
&testdyn1,
#endif
#if CH_USE_DYNAMIC && CH_USE_MEMPOOLS
&testdyn2,
#endif
&testbmk1,
&testbmk2,
&testbmk3,
&testbmk4,
&testbmk5,
&testbmk6,
&testbmk7,
&testbmk8,
static const struct testcase **patterns[] = {
patternrdy,
patternsem,
patternmtx,
patterncond,
patternmsg,
patternevt,
patternheap,
patternpools,
patterndyn,
patternbmk,
NULL
};
@ -248,13 +217,15 @@ static void execute_test(const struct testcase *tcp) {
for (i = 0; i < MAX_THREADS; i++)
threads[i] = NULL;
tcp->setup();
if (tcp->setup != NULL)
tcp->setup();
tcp->execute();
tcp->teardown();
if (tcp->teardown != NULL)
tcp->teardown();
}
msg_t TestThread(void *p) {
int i;
int i, j;
comp = p;
test_println("");
@ -265,29 +236,35 @@ msg_t TestThread(void *p) {
global_fail = FALSE;
i = 0;
while (tests[i]) {
while (patterns[i]) {
#if DELAY_BETWEEN_TESTS > 0
chThdSleepMilliseconds(DELAY_BETWEEN_TESTS);
chThdSleepMilliseconds(DELAY_BETWEEN_TESTS);
#endif
test_println("---------------------------------------------------------------------------");
test_print("--- Test Case ");
test_printn(i + 1);
test_print(" (");
test_print(tests[i]->gettest());
test_println(")");
execute_test(tests[i]);
if (local_fail) {
test_print("--- Result: FAIL (");
if (failmsg)
test_print(failmsg);
else {
test_print("sequence error: ");
print_tokens();
}
j = 0;
while (patterns[i][j]) {
test_println("---------------------------------------------------------------------------");
test_print("--- Test Case ");
test_printn(i + 1);
test_print(".");
test_printn(j + 1);
test_print(" (");
test_print(patterns[i][j]->gettest());
test_println(")");
execute_test(patterns[i][j]);
if (local_fail) {
test_print("--- Result: FAIL (");
if (failmsg)
test_print(failmsg);
else {
test_print("sequence error: ");
print_tokens();
}
test_println(")");
}
else
test_println("--- Result: SUCCESS");
j++;
}
else
test_println("--- Result: SUCCESS");
i++;
}
test_println("---------------------------------------------------------------------------");

View File

@ -20,9 +20,16 @@
#ifndef _TEST_H_
#define _TEST_H_
#ifndef DELAY_BETWEEN_TESTS
#define DELAY_BETWEEN_TESTS 200
#endif
#ifndef TEST_NO_BENCHMARKS
#define TEST_NO_BENCHMARKS FALSE
#endif
#define MAX_THREADS 5
#define MAX_TOKENS 16
#define DELAY_BETWEEN_TESTS 200
#if defined(CH_ARCHITECTURE_AVR) || defined(CH_ARCHITECTURE_MSP430)
#define THREADS_STACK_SIZE 48

View File

@ -23,8 +23,6 @@
static Semaphore sem1;
static void empty(void) {}
static msg_t thread1(void *p) {
msg_t msg;
@ -72,8 +70,8 @@ static void bmk1_execute(void) {
const struct testcase testbmk1 = {
bmk1_gettest,
empty,
empty,
NULL,
NULL,
bmk1_execute
};
@ -98,8 +96,8 @@ static void bmk2_execute(void) {
const struct testcase testbmk2 = {
bmk2_gettest,
empty,
empty,
NULL,
NULL,
bmk2_execute
};
@ -133,8 +131,8 @@ static void bmk3_execute(void) {
const struct testcase testbmk3 = {
bmk3_gettest,
empty,
empty,
NULL,
NULL,
bmk3_execute
};
@ -164,8 +162,8 @@ static void bmk4_execute(void) {
const struct testcase testbmk4 = {
bmk4_gettest,
empty,
empty,
NULL,
NULL,
bmk4_execute
};
@ -195,8 +193,8 @@ static void bmk5_execute(void) {
const struct testcase testbmk5 = {
bmk5_gettest,
empty,
empty,
NULL,
NULL,
bmk5_execute
};
@ -250,7 +248,7 @@ static void bmk6_execute(void) {
const struct testcase testbmk6 = {
bmk6_gettest,
bmk6_setup,
empty,
NULL,
bmk6_execute
};
@ -288,8 +286,8 @@ static void bmk7_execute(void) {
const struct testcase testbmk7 = {
bmk7_gettest,
empty,
empty,
NULL,
NULL,
bmk7_execute
};
@ -325,7 +323,24 @@ static void bmk8_execute(void) {
const struct testcase testbmk8 = {
bmk8_gettest,
empty,
empty,
NULL,
NULL,
bmk8_execute
};
/*
* Test sequence for benchmarks pattern.
*/
const struct testcase *patternbmk[] = {
#if TEST_NO_BENCHMARKS
&testbmk1,
&testbmk2,
&testbmk3,
&testbmk4,
&testbmk5,
&testbmk6,
&testbmk7,
&testbmk8,
#endif
NULL
};

View File

@ -20,8 +20,6 @@
#ifndef _TESTBMK_H_
#define _TESTBMK_H_
extern const struct testcase testbmk1, testbmk2, testbmk3,
testbmk4, testbmk5, testbmk6,
testbmk7, testbmk8;
extern const struct testcase *patternbmk[];
#endif /* _TESTBMK_H_ */

View File

@ -37,9 +37,6 @@ static void cond1_setup(void) {
chMtxInit(&m1);
}
static void cond1_teardown(void) {
}
static msg_t thread1(void *p) {
chMtxLock(&m1);
@ -71,7 +68,7 @@ static void cond1_execute(void) {
const struct testcase testcond1 = {
cond1_gettest,
cond1_setup,
cond1_teardown,
NULL,
cond1_execute
};
@ -97,9 +94,20 @@ static void cond2_execute(void) {
const struct testcase testcond2 = {
cond2_gettest,
cond1_setup,
cond1_teardown,
NULL,
NULL,
cond2_execute
};
#endif /* defined(CH_USE_CONDVARS) && defined(CH_USE_MUTEXES) */
#endif /* CH_USE_CONDVARS && CH_USE_MUTEXES */
/*
* Test sequence for condvars pattern.
*/
const struct testcase *patterncond[] = {
#if CH_USE_CONDVARS && CH_USE_MUTEXES
&testcond1,
&testcond2,
#endif
NULL
};

View File

@ -20,7 +20,6 @@
#ifndef _TESTCOND_H_
#define _TESTCOND_H_
extern const struct testcase testcond1;
extern const struct testcase testcond2;
extern const struct testcase *patterncond[];
#endif /* _TESTCOND_H_ */

View File

@ -35,12 +35,6 @@ static char *dyn1_gettest(void) {
return "Dynamic APIs, threads creation from heap";
}
static void dyn1_setup(void) {
}
static void dyn1_teardown(void) {
}
static void dyn1_execute(void) {
size_t n, sz;
tprio_t prio = chThdGetPriority();
@ -72,8 +66,8 @@ static void dyn1_execute(void) {
const struct testcase testdyn1 = {
dyn1_gettest,
dyn1_setup,
dyn1_teardown,
NULL,
NULL,
dyn1_execute
};
#endif /* CH_USE_HEAP */
@ -91,9 +85,6 @@ static void dyn2_setup(void) {
chPoolInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE));
}
static void dyn2_teardown(void) {
}
static void dyn2_execute(void) {
int i;
tprio_t prio = chThdGetPriority();
@ -129,9 +120,24 @@ static void dyn2_execute(void) {
const struct testcase testdyn2 = {
dyn2_gettest,
dyn2_setup,
dyn2_teardown,
NULL,
dyn2_execute
};
#endif /* CH_USE_MEMPOOLS */
#endif /* CH_USE_DYNAMIC */
/*
* Test sequence for dynamic APIs pattern.
*/
const struct testcase *patterndyn[] = {
#if CH_USE_DYNAMIC
#if CH_USE_HEAP
&testdyn1,
#endif
#if CH_USE_MEMPOOLS
&testdyn2,
#endif
#endif
NULL
};

View File

@ -20,6 +20,6 @@
#ifndef _TESTDYN_H_
#define _TESTDYN_H_
extern const struct testcase testdyn1, testdyn2;
extern const struct testcase *patterndyn[];
#endif /* _TESTDYN_H_ */

View File

@ -37,9 +37,6 @@ static void evt1_setup(void) {
chEvtClear(ALL_EVENTS);
}
static void evt1_teardown(void) {
}
static msg_t thread(void *p) {
chEvtBroadcast(&es1);
@ -97,8 +94,18 @@ static void evt1_execute(void) {
const struct testcase testevt1 = {
evt1_gettest,
evt1_setup,
evt1_teardown,
NULL,
evt1_execute
};
#endif /* CH_USE_EVENTS */
/*
* Test sequence for events pattern.
*/
const struct testcase *patternevt[] = {
#if CH_USE_EVENTS
&testevt1,
#endif
NULL
};

View File

@ -20,6 +20,6 @@
#ifndef _TESTEVT_H_
#define _TESTEVT_H_
extern const struct testcase testevt1;
extern const struct testcase *patternevt[];
#endif /* _TESTEVT_H_ */

View File

@ -30,12 +30,6 @@ static char *heap1_gettest(void) {
return "Heap, allocation and fragmentation test";
}
static void heap1_setup(void) {
}
static void heap1_teardown(void) {
}
static void heap1_execute(void) {
void *p1, *p2, *p3;
size_t n, sz;
@ -75,9 +69,19 @@ static void heap1_execute(void) {
const struct testcase testheap1 = {
heap1_gettest,
heap1_setup,
heap1_teardown,
NULL,
NULL,
heap1_execute
};
#endif /* CH_USE_HEAP */
/*
* Test sequence for heap pattern.
*/
const struct testcase *patternheap[] = {
#if CH_USE_HEAP
&testheap1,
#endif
NULL
};

View File

@ -20,6 +20,6 @@
#ifndef _TESTHEAP_H_
#define _TESTHEAP_H_
extern const struct testcase testheap1;
extern const struct testcase *patternheap[];
#endif /* _TESTHEAP_H_ */

View File

@ -21,17 +21,13 @@
#include "test.h"
#if CH_USE_MESSAGES
static char *msg1_gettest(void) {
return "Messages, dispatch test";
}
static void msg1_setup(void) {
}
static void msg1_teardown(void) {
}
static msg_t thread(void *p) {
msg_t msg;
int i;
@ -59,7 +55,19 @@ static void msg1_execute(void) {
const struct testcase testmsg1 = {
msg1_gettest,
msg1_setup,
msg1_teardown,
NULL,
NULL,
msg1_execute
};
#endif /* CH_USE_MESSAGES */
/*
* Test sequence for messages pattern.
*/
const struct testcase *patternmsg[] = {
#if CH_USE_MESSAGES
&testmsg1,
#endif
NULL
};

View File

@ -20,6 +20,6 @@
#ifndef _TESTMSG_H_
#define _TESTMSG_H_
extern const struct testcase testmsg1;
extern const struct testcase *patternmsg[];
#endif /* _TESTMSG_H_ */

View File

@ -37,9 +37,6 @@ static void mtx1_setup(void) {
chMtxInit(&m1);
}
static void mtx1_teardown(void) {
}
static msg_t thread1(void *p) {
chMtxLock(&m1);
@ -66,7 +63,7 @@ static void mtx1_execute(void) {
const struct testcase testmtx1 = {
mtx1_gettest,
mtx1_setup,
mtx1_teardown,
NULL,
mtx1_execute
};
@ -80,9 +77,6 @@ static void mtx2_setup(void) {
chMtxInit(&m1);
}
static void mtx2_teardown(void) {
}
static msg_t thread2(void *p) {
chThdSleepMilliseconds(10);
@ -127,7 +121,7 @@ static void mtx2_execute(void) {
const struct testcase testmtx2 = {
mtx2_gettest,
mtx2_setup,
mtx2_teardown,
NULL,
mtx2_execute
};
@ -142,9 +136,6 @@ static void mtx3_setup(void) {
chMtxInit(&m2);
}
static void mtx3_teardown(void) {
}
static msg_t thread5(void *p) {
chMtxLock(&m1);
@ -218,8 +209,20 @@ static void mtx3_execute(void) {
const struct testcase testmtx3 = {
mtx3_gettest,
mtx3_setup,
mtx3_teardown,
NULL,
mtx3_execute
};
#endif /* CH_USE_MUTEXES */
/*
* Test sequence for mutexes pattern.
*/
const struct testcase *patternmtx[] = {
#if CH_USE_MUTEXES
&testmtx1,
&testmtx2,
&testmtx3,
#endif
NULL
};

View File

@ -20,6 +20,6 @@
#ifndef _TESTMTX_H_
#define _TESTMTX_H_
extern const struct testcase testmtx1, testmtx2, testmtx3;
extern const struct testcase *patternmtx[];
#endif /* _TESTMTX_H_ */

View File

@ -35,9 +35,6 @@ static void pools1_setup(void) {
chPoolInit(&mp1, THD_WA_SIZE(THREADS_STACK_SIZE));
}
static void pools1_teardown(void) {
}
static void pools1_execute(void) {
int i;
@ -56,8 +53,18 @@ static void pools1_execute(void) {
const struct testcase testpools1 = {
pools1_gettest,
pools1_setup,
pools1_teardown,
NULL,
pools1_execute
};
#endif /* CH_USE_MEMPOOLS */
/*
* Test sequence for pools pattern.
*/
const struct testcase *patternpools[] = {
#if CH_USE_MEMPOOLS
&testpools1,
#endif
NULL
};

View File

@ -20,6 +20,6 @@
#ifndef _TESTPOOLS_H_
#define _TESTPOOLS_H_
extern const struct testcase testpools1;
extern const struct testcase *patternpools[];
#endif /* _TESTPOOLS_H_ */

View File

@ -32,12 +32,6 @@ static char *rdy1_gettest(void) {
return "Ready List, priority enqueuing test #1";
}
static void rdy1_setup(void) {
}
static void rdy1_teardown(void) {
}
static void rdy1_execute(void) {
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E");
@ -51,8 +45,8 @@ static void rdy1_execute(void) {
const struct testcase testrdy1 = {
rdy1_gettest,
rdy1_setup,
rdy1_teardown,
NULL,
NULL,
rdy1_execute
};
@ -61,12 +55,6 @@ static char *rdy2_gettest(void) {
return "Ready List, priority enqueuing test #2";
}
static void rdy2_setup(void) {
}
static void rdy2_teardown(void) {
}
static void rdy2_execute(void) {
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D");
@ -80,7 +68,16 @@ static void rdy2_execute(void) {
const struct testcase testrdy2 = {
rdy2_gettest,
rdy2_setup,
rdy2_teardown,
NULL,
NULL,
rdy2_execute
};
/*
* Test sequence for ready list pattern.
*/
const struct testcase *patternrdy[] = {
&testrdy1,
&testrdy2,
NULL
};

View File

@ -20,6 +20,6 @@
#ifndef _TESTRDY_H_
#define _TESTRDY_H_
extern const struct testcase testrdy1, testrdy2;
extern const struct testcase *patternrdy[];
#endif /* _TESTRDY_H_ */

View File

@ -37,9 +37,6 @@ static void sem1_setup(void) {
chSemInit(&sem1, 0);
}
static void sem1_teardown(void) {
}
static msg_t thread(void *p) {
chSemWait(&sem1);
@ -66,10 +63,11 @@ static void sem1_execute(void) {
const struct testcase testsem1 = {
sem1_gettest,
sem1_setup,
sem1_teardown,
NULL,
sem1_execute
};
#if CH_USE_SEMAPHORES_TIMEOUT
static char *sem2_gettest(void) {
return "Semaphores, timeout test";
@ -80,9 +78,6 @@ static void sem2_setup(void) {
chSemInit(&sem1, 0);
}
static void sem2_teardown(void) {
}
static void sem2_execute(void) {
int i;
systime_t target_time;
@ -101,8 +96,21 @@ static void sem2_execute(void) {
const struct testcase testsem2 = {
sem2_gettest,
sem2_setup,
sem2_teardown,
NULL,
sem2_execute
};
#endif /* CH_USE_SEMAPHORES_TIMEOUT */
#endif /* CH_USE_SEMAPHORES */
/*
* Test sequence for semaphores pattern.
*/
const struct testcase *patternsem[] = {
#if CH_USE_SEMAPHORES
&testsem1,
#if CH_USE_SEMAPHORES_TIMEOUT
&testsem2,
#endif
#endif
NULL
};

View File

@ -20,6 +20,6 @@
#ifndef _TESTSEM_H_
#define _TESTSEM_H_
extern const struct testcase testsem1, testsem2;
extern const struct testcase *patternsem[];
#endif /* _TESTSEM_H_ */

View File

@ -5,12 +5,14 @@ After 1.0.0:
* chSysLock() and chSysUnlock() with counter (option).
* OSEK-style chSysSuspendAll()/chSysResumeAll()/chSysEnable()/chSysDisable(),
implemented this as the new Suspended and Disabled states in 1.1.
X lwIP TCP/IP stack integration.
X lwIP TCP/IP stack integration and demo.
- "Wide Queues" or Mailboxes, lwIP requires them.
- FatFS library integration and demo.
X FatFS library integration and demo.
* Multiple debug switches.
- Stack guard pages.
- Threads profiling option.
- Objects registry.
Problem: fixed size? it goes against project policy.
* Idle loop hook macro.
* Switch the configuration options to TRUE/FALSE rather than def/undef.
- Threads Pools manager in the library.