Test improvements.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13190 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2019-11-23 15:28:39 +00:00
parent ef5ee94dad
commit 2d5f8eadd4
10 changed files with 115 additions and 11 deletions

View File

@ -94,6 +94,7 @@ static void nil_test_001_001_execute(void) {
test_println("");
#endif
}
test_end_step(1);
}
static const testcase_t nil_test_001_001 = {
@ -135,6 +136,7 @@ static void nil_test_001_002_execute(void) {
test_printn(CH_KERNEL_PATCH);
test_println("");
}
test_end_step(1);
}
static const testcase_t nil_test_001_002 = {
@ -206,6 +208,7 @@ static void nil_test_001_003_execute(void) {
test_printn(CH_DBG_ENABLE_STACK_CHECK);
test_println("");
}
test_end_step(1);
}
static const testcase_t nil_test_001_003 = {

View File

@ -67,6 +67,7 @@ static void nil_test_002_001_execute(void) {
while (time == chVTGetSystemTimeX()) {
}
}
test_end_step(1);
}
static const testcase_t nil_test_002_001 = {
@ -113,6 +114,7 @@ static void nil_test_002_002_execute(void) {
chTimeAddX(time, 100 + 1),
"out of time window");
}
test_end_step(1);
/* [2.2.2] The current system time is read then a sleep is performed
for 100000 microseconds and on exit the system time is verified
@ -125,6 +127,7 @@ static void nil_test_002_002_execute(void) {
chTimeAddX(time, TIME_US2I(100000) + 1),
"out of time window");
}
test_end_step(2);
/* [2.2.3] The current system time is read then a sleep is performed
for 100 milliseconds and on exit the system time is verified
@ -137,6 +140,7 @@ static void nil_test_002_002_execute(void) {
chTimeAddX(time, TIME_MS2I(100) + 1),
"out of time window");
}
test_end_step(3);
/* [2.2.4] The current system time is read then a sleep is performed
for 1 second and on exit the system time is verified again.*/
@ -148,6 +152,7 @@ static void nil_test_002_002_execute(void) {
chTimeAddX(time, TIME_S2I(1) + 1),
"out of time window");
}
test_end_step(4);
/* [2.2.5] Function chThdSleepUntil() is tested with a timeline of
"now" + 100 ticks.*/
@ -159,6 +164,7 @@ static void nil_test_002_002_execute(void) {
chTimeAddX(time, 100 + 1),
"out of time window");
}
test_end_step(5);
}
static const testcase_t nil_test_002_002 = {

View File

@ -119,6 +119,7 @@ static void nil_test_003_001_execute(void) {
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_OK == msg, "wrong returned message");
}
test_end_step(1);
/* [3.1.2] The function chSemSignal() is invoked, after return the
counter is tested.*/
@ -127,6 +128,7 @@ static void nil_test_003_001_execute(void) {
chSemSignal(&sem1);
test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value");
}
test_end_step(2);
/* [3.1.3] The function chSemReset() is invoked, after return the
counter is tested.*/
@ -135,6 +137,7 @@ static void nil_test_003_001_execute(void) {
chSemReset(&sem1, 2);
test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");
}
test_end_step(3);
}
static const testcase_t nil_test_003_001 = {
@ -191,6 +194,7 @@ static void nil_test_003_002_execute(void) {
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_OK == msg, "wrong returned message");
}
test_end_step(1);
/* [3.2.2] The function chSemWait() is invoked, after return the
counter and the returned message are tested. The semaphore is
@ -203,6 +207,7 @@ static void nil_test_003_002_execute(void) {
test_assert_lock(chSemGetCounterI(&sem2) == 0,"wrong counter value");
test_assert(MSG_RESET == msg, "wrong returned message");
}
test_end_step(2);
}
static const testcase_t nil_test_003_002 = {
@ -253,6 +258,7 @@ static void nil_test_003_003_execute(void) {
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
}
test_end_step(1);
/* [3.3.2] The function chSemWaitTimeout() is invoked again, after
return the system time, the counter and the returned message are
@ -267,6 +273,7 @@ static void nil_test_003_003_execute(void) {
test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
test_assert(MSG_TIMEOUT == msg, "wrong timeout message");
}
test_end_step(2);
}
static const testcase_t nil_test_003_003 = {

View File

@ -112,6 +112,7 @@ static void nil_test_004_001_execute(void) {
test_assert(NULL == tr1, "not NULL");
test_assert(MSG_OK == msg,"wrong returned message");
}
test_end_step(1);
/* [4.1.2] The function chThdSuspendTimeoutS() is invoked, the thread
is not resumed so a timeout must occur. On return the message and
@ -130,6 +131,7 @@ static void nil_test_004_001_execute(void) {
test_assert(NULL == tr, "not NULL");
test_assert(MSG_TIMEOUT == msg, "wrong returned message");
}
test_end_step(2);
}
static const testcase_t nil_test_004_001 = {

View File

@ -112,6 +112,7 @@ static void nil_test_005_001_execute(void) {
{
chEvtObjectInit(&es1);
}
test_end_step(1);
/* [5.1.2] Two Event Listeners are registered on the Event Source,
the Event Source is tested to have listeners.*/
@ -121,6 +122,7 @@ static void nil_test_005_001_execute(void) {
chEvtRegisterMask(&es1, &el2, 2);
test_assert_lock(chEvtIsListeningI(&es1), "no listener");
}
test_end_step(2);
/* [5.1.3] An Event Listener is unregistered, the Event Source must
still have listeners.*/
@ -129,6 +131,7 @@ static void nil_test_005_001_execute(void) {
chEvtUnregister(&es1, &el1);
test_assert_lock(chEvtIsListeningI(&es1), "no listener");
}
test_end_step(3);
/* [5.1.4] An Event Listener is unregistered, the Event Source must
not have listeners.*/
@ -137,6 +140,7 @@ static void nil_test_005_001_execute(void) {
chEvtUnregister(&es1, &el2);
test_assert_lock(!chEvtIsListeningI(&es1), "stuck listener");
}
test_end_step(4);
}
static const testcase_t nil_test_005_001 = {
@ -172,6 +176,7 @@ static void nil_test_005_002_execute(void) {
chEvtDispatch(evhndl, 7);
test_assert_sequence("ABC", "invalid sequence");
}
test_end_step(1);
}
static const testcase_t nil_test_005_002 = {
@ -213,6 +218,7 @@ static void nil_test_005_003_execute(void) {
{
chEvtAddEvents(7);
}
test_end_step(1);
/* [5.3.2] Calling chEvtWaitOne() three times, each time a single
flag must be returned in order of priority.*/
@ -227,6 +233,7 @@ static void nil_test_005_003_execute(void) {
m = chEvtGetAndClearEvents(ALL_EVENTS);
test_assert(m == 0, "stuck event");
}
test_end_step(2);
/* [5.3.3] Getting current time and starting a signaler thread, the
thread will set an event flag after 50mS.*/
@ -243,6 +250,7 @@ static void nil_test_005_003_execute(void) {
};
tp = chThdCreate(&tc);
}
test_end_step(3);
/* [5.3.4] Calling chEvtWaitOne() then verifying that the event has
been received after 50mS and that the event flags mask has been
@ -258,6 +266,7 @@ static void nil_test_005_003_execute(void) {
test_assert(m == 0, "stuck event");
chThdWait(tp);
}
test_end_step(4);
}
static const testcase_t nil_test_005_003 = {
@ -299,6 +308,7 @@ static void nil_test_005_004_execute(void) {
{
chEvtAddEvents(5);
}
test_end_step(1);
/* [5.4.2] Calling chEvtWaitAny() one time, the two flags must be
returned.*/
@ -309,6 +319,7 @@ static void nil_test_005_004_execute(void) {
m = chEvtGetAndClearEvents(ALL_EVENTS);
test_assert(m == 0, "stuck event");
}
test_end_step(2);
/* [5.4.3] Getting current time and starting a signaler thread, the
thread will set an event flag after 50mS.*/
@ -325,6 +336,7 @@ static void nil_test_005_004_execute(void) {
};
tp = chThdCreate(&tc);
}
test_end_step(3);
/* [5.4.4] Calling chEvtWaitAny() then verifying that the event has
been received after 50mS and that the event flags mask has been
@ -340,6 +352,7 @@ static void nil_test_005_004_execute(void) {
test_assert(m == 0, "stuck event");
chThdWait(tp);
}
test_end_step(4);
}
static const testcase_t nil_test_005_004 = {
@ -382,6 +395,7 @@ static void nil_test_005_005_execute(void) {
{
chEvtAddEvents(5);
}
test_end_step(1);
/* [5.5.2] Calling chEvtWaitAll() one time, the two flags must be
returned.*/
@ -392,12 +406,14 @@ static void nil_test_005_005_execute(void) {
m = chEvtGetAndClearEvents(ALL_EVENTS);
test_assert(m == 0, "stuck event");
}
test_end_step(2);
/* [5.5.3] Setting one event flag.*/
test_set_step(3);
{
chEvtAddEvents(4);
}
test_end_step(3);
/* [5.5.4] Getting current time and starting a signaler thread, the
thread will set another event flag after 50mS.*/
@ -414,6 +430,7 @@ static void nil_test_005_005_execute(void) {
};
tp = chThdCreate(&tc);
}
test_end_step(4);
/* [5.5.5] Calling chEvtWaitAll() then verifying that both event
flags have been received after 50mS and that the event flags mask
@ -429,6 +446,7 @@ static void nil_test_005_005_execute(void) {
test_assert(m == 0, "stuck event");
chThdWait(tp);
}
test_end_step(5);
}
static const testcase_t nil_test_005_005 = {
@ -471,6 +489,7 @@ static void nil_test_005_006_execute(void) {
m = chEvtWaitAllTimeout(ALL_EVENTS, TIME_IMMEDIATE);
test_assert(m == 0, "spurious event");
}
test_end_step(1);
/* [5.6.2] The functions are invoked first with a 50mS timeout, the
timeout condition is tested.*/
@ -483,6 +502,7 @@ static void nil_test_005_006_execute(void) {
m = chEvtWaitAllTimeout(ALL_EVENTS, TIME_MS2I(50));
test_assert(m == 0, "spurious event");
}
test_end_step(2);
}
static const testcase_t nil_test_005_006 = {
@ -530,6 +550,7 @@ static void nil_test_005_007_execute(void) {
chEvtRegisterMask(&es1, &el1, 1);
chEvtRegisterMask(&es2, &el2, 4);
}
test_end_step(1);
/* [5.7.2] Getting current time and starting a broadcaster thread,
the thread broadcast the first Event Source immediately and the
@ -547,6 +568,7 @@ static void nil_test_005_007_execute(void) {
};
tp = chThdCreate(&tc);
}
test_end_step(2);
/* [5.7.3] Calling chEvtWaitAll() then verifying that both event
flags have been received after 50mS and that the event flags mask
@ -561,6 +583,7 @@ static void nil_test_005_007_execute(void) {
test_assert(m == 0, "stuck event");
chThdWait(tp);
}
test_end_step(3);
/* [5.7.4] Unregistering from the Event Sources.*/
test_set_step(4);
@ -570,6 +593,7 @@ static void nil_test_005_007_execute(void) {
test_assert(!chEvtIsListeningI(&es1), "stuck listener");
test_assert(!chEvtIsListeningI(&es2), "stuck listener");
}
test_end_step(4);
}
static const testcase_t nil_test_005_007 = {

View File

@ -92,6 +92,7 @@ static void nil_test_006_001_execute(void) {
};
tp1 = chThdCreate(&tc);
}
test_end_step(1);
/* [6.1.2] Waiting for four messages then testing the receive
order.*/
@ -108,6 +109,7 @@ static void nil_test_006_001_execute(void) {
chThdWait(tp1);
test_assert_sequence("ABCD", "invalid sequence");
}
test_end_step(2);
}
static const testcase_t nil_test_006_001 = {

View File

@ -150,6 +150,7 @@ static void nil_test_007_001_execute(void) {
};
tp = chThdCreate(&tc);
}
test_end_step(1);
/* [7.1.2] The number of messages exchanged is counted in a one
second time window.*/
@ -158,6 +159,7 @@ static void nil_test_007_001_execute(void) {
n = msg_loop_test(tp);
chThdWait(tp);
}
test_end_step(2);
/* [7.1.3] Score is printed.*/
test_set_step(3);
@ -168,6 +170,7 @@ static void nil_test_007_001_execute(void) {
test_printn(n << 1);
test_println(" ctxswc/S");
}
test_end_step(3);
}
static const testcase_t nil_test_007_001 = {
@ -220,6 +223,7 @@ static void nil_test_007_002_execute(void) {
};
tp = chThdCreate(&tc);
}
test_end_step(1);
/* [7.2.2] The number of messages exchanged is counted in a one
second time window.*/
@ -228,6 +232,7 @@ static void nil_test_007_002_execute(void) {
n = msg_loop_test(tp);
chThdWait(tp);
}
test_end_step(2);
/* [7.2.3] Score is printed.*/
test_set_step(3);
@ -238,6 +243,7 @@ static void nil_test_007_002_execute(void) {
test_printn(n << 1);
test_println(" ctxswc/S");
}
test_end_step(3);
}
static const testcase_t nil_test_007_002 = {
@ -284,6 +290,7 @@ static void nil_test_007_003_execute(void) {
};
tp = chThdCreate(&tc);
}
test_end_step(1);
/* [7.3.2] Waking up the thread as fast as possible in a one second
time window.*/
@ -304,6 +311,7 @@ static void nil_test_007_003_execute(void) {
n += 4;
} while (chVTIsSystemTimeWithinX(start, end));
}
test_end_step(2);
/* [7.3.3] Stopping the target thread.*/
test_set_step(3);
@ -313,6 +321,7 @@ static void nil_test_007_003_execute(void) {
chSysUnlock();
chThdWait(tp);
}
test_end_step(3);
/* [7.3.4] Score is printed.*/
test_set_step(4);
@ -321,6 +330,7 @@ static void nil_test_007_003_execute(void) {
test_printn(n * 2);
test_println(" ctxswc/S");
}
test_end_step(4);
}
static const testcase_t nil_test_007_003 = {
@ -374,6 +384,7 @@ static void nil_test_007_004_execute(void) {
n++;
} while (chVTIsSystemTimeWithinX(start, end));
}
test_end_step(1);
/* [7.4.2] Score is printed.*/
test_set_step(2);
@ -382,6 +393,7 @@ static void nil_test_007_004_execute(void) {
test_printn(n);
test_println(" threads/S");
}
test_end_step(2);
}
static const testcase_t nil_test_007_004 = {
@ -436,6 +448,7 @@ static void nil_test_007_005_execute(void) {
n++;
} while (chVTIsSystemTimeWithinX(start, end));
}
test_end_step(1);
/* [7.5.2] Score is printed.*/
test_set_step(2);
@ -444,6 +457,7 @@ static void nil_test_007_005_execute(void) {
test_printn(n);
test_println(" threads/S");
}
test_end_step(2);
}
static const testcase_t nil_test_007_005 = {
@ -507,6 +521,7 @@ static void nil_test_007_006_execute(void) {
#endif
} while (chVTIsSystemTimeWithinX(start, end));
}
test_end_step(1);
/* [7.6.2] The score is printed.*/
test_set_step(2);
@ -515,6 +530,7 @@ static void nil_test_007_006_execute(void) {
test_printn(n * 4);
test_println(" wait+signal/S");
}
test_end_step(2);
}
static const testcase_t nil_test_007_006 = {
@ -550,6 +566,7 @@ static void nil_test_007_007_execute(void) {
test_printn(sizeof(nil_system_t));
test_println(" bytes");
}
test_end_step(1);
/* [7.7.2] The size of a thread structure is printed.*/
test_set_step(2);
@ -558,6 +575,7 @@ static void nil_test_007_007_execute(void) {
test_printn(sizeof(thread_t));
test_println(" bytes");
}
test_end_step(2);
/* [7.7.3] The size of a semaphore structure is printed.*/
test_set_step(3);
@ -568,6 +586,7 @@ static void nil_test_007_007_execute(void) {
test_println(" bytes");
#endif
}
test_end_step(3);
/* [7.7.4] The size of an event source is printed.*/
test_set_step(4);
@ -578,6 +597,7 @@ static void nil_test_007_007_execute(void) {
test_println(" bytes");
#endif
}
test_end_step(4);
/* [7.7.5] The size of an event listener is printed.*/
test_set_step(5);
@ -588,6 +608,7 @@ static void nil_test_007_007_execute(void) {
test_println(" bytes");
#endif
}
test_end_step(5);
/* [7.7.6] The size of a mailbox is printed.*/
test_set_step(6);
@ -598,6 +619,7 @@ static void nil_test_007_007_execute(void) {
test_println(" bytes");
#endif
}
test_end_step(6);
}
static const testcase_t nil_test_007_007 = {

View File

@ -207,7 +207,11 @@ test_println("");]]></value>
<value />
</tags>
<code>
<value><![CDATA[test_print("--- CH_CFG_USE_MEMCORE: ");
<value><![CDATA[
test_print("--- CH_CFG_USE_MAILBOXES: ");
test_printn(CH_CFG_USE_MAILBOXES);
test_println("");
test_print("--- CH_CFG_USE_MEMCORE: ");
test_printn(CH_CFG_USE_MEMCORE);
test_println("");
test_print("--- CH_CFG_USE_HEAP: ");
@ -222,6 +226,12 @@ test_println("");
test_print("--- CH_CFG_USE_PIPES: ");
test_printn(CH_CFG_USE_PIPES);
test_println("");
test_print("--- CH_CFG_USE_OBJ_CACHES: ");
test_printn(CH_CFG_USE_OBJ_CACHES);
test_println("");
test_print("--- CH_CFG_USE_DELEGATES: ");
test_printn(CH_CFG_USE_DELEGATES);
test_println("");
test_print("--- CH_CFG_USE_FACTORY: ");
test_printn(CH_CFG_USE_FACTORY);
test_println("");
@ -1079,10 +1089,7 @@ static THD_FUNCTION(Thread1, arg) {
(void)arg;
chRegSetThreadName("dispatcher");
exit_flag = false;
do {
chDelegateDispatch();
} while (!exit_flag);
@ -1127,10 +1134,26 @@ thread_t *tp;
<code>
<value><![CDATA[
#if defined(_CHIBIOS_RT_)
tp = chThdCreateStatic(waThread1, sizeof(waThread1),
chThdGetPriorityX() + 1, Thread1, NULL);
thread_descriptor_t &td = {
.name = "dispatcher",
.wbase = waThread1,
.wend = THD_WORKING_AREA_END(waThread1),
.prio = chThdGetPriorityX() + 1,
.funcp = Thread1,
.arg = NULL
};
tp = chThdCreate(&td);
#endif
#if defined(_CHIBIOS_NIL_)
thread_config_t tc = {
.prio = chThdGetPriorityX() + 1,
.namep = "dispatcher",
.wbase = waThread1,
.wend = THD_WORKING_AREA_END(waThread1),
.funcp = Thread1,
.arg = NULL
};
tp = chThdCreate(&tc);
#endif
]]></value>
</code>

View File

@ -162,6 +162,9 @@ static void oslib_test_001_003_execute(void) {
/* [1.3.1] Prints the configuration options settings.*/
test_set_step(1);
{
test_print("--- CH_CFG_USE_MAILBOXES: ");
test_printn(CH_CFG_USE_MAILBOXES);
test_println("");
test_print("--- CH_CFG_USE_MEMCORE: ");
test_printn(CH_CFG_USE_MEMCORE);
test_println("");
@ -177,6 +180,12 @@ static void oslib_test_001_003_execute(void) {
test_print("--- CH_CFG_USE_PIPES: ");
test_printn(CH_CFG_USE_PIPES);
test_println("");
test_print("--- CH_CFG_USE_OBJ_CACHES: ");
test_printn(CH_CFG_USE_OBJ_CACHES);
test_println("");
test_print("--- CH_CFG_USE_DELEGATES: ");
test_printn(CH_CFG_USE_DELEGATES);
test_println("");
test_print("--- CH_CFG_USE_FACTORY: ");
test_printn(CH_CFG_USE_FACTORY);
test_println("");

View File

@ -102,10 +102,7 @@ static THD_FUNCTION(Thread1, arg) {
(void)arg;
chRegSetThreadName("dispatcher");
exit_flag = false;
do {
chDelegateDispatch();
} while (!exit_flag);
@ -142,6 +139,15 @@ static void oslib_test_004_001_execute(void) {
chThdGetPriorityX() + 1, Thread1, NULL);
#endif
#if defined(_CHIBIOS_NIL_)
thread_config_t tc = {
.prio = chThdGetPriorityX() + 1,
.namep = "dispatcher",
.wbase = waThread1,
.wend = THD_WORKING_AREA_END(waThread1),
.funcp = Thread1,
.arg = NULL
};
tp = chThdCreate(&tc);
#endif
}
test_end_step(1);