Test coverage improvements.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7869 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2015-04-07 10:37:52 +00:00
parent 16c53c9c52
commit f1080803f7
4 changed files with 178 additions and 0 deletions

View File

@ -36,6 +36,7 @@
#include "testpools.h"
#include "testdyn.h"
#include "testqueues.h"
#include "testsys.h"
#include "testbmk.h"
/*
@ -52,6 +53,7 @@ static ROMCONST struct testcase * ROMCONST *patterns[] = {
patternpools,
patterndyn,
patternqueues,
patternsys,
patternbmk,
NULL
};

View File

@ -10,6 +10,7 @@ TESTSRC = ${CHIBIOS}/test/rt/test.c \
${CHIBIOS}/test/rt/testpools.c \
${CHIBIOS}/test/rt/testdyn.c \
${CHIBIOS}/test/rt/testqueues.c \
${CHIBIOS}/test/rt/testsys.c \
${CHIBIOS}/test/rt/testbmk.c
# Required include directories

153
test/rt/testsys.c Normal file
View File

@ -0,0 +1,153 @@
/*
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "ch.h"
#include "test.h"
/**
* @page test_sys System test
*
* File: @ref testsys.c
*
* <h2>Description</h2>
* This module implements the test sequence for the @ref system subsystem.
*
* <h2>Objective</h2>
* Objective of the test module is to cover 100% of the @ref system
* subsystem code.
*
* <h2>Preconditions</h2>
* None.
*
* <h2>Test Cases</h2>
* - @subpage test_sys_001
* - @subpage test_sys_002
* .
* @file testsys.c
* @brief System test source file
* @file testsys.h
* @brief System header file
*/
/**
* @page test_sys_001 Critical zones check
*
* <h2>Description</h2>
* The critical zones API is invoked for coverage.
*/
static void vtcb(void *p) {
syssts_t sts;
(void)p;
/* Testing normal case.*/
chSysLockFromISR();
chSysUnlockFromISR();
/* Reentrant case.*/
chSysLockFromISR();
sts = chSysGetStatusAndLockX();
chSysRestoreStatusX(sts);
chSysUnlockFromISR();
}
static void sys1_execute(void) {
syssts_t sts;
virtual_timer_t vt;
/* Testing normal case.*/
sts = chSysGetStatusAndLockX();
chSysRestoreStatusX(sts);
/* Reentrant case.*/
chSysLock();
sts = chSysGetStatusAndLockX();
chSysRestoreStatusX(sts);
chSysUnlock();
/* Unconditional lock.*/
chSysUnconditionalLock();
chSysUnconditionalLock();
chSysUnlock();
/* Unconditional unlock.*/
chSysLock();
chSysUnconditionalUnlock();
chSysUnconditionalUnlock();
/*/Testing from ISR context using a virtual timer.*/
chVTObjectInit(&vt);
chVTSet(&vt, 1, vtcb, NULL);
chThdSleep(10);
test_assert(1, chVTIsArmed(&vt) == false, "timer still armed");
}
ROMCONST struct testcase testsys1 = {
"System, critical zones",
NULL,
NULL,
sys1_execute
};
/**
* @page test_sys_002 System integrity check
*
* <h2>Description</h2>
* The chSysIntegrityCheckI() API is invoked in order to asses the state of the
* system data structures.
*/
static void sys2_execute(void) {
bool result;
chSysLock();
result = chSysIntegrityCheckI(CH_INTEGRITY_RLIST);
chSysUnlock();
test_assert(1, result == false, "ready list check failed");
chSysLock();
result = chSysIntegrityCheckI(CH_INTEGRITY_VTLIST);
chSysUnlock();
test_assert(2, result == false, "virtual timers list check failed");
chSysLock();
result = chSysIntegrityCheckI(CH_INTEGRITY_REGISTRY);
chSysUnlock();
test_assert(3, result == false, "registry list check failed");
chSysLock();
result = chSysIntegrityCheckI(CH_INTEGRITY_PORT);
chSysUnlock();
test_assert(4, result == false, "port layer check failed");
}
ROMCONST struct testcase testsys2 = {
"System, integrity",
NULL,
NULL,
sys2_execute
};
/**
* @brief Test sequence for messages.
*/
ROMCONST struct testcase * ROMCONST patternsys[] = {
&testsys1,
&testsys2,
NULL
};

22
test/rt/testsys.h Normal file
View File

@ -0,0 +1,22 @@
/*
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _TESTSYS_H_
#define _TESTSYS_H_
extern ROMCONST struct testcase * ROMCONST patternsys[];
#endif /* _TESTSYS_H_ */