1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Create unittest application

This commit is contained in:
Martin Lenders 2014-04-07 15:15:25 +02:00
parent 0c6b5ba671
commit 9ce8ab2275
3 changed files with 91 additions and 0 deletions

21
tests/unittests/Makefile Normal file
View File

@ -0,0 +1,21 @@
export PROJECT = unittests
include ../Makefile.tests_common
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
.PHONY : all clean core
include $(RIOTBASE)/Makefile.include

View File

@ -0,0 +1,6 @@
# Unittests
see [Wiki][Testing-RIOT]
[Testing-RIOT]: https://github.com/RIOT-OS/RIOT/wiki/Testing-RIOT

64
tests/unittests/main.c Normal file
View File

@ -0,0 +1,64 @@
/*
* Copyright (C) 2014 Martin Lenders
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/
#include "embUnit/embUnit.h"
#include "lpm.h"
#ifdef OUTPUT
#define OUTPUT_XML (1)
#define OUTPUT_TEXT (2)
#define OUTPUT_COMPILER (4)
#if (OUTPUT==OUTPUT_XML)
#include "textui/XMLOutputter.h"
#define OUTPUTTER (XMLOutputter_outputter())
#endif
#if (OUTPUT==OUTPUT_TEXT)
#include "textui/TextOutputter.h"
#define OUTPUTTER (TextOutputter_outputter())
#endif
#if (OUTPUT==OUTPUT_COMPILER)
#include "textui/CompilerOutputter.h"
#define OUTPUTTER (CompilerOutputter_outputter())
#endif
#include "textui/TextUIRunner.h"
#define TESTS_START() TextUIRunner_start()
#define TESTS_RUN(t) TextUIRunner_runTest(t)
#define TESTS_END() TextUIRunner_end()
#else
#define TESTS_START() TestRunner_start()
#define TESTS_RUN(t) TestRunner_runTest(t)
#define TESTS_END() TestRunner_end()
#endif
int main(void)
{
#ifdef OUTPUT
TextUIRunner_setOutputter(OUTPUTTER);
#endif
TESTS_START();
/* put test TEST_RUN() calls here */
TESTS_END();
lpm_set(LPM_POWERDOWN);
return 0;
}