1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #2102 from Kijewski/embunit-module

tests: make embUnit a normal sys module
This commit is contained in:
Ludwig Ortmann 2014-12-22 12:50:26 +01:00
commit dc916ad458
62 changed files with 83 additions and 94 deletions

View File

@ -3,11 +3,4 @@ MODULE = $(APPLICATION)
DIRS += $(RIOTCPU)/$(CPU) $(RIOTBOARD)/$(BOARD)
DIRS += $(RIOTBASE)/core $(RIOTBASE)/drivers $(RIOTBASE)/sys
ifneq (,$(filter embunit,$(USEMODULE)))
DIRS += $(RIOTBASE)/tests/unittests/embunit/embUnit
endif
ifneq (,$(filter embunit_textui,$(USEMODULE)))
DIRS += $(RIOTBASE)/tests/unittests/embunit/textui
endif
include $(RIOTBASE)/Makefile.base

View File

@ -69,3 +69,13 @@ endif
ifneq (,$(filter oneway_malloc,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/oneway-malloc/include
endif
ifneq (,$(filter embunit,$(USEMODULE)))
ifeq ($(OUTPUT),XML)
CFLAGS += -DOUTPUT=OUTPUT_XML
else ifeq ($(OUTPUT),TEXT)
CFLAGS += -DOUTPUT=OUTPUT_TEXT
else ifeq ($(OUTPUT),COMPILER)
CFLAGS += -DOUTPUT=OUTPUT_COMPILER
endif
endif

View File

@ -32,7 +32,7 @@
*
* $Id: AssertImpl.c,v 1.5 2004/02/10 16:15:25 arms22 Exp $
*/
#include "config.h"
#include "embUnit_config.h"
#include "stdImpl.h"
#include "AssertImpl.h"

View File

@ -64,7 +64,7 @@ static void CompilerOutputter_printFailure(OutputterRef self,TestRef test,char *
{
(void)self;
(void)runCount;
fprintf(stdout,"%s %d: %s: %s\n", file, line, Test_name(test), msg);
printf("%s %d: %s: %s\n", file, line, Test_name(test), msg);
}
static void CompilerOutputter_printStatistics(OutputterRef self,TestResultRef result)

View File

@ -1,5 +1,5 @@
MODULE = embunit
INCLUDES += -I$(RIOTBASE)/tests/unittests/embunit
INCLUDES += -I$(RIOTBASE)/sys/include/embUnit
include $(RIOTBASE)/Makefile.base

View File

@ -32,7 +32,7 @@
*
* $Id: TestRunner.c,v 1.6 2004/02/10 16:19:29 arms22 Exp $
*/
#include "config.h"
#include "embUnit_config.h"
#include "stdImpl.h"
#include "Test.h"
#include "TestListener.h"

View File

@ -43,7 +43,7 @@ static void TextOutputter_printHeader(OutputterRef self)
static void TextOutputter_printStartTest(OutputterRef self,TestRef test)
{
(void)self;
fprintf(stdout,"- %s\n",Test_name(test));
printf("- %s\n",Test_name(test));
}
static void TextOutputter_printEndTest(OutputterRef self,TestRef test)
@ -55,22 +55,22 @@ static void TextOutputter_printEndTest(OutputterRef self,TestRef test)
static void TextOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount)
{
(void)self;
fprintf(stdout,"%d) OK %s\n", runCount, Test_name(test));
printf("%d) OK %s\n", runCount, Test_name(test));
}
static void TextOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount)
{
(void)self;
fprintf(stdout,"%d) NG %s (%s %d) %s\n", runCount, Test_name(test), file, line, msg);
printf("%d) NG %s (%s %d) %s\n", runCount, Test_name(test), file, line, msg);
}
static void TextOutputter_printStatistics(OutputterRef self,TestResultRef result)
{
(void)self;
if (result->failureCount) {
fprintf(stdout,"\nrun %d failures %d\n",result->runCount,result->failureCount);
printf("\nrun %d failures %d\n",result->runCount,result->failureCount);
} else {
fprintf(stdout,"\nOK (%d tests)\n",result->runCount);
printf("\nOK (%d tests)\n",result->runCount);
}
}

View File

@ -40,55 +40,55 @@ static char *stylesheet_;
static void XMLOutputter_printHeader(OutputterRef self)
{
(void)self;
fprintf(stdout,"<?xml version=\"1.0\" encoding='shift_jis' standalone='yes' ?>\n");
printf("<?xml version=\"1.0\" encoding='shift_jis' standalone='yes' ?>\n");
if (stylesheet_)
fprintf(stdout,"<?xml-stylesheet type=\"text/xsl\" href=\"%s\" ?>\n",stylesheet_);
fprintf(stdout,"<TestRun>\n");
printf("<?xml-stylesheet type=\"text/xsl\" href=\"%s\" ?>\n",stylesheet_);
printf("<TestRun>\n");
}
static void XMLOutputter_printStartTest(OutputterRef self,TestRef test)
{
(void)self;
fprintf(stdout,"<%s>\n",Test_name(test));
printf("<%s>\n",Test_name(test));
}
static void XMLOutputter_printEndTest(OutputterRef self,TestRef test)
{
(void)self;
fprintf(stdout,"</%s>\n",Test_name(test));
printf("</%s>\n",Test_name(test));
}
static void XMLOutputter_printSuccessful(OutputterRef self,TestRef test,int runCount)
{
(void)self;
fprintf(stdout,"<Test id=\"%d\">\n",runCount);
fprintf(stdout,"<Name>%s</Name>\n",Test_name(test));
fprintf(stdout,"</Test>\n");
printf("<Test id=\"%d\">\n",runCount);
printf("<Name>%s</Name>\n",Test_name(test));
printf("</Test>\n");
}
static void XMLOutputter_printFailure(OutputterRef self,TestRef test,char *msg,int line,char *file,int runCount)
{
(void)self;
fprintf(stdout,"<FailedTest id=\"%d\">\n",runCount);
fprintf(stdout,"<Name>%s</Name>\n",Test_name(test));
fprintf(stdout,"<Location>\n");
fprintf(stdout,"<File>%s</File>\n",file);
fprintf(stdout,"<Line>%d</Line>\n",line);
fprintf(stdout,"</Location>\n");
fprintf(stdout,"<Message>%s</Message>\n",msg);
fprintf(stdout,"</FailedTest>\n");
printf("<FailedTest id=\"%d\">\n",runCount);
printf("<Name>%s</Name>\n",Test_name(test));
printf("<Location>\n");
printf("<File>%s</File>\n",file);
printf("<Line>%d</Line>\n",line);
printf("</Location>\n");
printf("<Message>%s</Message>\n",msg);
printf("</FailedTest>\n");
}
static void XMLOutputter_printStatistics(OutputterRef self,TestResultRef result)
{
(void)self;
fprintf(stdout,"<Statistics>\n");
fprintf(stdout,"<Tests>%d</Tests>\n",result->runCount);
printf("<Statistics>\n");
printf("<Tests>%d</Tests>\n",result->runCount);
if (result->failureCount) {
fprintf(stdout,"<Failures>%d</Failures>\n",result->failureCount);
printf("<Failures>%d</Failures>\n",result->failureCount);
}
fprintf(stdout,"</Statistics>\n");
fprintf(stdout,"</TestRun>\n");
printf("</Statistics>\n");
printf("</TestRun>\n");
}
static const OutputterImplement XMLOutputterImplement = {

View File

@ -7,21 +7,18 @@
*/
/**
* @addtogroup unittests
* @addtogroup unittests
* @addtogroup sys
* @{
*
* @file unittests.h
* @brief Common header file for unittests
* @file
* @brief Common header file for unittests
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef __UNITTESTS__H
#define __UNITTESTS__H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __SYS__EMB_UNIT__H
#define __SYS__EMB_UNIT__H
#include "embUnit/embUnit.h"
@ -31,17 +28,17 @@ extern "C" {
# define OUTPUT_COMPILER (4)
# if (OUTPUT==OUTPUT_XML)
# include "textui/XMLOutputter.h"
# include "embUnit/XMLOutputter.h"
# define OUTPUTTER (XMLOutputter_outputter())
# elif (OUTPUT==OUTPUT_TEXT)
# include "textui/TextOutputter.h"
# include "embUnit/TextOutputter.h"
# define OUTPUTTER (TextOutputter_outputter())
# elif (OUTPUT==OUTPUT_COMPILER)
# include "textui/CompilerOutputter.h"
# include "embUnit/CompilerOutputter.h"
# define OUTPUTTER (CompilerOutputter_outputter())
# endif
# include "textui/TextUIRunner.h"
# include "embUnit/TextUIRunner.h"
# define TESTS_START() TextUIRunner_start()
# define TESTS_RUN(t) TextUIRunner_runTest(t)
@ -52,8 +49,16 @@ extern "C" {
# define TESTS_END() TestRunner_end()
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/

View File

@ -6,19 +6,6 @@ BOARD_INSUFFICIENT_RAM := chronos msb-430 msb-430h redbee-econotag stm32f0discov
USEMODULE += embunit
INCLUDES += -I$(RIOTBASE)/tests/unittests/embunit
ifeq ($(OUTPUT),XML)
CFLAGS += -DOUTPUT=OUTPUT_XML
USEMODULE += embunit_textui
else ifeq ($(OUTPUT),TEXT)
CFLAGS += -DOUTPUT=OUTPUT_TEXT
USEMODULE += embunit_textui
else ifeq ($(OUTPUT),COMPILER)
CFLAGS += -DOUTPUT=OUTPUT_COMPILER
USEMODULE += embunit_textui
endif
# Some randomly generated but still deterministic values for testing
CFLAGS += -DTEST_STRING8="\"o<\\\\rrB/q\""
CFLAGS += -DTEST_STRING12="\"50U'HLKC3_ft\""

View File

@ -1,5 +0,0 @@
MODULE = embunit_textui
INCLUDES += -I$(RIOTBASE)/tests/unittests/embunit
include $(RIOTBASE)/Makefile.base

View File

@ -6,9 +6,9 @@
* directory for more details.
*/
#include "unittests.h"
#include "map.h"
#include "embUnit.h"
#include "lpm.h"
#define UNCURRY(FUN, ARGS) FUN(ARGS)

View File

@ -18,7 +18,7 @@
#ifndef __TESTS_BLOOM_H_
#define __TESTS_BLOOM_H_
#include "../unittests.h"
#include "embUnit.h"
#ifdef __cplusplus
extern "C" {

View File

@ -13,7 +13,7 @@
* @author Jana Cavojska <jana.cavojska9@gmail.com>
*/
#include "../unittests.h"
#include "embUnit.h"
#include "bitarithm.h"
#include "cbor.h"

View File

@ -8,7 +8,7 @@
#include <limits.h>
#include "embUnit/embUnit.h"
#include "embUnit.h"
#include "atomic.h"

View File

@ -9,7 +9,7 @@
#include <limits.h>
#include <stdint.h>
#include "embUnit/embUnit.h"
#include "embUnit.h"
#include "bitarithm.h"

View File

@ -6,7 +6,7 @@
* directory for more details.
*/
#include "embUnit/embUnit.h"
#include "embUnit.h"
#include "byteorder.h"

View File

@ -6,7 +6,7 @@
* directory for more details.
*/
#include "embUnit/embUnit.h"
#include "embUnit.h"
#include "cib.h"

View File

@ -8,7 +8,7 @@
#include <string.h>
#include "embUnit/embUnit.h"
#include "embUnit.h"
#include "clist.h"

View File

@ -6,7 +6,7 @@
* directory for more details.
*/
#include "embUnit/embUnit.h"
#include "embUnit.h"
#include "lifo.h"

View File

@ -7,7 +7,7 @@
*/
#include <string.h>
#include "embUnit/embUnit.h"
#include "embUnit.h"
#include "priority_queue.h"

View File

@ -18,7 +18,7 @@
#ifndef __TESTS_CORE_H_
#define __TESTS_CORE_H_
#include "../unittests.h"
#include "embUnit.h"
#ifdef __cplusplus
extern "C" {

View File

@ -18,7 +18,7 @@
#ifndef __TESTS_CRYPTO_H_
#define __TESTS_CRYPTO_H_
#include "../unittests.h"
#include "embUnit.h"
#ifdef __cplusplus
extern "C" {

View File

@ -12,7 +12,7 @@
#include "clist.h"
#include "embUnit/embUnit.h"
#include "embUnit.h"
#include "netdev_dummy.h"

View File

@ -18,7 +18,7 @@
#ifndef __TESTS_NETDEV_DUMMY_H_
#define __TESTS_NETDEV_DUMMY_H_
#include "../unittests.h"
#include "embUnit.h"
#ifdef __cplusplus
extern "C" {

View File

@ -14,7 +14,7 @@
#include <errno.h>
#include <stdint.h>
#include "embUnit/embUnit.h"
#include "embUnit.h"
#include "pktbuf.h"

View File

@ -18,7 +18,7 @@
#ifndef __TESTS_PKTBUF_H_
#define __TESTS_PKTBUF_H_
#include "../unittests.h"
#include "embUnit.h"
#ifdef __cplusplus
extern "C" {

View File

@ -13,7 +13,7 @@
*/
#include <string.h>
#include "embUnit/embUnit.h"
#include "embUnit.h"
#include "pktqueue.h"

View File

@ -18,7 +18,7 @@
#ifndef __TESTS_PKTQUEUE_H_
#define __TESTS_PKTQUEUE_H_
#include "../unittests.h"
#include "embUnit.h"
#ifdef __cplusplus
extern "C" {
@ -29,7 +29,6 @@ extern "C" {
*/
void tests_pktqueue(void);
#ifdef __cplusplus
}
#endif

View File

@ -19,7 +19,7 @@
#ifndef __TESTS_TIMEX_H_
#define __TESTS_TIMEX_H_
#include "../unittests.h"
#include "embUnit.h"
#ifdef __cplusplus
extern "C" {

View File

@ -17,6 +17,7 @@
*/
#include "tests-ubjson.h"
#include "kernel.h"
typedef enum {
BEFORE_ARRAY_1 = __LINE__,

View File

@ -17,6 +17,7 @@
*/
#include "tests-ubjson.h"
#include "kernel.h"
typedef enum {
BEFORE_ARRAY_1 = __LINE__,

View File

@ -22,6 +22,8 @@
#include "sched.h"
#include "msg.h"
#include "mutex.h"
#include "pipe.h"
#include "irq.h"
static pipe_t communication_pipe;
static ringbuffer_t pipe_rb;

View File

@ -29,13 +29,9 @@
#ifndef TESTS__UBJSON_H__
#define TESTS__UBJSON_H__
#include "../unittests.h"
#include "msg.h"
#include "kernel_macros.h"
#include "irq.h"
#include "embUnit.h"
#include "ubjson.h"
#include "pipe.h"
#ifdef __cplusplus
extern "C" {