Squashed 'tests/unity/' content from commit 1782bab

git-subtree-dir: tests/unity
git-subtree-split: 1782bab0bacd349a45bc215ff91f082912cd7a64
This commit is contained in:
Max Bruckner
2017-02-07 21:30:57 +01:00
commit 6b9b57be22
125 changed files with 16533 additions and 0 deletions

63
test/Makefile Normal file
View File

@@ -0,0 +1,63 @@
CC = gcc
ifeq ($(shell uname -s), Darwin)
CC = clang
endif
ifeq ($(findstring clang, $(CC)), clang)
E = -Weverything
CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes
CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn
endif
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Wconversion -Werror
CFLAGS += -Wno-switch-enum -Wno-double-promotion
CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \
-Wstrict-prototypes -Wswitch-default -Wundef
#DEBUG = -O0 -g
CFLAGS += $(DEBUG)
DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy
DEFINES += -D UNITY_SUPPORT_64 -D UNITY_INCLUDE_DOUBLE
SRC = ../src/unity.c tests/testunity.c build/testunityRunner.c
INC_DIR = -I ../src
COV_FLAGS = -fprofile-arcs -ftest-coverage -I ../../src
BUILD_DIR = build
TARGET = build/testunity-cov.exe
# To generate coverage, call 'make -s', the default target runs.
# For verbose output of all the tests, run 'make test'.
default: coverage
.PHONY: default coverage test clean
coverage: DEFINES += -D UNITY_NO_WEAK
coverage: $(BUILD_DIR)/testunityRunner.c
cd $(BUILD_DIR) && \
$(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC), ../$i) $(COV_FLAGS) -o ../$(TARGET)
rm -f $(BUILD_DIR)/*.gcda
./$(TARGET) | grep 'Tests\|]]]' -A1
cd $(BUILD_DIR) && \
gcov unity.c | head -3
grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true
test: $(BUILD_DIR)/testunityRunner.c
$(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC) -o $(TARGET)
./$(TARGET)
# Compile only, for testing that preprocessor detection works
UNITY_C_ONLY =-c ../src/unity.c -o $(BUILD_DIR)/unity.o
intDetection:
$(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_STDINT_H
$(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_LIMITS_H
$(BUILD_DIR)/testunityRunner.c: tests/testunity.c | $(BUILD_DIR)
awk $(AWK_SCRIPT) tests/testunity.c > $@
AWK_SCRIPT=\
'/^void test/{ declarations[d++]=$$0; gsub(/\(?void\)? ?/,""); tests[t++]=$$0; line[u++]=NR } \
END{ print "\#include \"unity.h\" /* Autogenerated by awk in Makefile */" ; \
for (i=0; i<d; i++) { print declarations[i] ";" } \
print "int main(void)\n{\n UnityBegin(\"" FILENAME "\");" ; \
for (i=0; i<t; i++) { print " RUN_TEST(" tests[i] ", " line[i] ");" } \
print " return UNITY_END();\n}" }'
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
clean:
rm -f $(TARGET) $(BUILD_DIR)/*.gc* $(BUILD_DIR)/testunityRunner.c

View File

@@ -0,0 +1,61 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
Try { \
setUp(); \
TestFunc(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "CException.h"
#include "funky.h"
#include "stanky.h"
#include <setjmp.h>
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
extern void test_TheThirdThingToTest(void);
extern void test_TheFourthThingToTest(void);
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
tearDown();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/testsample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
RUN_TEST(test_TheThirdThingToTest, 53);
RUN_TEST(test_TheFourthThingToTest, 58);
return (UnityEnd());
}

View File

@@ -0,0 +1,57 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "funky.h"
#include "stanky.h"
#include <setjmp.h>
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
extern void test_TheThirdThingToTest(void);
extern void test_TheFourthThingToTest(void);
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
tearDown();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/testsample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
RUN_TEST(test_TheThirdThingToTest, 53);
RUN_TEST(test_TheFourthThingToTest, 58);
return (UnityEnd());
}

View File

@@ -0,0 +1,55 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "testsample_head1.h"
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
extern void test_TheThirdThingToTest(void);
extern void test_TheFourthThingToTest(void);
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
tearDown();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/testsample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
RUN_TEST(test_TheThirdThingToTest, 53);
RUN_TEST(test_TheFourthThingToTest, 58);
return (UnityEnd());
}

View File

@@ -0,0 +1,15 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
#ifndef _TESTSAMPLE_HEAD1_H
#define _TESTSAMPLE_HEAD1_H
#include "unity.h"
#include "funky.h"
#include "stanky.h"
#include <setjmp.h>
void test_TheFirstThingToTest(void);
void test_TheSecondThingToTest(void);
void test_TheThirdThingToTest(void);
void test_TheFourthThingToTest(void);
#endif

View File

@@ -0,0 +1,80 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
Try { \
setUp(); \
TestFunc(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
CMock_Verify(); \
} \
CMock_Destroy(); \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include "cmock.h"
#include <setjmp.h>
#include <stdio.h>
#include "CException.h"
#include "funky.h"
#include <setjmp.h>
#include "Mockstanky.h"
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
/*=======Mock Management=====*/
static void CMock_Init(void)
{
Mockstanky_Init();
}
static void CMock_Verify(void)
{
Mockstanky_Verify();
}
static void CMock_Destroy(void)
{
Mockstanky_Destroy();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
CMock_Verify();
CMock_Destroy();
tearDown();
CMock_Init();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/mocksample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd());
}

View File

@@ -0,0 +1,76 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
CMock_Verify(); \
} \
CMock_Destroy(); \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include "cmock.h"
#include <setjmp.h>
#include <stdio.h>
#include "funky.h"
#include <setjmp.h>
#include "Mockstanky.h"
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
/*=======Mock Management=====*/
static void CMock_Init(void)
{
Mockstanky_Init();
}
static void CMock_Verify(void)
{
Mockstanky_Verify();
}
static void CMock_Destroy(void)
{
Mockstanky_Destroy();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
CMock_Verify();
CMock_Destroy();
tearDown();
CMock_Init();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/mocksample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd());
}

View File

@@ -0,0 +1,75 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
CMock_Verify(); \
} \
CMock_Destroy(); \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include "cmock.h"
#include <setjmp.h>
#include <stdio.h>
#include "testsample_mock_head1.h"
#include "Mockstanky.h"
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
/*=======Mock Management=====*/
static void CMock_Init(void)
{
Mockstanky_Init();
}
static void CMock_Verify(void)
{
Mockstanky_Verify();
}
static void CMock_Destroy(void)
{
Mockstanky_Destroy();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
CMock_Verify();
CMock_Destroy();
tearDown();
CMock_Init();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/mocksample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd());
}

View File

@@ -0,0 +1,13 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
#ifndef _TESTSAMPLE_MOCK_HEAD1_H
#define _TESTSAMPLE_MOCK_HEAD1_H
#include "unity.h"
#include "cmock.h"
#include "funky.h"
#include <setjmp.h>
void test_TheFirstThingToTest(void);
void test_TheSecondThingToTest(void);
#endif

View File

@@ -0,0 +1,89 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
Try { \
setUp(); \
TestFunc(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
CMock_Verify(); \
} \
CMock_Destroy(); \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include "cmock.h"
#include <setjmp.h>
#include <stdio.h>
#include "CException.h"
#include "one.h"
#include "two.h"
#include "funky.h"
#include <setjmp.h>
#include "Mockstanky.h"
int GlobalExpectCount;
int GlobalVerifyOrder;
char* GlobalOrderError;
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
/*=======Mock Management=====*/
static void CMock_Init(void)
{
GlobalExpectCount = 0;
GlobalVerifyOrder = 0;
GlobalOrderError = NULL;
Mockstanky_Init();
}
static void CMock_Verify(void)
{
Mockstanky_Verify();
}
static void CMock_Destroy(void)
{
Mockstanky_Destroy();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
CMock_Verify();
CMock_Destroy();
tearDown();
CMock_Init();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/mocksample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd());
}

View File

@@ -0,0 +1,89 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
CMock_Verify(); \
} \
CMock_Destroy(); \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include "cmock.h"
#include <setjmp.h>
#include <stdio.h>
#include "funky.h"
#include <setjmp.h>
#include "Mockstanky.h"
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
/*=======Mock Management=====*/
static void CMock_Init(void)
{
Mockstanky_Init();
}
static void CMock_Verify(void)
{
Mockstanky_Verify();
}
static void CMock_Destroy(void)
{
Mockstanky_Destroy();
}
/*=======Suite Setup=====*/
static int suite_setup(void)
{
a_custom_setup();
}
/*=======Suite Teardown=====*/
static int suite_teardown(int num_failures)
{
a_custom_teardown();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
CMock_Verify();
CMock_Destroy();
tearDown();
CMock_Init();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
suite_setup();
UnityBegin("testdata/mocksample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return suite_teardown(UnityEnd());
}

View File

@@ -0,0 +1,77 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST_NO_ARGS
#define RUN_TEST(TestFunc, TestLineNum, ...) \
{ \
Unity.CurrentTestName = #TestFunc "(" #__VA_ARGS__ ")"; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(__VA_ARGS__); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
CMock_Verify(); \
} \
CMock_Destroy(); \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include "cmock.h"
#include <setjmp.h>
#include <stdio.h>
#include "funky.h"
#include <setjmp.h>
#include "Mockstanky.h"
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
/*=======Mock Management=====*/
static void CMock_Init(void)
{
Mockstanky_Init();
}
static void CMock_Verify(void)
{
Mockstanky_Verify();
}
static void CMock_Destroy(void)
{
Mockstanky_Destroy();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
CMock_Verify();
CMock_Destroy();
tearDown();
CMock_Init();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/mocksample.c");
RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS);
RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS);
CMock_Guts_MemFreeFinal();
return (UnityEnd());
}

View File

@@ -0,0 +1,89 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
Try { \
setUp(); \
TestFunc(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
CMock_Verify(); \
} \
CMock_Destroy(); \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include "cmock.h"
#include <setjmp.h>
#include <stdio.h>
#include "CException.h"
#include "one.h"
#include "two.h"
#include "funky.h"
#include <setjmp.h>
#include "Mockstanky.h"
int GlobalExpectCount;
int GlobalVerifyOrder;
char* GlobalOrderError;
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
/*=======Mock Management=====*/
static void CMock_Init(void)
{
GlobalExpectCount = 0;
GlobalVerifyOrder = 0;
GlobalOrderError = NULL;
Mockstanky_Init();
}
static void CMock_Verify(void)
{
Mockstanky_Verify();
}
static void CMock_Destroy(void)
{
Mockstanky_Destroy();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
CMock_Verify();
CMock_Destroy();
tearDown();
CMock_Init();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/mocksample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd());
}

View File

@@ -0,0 +1,89 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
CMock_Verify(); \
} \
CMock_Destroy(); \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include "cmock.h"
#include <setjmp.h>
#include <stdio.h>
#include "funky.h"
#include <setjmp.h>
#include "Mockstanky.h"
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
/*=======Mock Management=====*/
static void CMock_Init(void)
{
Mockstanky_Init();
}
static void CMock_Verify(void)
{
Mockstanky_Verify();
}
static void CMock_Destroy(void)
{
Mockstanky_Destroy();
}
/*=======Suite Setup=====*/
static int suite_setup(void)
{
a_custom_setup();
}
/*=======Suite Teardown=====*/
static int suite_teardown(int num_failures)
{
a_custom_teardown();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
CMock_Verify();
CMock_Destroy();
tearDown();
CMock_Init();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
suite_setup();
UnityBegin("testdata/mocksample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return suite_teardown(UnityEnd());
}

View File

@@ -0,0 +1,90 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
Try { \
setUp(); \
TestFunc(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
CMock_Verify(); \
} \
CMock_Destroy(); \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include "cmock.h"
#include <setjmp.h>
#include <stdio.h>
#include "CException.h"
#include "two.h"
#include "three.h"
#include <four.h>
#include "funky.h"
#include <setjmp.h>
#include "Mockstanky.h"
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
/*=======Mock Management=====*/
static void CMock_Init(void)
{
Mockstanky_Init();
}
static void CMock_Verify(void)
{
Mockstanky_Verify();
}
static void CMock_Destroy(void)
{
Mockstanky_Destroy();
}
/*=======Suite Setup=====*/
static int suite_setup(void)
{
a_yaml_setup();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
CMock_Verify();
CMock_Destroy();
tearDown();
CMock_Init();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
suite_setup();
UnityBegin("testdata/mocksample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd());
}

View File

@@ -0,0 +1,67 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
Try { \
setUp(); \
TestFunc(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "CException.h"
#include "one.h"
#include "two.h"
#include "funky.h"
#include "stanky.h"
#include <setjmp.h>
int GlobalExpectCount;
int GlobalVerifyOrder;
char* GlobalOrderError;
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
extern void test_TheThirdThingToTest(void);
extern void test_TheFourthThingToTest(void);
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
tearDown();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/testsample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
RUN_TEST(test_TheThirdThingToTest, 53);
RUN_TEST(test_TheFourthThingToTest, 58);
return (UnityEnd());
}

View File

@@ -0,0 +1,70 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "funky.h"
#include "stanky.h"
#include <setjmp.h>
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
extern void test_TheThirdThingToTest(void);
extern void test_TheFourthThingToTest(void);
/*=======Suite Setup=====*/
static int suite_setup(void)
{
a_custom_setup();
}
/*=======Suite Teardown=====*/
static int suite_teardown(int num_failures)
{
a_custom_teardown();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
tearDown();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
suite_setup();
UnityBegin("testdata/testsample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
RUN_TEST(test_TheThirdThingToTest, 53);
RUN_TEST(test_TheFourthThingToTest, 58);
return suite_teardown(UnityEnd());
}

View File

@@ -0,0 +1,58 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST_NO_ARGS
#define RUN_TEST(TestFunc, TestLineNum, ...) \
{ \
Unity.CurrentTestName = #TestFunc "(" #__VA_ARGS__ ")"; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(__VA_ARGS__); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "funky.h"
#include "stanky.h"
#include <setjmp.h>
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
extern void test_TheThirdThingToTest(void);
extern void test_TheFourthThingToTest(void);
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
tearDown();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/testsample.c");
RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS);
RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS);
RUN_TEST(test_TheThirdThingToTest, 53, RUN_TEST_NO_ARGS);
RUN_TEST(test_TheFourthThingToTest, 58, RUN_TEST_NO_ARGS);
return (UnityEnd());
}

View File

@@ -0,0 +1,67 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
Try { \
setUp(); \
TestFunc(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "CException.h"
#include "one.h"
#include "two.h"
#include "funky.h"
#include "stanky.h"
#include <setjmp.h>
int GlobalExpectCount;
int GlobalVerifyOrder;
char* GlobalOrderError;
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
extern void test_TheThirdThingToTest(void);
extern void test_TheFourthThingToTest(void);
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
tearDown();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("testdata/testsample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
RUN_TEST(test_TheThirdThingToTest, 53);
RUN_TEST(test_TheFourthThingToTest, 58);
return (UnityEnd());
}

View File

@@ -0,0 +1,70 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "funky.h"
#include "stanky.h"
#include <setjmp.h>
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
extern void test_TheThirdThingToTest(void);
extern void test_TheFourthThingToTest(void);
/*=======Suite Setup=====*/
static int suite_setup(void)
{
a_custom_setup();
}
/*=======Suite Teardown=====*/
static int suite_teardown(int num_failures)
{
a_custom_teardown();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
tearDown();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
suite_setup();
UnityBegin("testdata/testsample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
RUN_TEST(test_TheThirdThingToTest, 53);
RUN_TEST(test_TheFourthThingToTest, 58);
return suite_teardown(UnityEnd());
}

View File

@@ -0,0 +1,71 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
Try { \
setUp(); \
TestFunc(); \
} Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "CException.h"
#include "two.h"
#include "three.h"
#include <four.h>
#include "funky.h"
#include "stanky.h"
#include <setjmp.h>
/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_TheFirstThingToTest(void);
extern void test_TheSecondThingToTest(void);
extern void test_TheThirdThingToTest(void);
extern void test_TheFourthThingToTest(void);
/*=======Suite Setup=====*/
static int suite_setup(void)
{
a_yaml_setup();
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
tearDown();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
suite_setup();
UnityBegin("testdata/testsample.c");
RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43);
RUN_TEST(test_TheThirdThingToTest, 53);
RUN_TEST(test_TheFourthThingToTest, 58);
return (UnityEnd());
}

72
test/rakefile Normal file
View File

@@ -0,0 +1,72 @@
# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/'
$verbose = false
require 'rake'
require 'rake/clean'
require UNITY_ROOT + 'rakefile_helper'
require 'rspec/core/rake_task'
TEMP_DIRS = [
File.join(UNITY_ROOT, 'build'),
File.join(UNITY_ROOT, 'sandbox')
]
TEMP_DIRS.each do |dir|
directory(dir)
CLOBBER.include(dir)
end
task :prepare_for_tests => TEMP_DIRS
include RakefileHelpers
# Load proper GCC as defult configuration
DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'
configure_toolchain(DEFAULT_CONFIG_FILE)
desc "Test unity with its own unit tests"
task :unit => [:prepare_for_tests] do
run_tests get_unit_test_files
end
desc "Test unity's helper scripts"
task :scripts => [:prepare_for_tests] do
Dir['tests/test_*.rb'].each do |scriptfile|
require "./"+scriptfile
end
end
desc "Run all rspecs"
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/**/*_spec.rb'
end
desc "Generate test summary"
task :summary do
report_summary
end
desc "Build and test Unity"
task :all => [:clean, :prepare_for_tests, :scripts, :unit, :summary]
task :default => [:clobber, :all]
task :ci => [:no_color, :default]
task :cruise => [:no_color, :default]
desc "Load configuration"
task :config, :config_file do |t, args|
configure_toolchain(args[:config_file])
end
task :no_color do
$colour_output = false
end
task :verbose do
$verbose = true
end

257
test/rakefile_helper.rb Normal file
View File

@@ -0,0 +1,257 @@
# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
require 'yaml'
require 'fileutils'
require UNITY_ROOT + '../auto/unity_test_summary'
require UNITY_ROOT + '../auto/generate_test_runner'
require UNITY_ROOT + '../auto/colour_reporter'
module RakefileHelpers
C_EXTENSION = '.c'
def load_configuration(config_file)
unless ($configured)
$cfg_file = "targets/#{config_file}" unless (config_file =~ /[\\|\/]/)
$cfg = YAML.load(File.read($cfg_file))
$colour_output = false unless $cfg['colour']
$configured = true if (config_file != DEFAULT_CONFIG_FILE)
end
end
def configure_clean
CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
end
def configure_toolchain(config_file=DEFAULT_CONFIG_FILE)
config_file += '.yml' unless config_file =~ /\.yml$/
config_file = config_file unless config_file =~ /[\\|\/]/
load_configuration(config_file)
configure_clean
end
def get_unit_test_files
path = $cfg['compiler']['unit_tests_path'] + 'test*' + C_EXTENSION
path.gsub!(/\\/, '/')
FileList.new(path)
end
def get_local_include_dirs
include_dirs = $cfg['compiler']['includes']['items'].dup
include_dirs.delete_if {|dir| dir.is_a?(Array)}
return include_dirs
end
def extract_headers(filename)
includes = []
lines = File.readlines(filename)
lines.each do |line|
m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/)
if not m.nil?
includes << m[1]
end
end
return includes
end
def find_source_file(header, paths)
paths.each do |dir|
src_file = dir + header.ext(C_EXTENSION)
if (File.exists?(src_file))
return src_file
end
end
return nil
end
def tackit(strings)
if strings.is_a?(Array)
result = "\"#{strings.join}\""
else
result = strings
end
return result
end
def squash(prefix, items)
result = ''
items.each { |item| result += " #{prefix}#{tackit(item)}" }
return result
end
def should(behave, &block)
if block
puts "Should " + behave
yield block
else
puts "UNIMPLEMENTED CASE: Should #{behave}"
end
end
def build_compiler_fields(inject_defines)
command = tackit($cfg['compiler']['path'])
if $cfg['compiler']['defines']['items'].nil?
defines = ''
else
defines = squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + inject_defines)
end
options = squash('', $cfg['compiler']['options'])
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
return {:command => command, :defines => defines, :options => options, :includes => includes}
end
def compile(file, defines=[])
compiler = build_compiler_fields(defines)
defines =
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " +
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
execute(cmd_str + obj_file)
return obj_file
end
def build_linker_fields
command = tackit($cfg['linker']['path'])
if $cfg['linker']['options'].nil?
options = ''
else
options = squash('', $cfg['linker']['options'])
end
if ($cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?)
includes = ''
else
includes = squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
end
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
return {:command => command, :options => options, :includes => includes}
end
def link_it(exe_name, obj_list)
linker = build_linker_fields
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
(obj_list.map{|obj|"#{$cfg['linker']['object_files']['path']}#{obj} "}).join +
$cfg['linker']['bin_files']['prefix'] + ' ' +
$cfg['linker']['bin_files']['destination'] +
exe_name + $cfg['linker']['bin_files']['extension']
execute(cmd_str)
end
def build_simulator_fields
return nil if $cfg['simulator'].nil?
if $cfg['simulator']['path'].nil?
command = ''
else
command = (tackit($cfg['simulator']['path']) + ' ')
end
if $cfg['simulator']['pre_support'].nil?
pre_support = ''
else
pre_support = squash('', $cfg['simulator']['pre_support'])
end
if $cfg['simulator']['post_support'].nil?
post_support = ''
else
post_support = squash('', $cfg['simulator']['post_support'])
end
return {:command => command, :pre_support => pre_support, :post_support => post_support}
end
def execute(command_string, ok_to_fail=false)
report command_string if $verbose
output = `#{command_string}`.chomp
report(output) if ($verbose && !output.nil? && (output.length > 0))
if (($?.exitstatus != 0) && !ok_to_fail)
raise "Command failed. (Returned #{$?.exitstatus})"
end
return output
end
def report_summary
summary = UnityTestSummary.new
summary.set_root_path(UNITY_ROOT)
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
results_glob.gsub!(/\\/, '/')
results = Dir[results_glob]
summary.set_targets(results)
report summary.run
end
def run_tests(test_files)
report 'Running Unity system tests...'
# Tack on TEST define for compiling unit tests
load_configuration($cfg_file)
test_defines = ['TEST']
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
$cfg['compiler']['defines']['items'] << 'TEST'
include_dirs = get_local_include_dirs
# Build and execute each unit test
test_files.each do |test|
obj_list = []
if !$cfg['compiler']['aux_sources'].nil?
$cfg['compiler']['aux_sources'].each do |aux|
obj_list << compile(aux, test_defines)
end
end
# Detect dependencies and build required modules
extract_headers(test).each do |header|
# Compile corresponding source file if it exists
src_file = find_source_file(header, include_dirs)
if !src_file.nil?
obj_list << compile(src_file, test_defines)
end
end
# Build the test runner (generate if configured to do so)
test_base = File.basename(test, C_EXTENSION)
runner_name = test_base + '_Runner.c'
runner_path = ''
if $cfg['compiler']['runner_path'].nil?
runner_path = $cfg['compiler']['build_path'] + runner_name
else
runner_path = $cfg['compiler']['runner_path'] + runner_name
end
options = $cfg[:unity]
options[:use_param_tests] = (test =~ /parameterized/) ? true : false
UnityTestRunnerGenerator.new(options).run(test, runner_path)
obj_list << compile(runner_path, test_defines)
# Build the test module
obj_list << compile(test, test_defines)
# Link the test executable
link_it(test_base, obj_list)
# Execute unit test and generate results file
simulator = build_simulator_fields
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
if simulator.nil?
cmd_str = executable
else
cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
end
output = execute(cmd_str)
test_results = $cfg['compiler']['build_path'] + test_base
if output.match(/OK$/m).nil?
test_results += '.testfail'
else
report output if (!$verbose) #verbose already prints this line, as does a failure
test_results += '.testpass'
end
File.open(test_results, 'w') { |f| f.print output }
end
end
end

View File

@@ -0,0 +1,158 @@
require '../auto/generate_module.rb'
require 'fileutils'
def touch_src(file)
FileUtils.touch "sandbox/src/#{file}"
end
def touch_test(file)
FileUtils.touch "sandbox/test/#{file}"
end
def create_src_with_known_content(file)
File.open("sandbox/src/#{file}", "w") {|f| f.write("the original #{file}")}
end
def create_test_with_known_content(file)
File.open("sandbox/test/#{file}", "w") {|f| f.write("the original #{file}")}
end
def expect_src_content_didnt_change(file)
expect(File.read("sandbox/src/#{file}")).to eq("the original #{file}")
end
def expect_test_content_didnt_change(file)
expect(File.read("sandbox/test/#{file}")).to eq("the original #{file}")
end
def expect_src_file_to_exist(file)
expect(File.exist?("sandbox/src/#{file}")).to be true
end
def expect_test_file_to_exist(file)
expect(File.exist?("sandbox/test/#{file}")).to be true
end
describe "UnityModuleGenerator" do
before do
# clean sandbox and setup our "project" folders
FileUtils.rm_rf "sandbox"
FileUtils.mkdir_p "sandbox"
FileUtils.mkdir_p "sandbox/src"
FileUtils.mkdir_p "sandbox/test"
@options = {
:path_src => "sandbox/src",
:path_tst => "sandbox/test",
}
end
context "with src pattern" do
before do
@options[:pattern] = "src"
end
it "fails when all files already exist" do
# create an existing triad of files
touch_src "meh.c"
touch_src "meh.h"
touch_test "Testmeh.c"
expect {
UnityModuleGenerator.new(@options).generate("meh")
}.to raise_error("ERROR: File meh already exists. Exiting.")
end
it "creates the test file if the source and header files exist" do
# Create the existing files.
touch_src "meh.c"
touch_src "meh.h"
UnityModuleGenerator.new(@options).generate("meh")
expect_test_file_to_exist "Testmeh.c"
end
it "does not alter existing files" do
# Create some files with known content.
create_src_with_known_content "meh.c"
create_src_with_known_content "meh.h"
UnityModuleGenerator.new(@options).generate("meh")
expect_src_content_didnt_change "meh.c"
expect_src_content_didnt_change "meh.c"
end
it "does not alter existing test files" do
# Create some files with known content.
create_test_with_known_content "Testmeh.c"
UnityModuleGenerator.new(@options).generate("meh")
expect_test_content_didnt_change "Testmeh.c"
end
end
context "with mch pattern" do
before do
@options[:pattern] = "mch"
end
it "fails when all files exist" do
touch_src "meh_model.c"
touch_src "meh_conductor.c"
touch_src "meh_hardware.c"
touch_src "meh_model.h"
touch_src "meh_conductor.h"
touch_src "meh_hardware.h"
touch_test "Testmeh_model.c"
touch_test "Testmeh_conductor.c"
touch_test "Testmeh_hardware.c"
expect {
UnityModuleGenerator.new(@options).generate("meh")
}.to raise_error("ERROR: File meh_model already exists. Exiting.")
end
it "creates files that don't exist" do
touch_src "meh_model.c"
touch_src "meh_conductor.c"
touch_src "meh_hardware.c"
touch_src "meh_model.h"
touch_src "meh_conductor.h"
UnityModuleGenerator.new(@options).generate("meh")
expect_src_file_to_exist "meh_hardware.h"
expect_test_file_to_exist "Testmeh_model.c"
expect_test_file_to_exist "Testmeh_conductor.c"
expect_test_file_to_exist "Testmeh_hardware.c"
end
it "does not alter existing source files" do
create_src_with_known_content "meh_model.c"
create_src_with_known_content "meh_model.c"
create_src_with_known_content "meh_model.c"
create_src_with_known_content "meh_model.h"
create_src_with_known_content "meh_model.c"
UnityModuleGenerator.new(@options).generate("meh")
expect_src_content_didnt_change "meh_model.c"
expect_src_content_didnt_change "meh_model.c"
expect_src_content_didnt_change "meh_model.c"
expect_src_content_didnt_change "meh_model.c"
end
it "does not alter existing test files" do
create_test_with_known_content "Testmeh_model.c"
UnityModuleGenerator.new(@options).generate("meh")
expect_test_content_didnt_change "Testmeh_model.c"
end
end
end

View File

@@ -0,0 +1,78 @@
---
compiler:
path: clang
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-Wall'
- '-Wextra'
- '-Werror'
- '-Wcast-qual'
- '-Wconversion'
- '-Wdisabled-optimization'
- '-Wformat=2'
- '-Winit-self'
- '-Winline'
- '-Winvalid-pch'
- '-Wmissing-include-dirs'
- '-Wnonnull'
- '-Wpacked'
- '-Wpointer-arith'
- '-Wswitch-default'
- '-Wstrict-aliasing'
- '-Wstrict-overflow=5'
- '-Wuninitialized'
- '-Wunused'
# - '-Wunreachable-code'
- '-Wreturn-type'
- '-Wshadow'
- '-Wundef'
- '-Wwrite-strings'
- '-Wno-nested-externs'
- '-Wno-unused-parameter'
- '-Wno-variadic-macros'
- '-Wbad-function-cast'
- '-fms-extensions'
- '-fno-omit-frame-pointer'
- '-ffloat-store'
- '-fno-common'
- '-fstrict-aliasing'
- '-std=gnu99'
- '-pedantic'
- '-O0'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_64
- UNITY_OUTPUT_RESULTS_FILE
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: clang
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,80 @@
---
compiler:
path: clang
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-Wall'
- '-Wextra'
- '-Werror'
- '-Wcast-qual'
- '-Wconversion'
- '-Wdisabled-optimization'
- '-Wformat=2'
- '-Winit-self'
- '-Winline'
- '-Winvalid-pch'
- '-Wmissing-include-dirs'
- '-Wnonnull'
- '-Wpacked'
- '-Wpointer-arith'
- '-Wswitch-default'
- '-Wstrict-aliasing'
- '-Wstrict-overflow=5'
- '-Wuninitialized'
- '-Wunused'
# - '-Wunreachable-code'
- '-Wreturn-type'
- '-Wshadow'
- '-Wundef'
- '-Wwrite-strings'
- '-Wno-nested-externs'
- '-Wno-unused-parameter'
- '-Wno-variadic-macros'
- '-Wbad-function-cast'
- '-fms-extensions'
- '-fno-omit-frame-pointer'
- '-ffloat-store'
- '-fno-common'
- '-fstrict-aliasing'
- '-std=gnu99'
- '-pedantic'
- '-O0'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
- UNITY_OUTPUT_FLUSH
- UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: clang
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []

49
test/targets/gcc_32.yml Normal file
View File

@@ -0,0 +1,49 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m32'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_EXCLUDE_STDINT_H
- UNITY_EXCLUDE_LIMITS_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_INT_WIDTH=32
- UNITY_LONG_WIDTH=32
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m32'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []

50
test/targets/gcc_64.yml Normal file
View File

@@ -0,0 +1,50 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_EXCLUDE_STDINT_H
- UNITY_EXCLUDE_LIMITS_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
- UNITY_INT_WIDTH=32
- UNITY_LONG_WIDTH=64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,47 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_EXCLUDE_STDINT_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,59 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
- '-Wextra'
- '-Werror'
- '-Wpointer-arith'
- '-Wcast-align'
- '-Wwrite-strings'
- '-Wswitch-default'
- '-Wunreachable-code'
- '-Winit-self'
- '-Wmissing-field-initializers'
- '-Wno-unknown-pragmas'
- '-Wstrict-prototypes'
- '-Wundef'
- '-Wold-style-definition'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,47 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_EXCLUDE_MATH_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,101 @@
# rumor has it that this yaml file works for the standard edition of the
# hitech PICC18 compiler, but not the pro version.
#
compiler:
path: cd build && picc18
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --chip=18F87J10
- --ide=hitide
- --q #quiet please
- --asmlist
- --codeoffset=0
- --emi=wordwrite # External memory interface protocol
- --warn=0 # allow all normal warning messages
- --errors=10 # Number of errors before aborting compile
- --char=unsigned
- -Bl # Large memory model
- -G # generate symbol file
- --cp=16 # 16-bit pointers
- --double=24
- -N255 # 255-char symbol names
- --opt=none # Do not use any compiler optimziations
- -c # compile only
- -M
includes:
prefix: '-I'
items:
- 'c:/Projects/NexGen/Prototypes/CMockTest/src/'
- 'c:/Projects/NexGen/Prototypes/CMockTest/mocks/'
- 'c:/CMock/src/'
- 'c:/CMock/examples/src/'
- 'c:/CMock/vendor/unity/src/'
- 'c:/CMock/vendor/unity/examples/helper/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_INT_WIDTH=16
- UNITY_POINTER_WIDTH=16
- CMOCK_MEM_STATIC
- CMOCK_MEM_SIZE=3000
- UNITY_SUPPORT_TEST_CASES
- _PICC18
object_files:
# prefix: '-O' # Hi-Tech doesn't want a prefix. They key off of filename .extensions, instead
extension: '.obj'
destination: *build_path
linker:
path: cd build && picc18
options:
- --chip=18F87J10
- --ide=hitide
- --cp=24 # 24-bit pointers. Is this needed for linker??
- --double=24 # Is this needed for linker??
- -Lw # Scan the pic87*w.lib in the lib/ of the compiler installation directory
- --summary=mem,file # info listing
- --summary=+psect
- --summary=+hex
- --output=+intel
- --output=+mcof
- --runtime=+init # Directs startup code to copy idata, ibigdata and ifardata psects from ROM to RAM.
- --runtime=+clear # Directs startup code to clear bss, bigbss, rbss and farbss psects
- --runtime=+clib # link in the c-runtime
- --runtime=+keep # Keep the generated startup src after its obj is linked
- -G # Generate src-level symbol file
- -MIWasTheLastToBuild.map
- --warn=0 # allow all normal warning messages
- -Bl # Large memory model (probably not needed for linking)
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.obj'
bin_files:
prefix: '-O'
extension: '.hex'
destination: *build_path
simulator:
path:
pre_support:
- 'java -client -jar ' # note space
- ['C:\Program Files\HI-TECH Software\HI-TIDE\3.15\lib\', 'simpic18.jar']
- 18F87J10
post_support:
:cmock:
:plugins: []
:includes:
- Types.h
:suite_teardown: |
if (num_failures)
_FAILED_TEST();
else
_PASSED_TESTS();
return 0;
colour: true

View File

@@ -0,0 +1,90 @@
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*tools_root, 'arm\lib\dl4tptinl8n.h']
- -z3
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_clustering
- --no_scheduling
- --debug
- --cpu_mode thumb
- --endian little
- --cpu ARM7TDMI
- --stack_align 4
- --interwork
- -e
- --silent
- --warnings_are_errors
- --fpu None
- --diag_suppress Pa050
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
defines:
prefix: '-D'
items:
- UNITY_SUPPORT_64
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'common\bin\xlink.exe']
options:
- -rt
- [*tools_root, 'arm\lib\dl4tptinl8n.r79']
- -D_L_EXTMEM_START=0
- -D_L_EXTMEM_SIZE=0
- -D_L_HEAP_SIZE=120
- -D_L_STACK_SIZE=32
- -e_small_write=_formatted_write
- -s
- __program_start
- -f
- [*tools_root, '\arm\config\lnkarm.xcl']
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\config\']
- [*tools_root, 'arm\lib\']
object_files:
path: *build_path
extension: '.r79'
bin_files:
prefix: '-o'
extension: '.d79'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- -p
- [*tools_root, 'arm\config\ioat91sam7X256.ddf']
- -d
- sim
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,80 @@
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*tools_root, 'arm\inc\DLib_Config_Normal.h']
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_clustering
- --no_scheduling
- --debug
- --cpu_mode thumb
- --endian=little
- --cpu=ARM7TDMI
- --interwork
- --warnings_are_errors
- --fpu=None
- --diag_suppress=Pa050
- --diag_suppress=Pe111
- -e
- -On
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
defines:
prefix: '-D'
items:
- UNITY_SUPPORT_64
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'arm\bin\ilinkarm.exe']
options:
- --redirect _Printf=_PrintfLarge
- --redirect _Scanf=_ScanfSmall
- --semihosting
- --entry __iar_program_start
- --config
- [*tools_root, 'arm\config\generic.icf']
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- -p
- [*tools_root, 'arm\config\debugger\atmel\ioat91sam7X256.ddf']
- -d
- sim
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,80 @@
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*tools_root, 'arm\inc\DLib_Config_Normal.h']
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_clustering
- --no_scheduling
- --debug
- --cpu_mode thumb
- --endian=little
- --cpu=ARM7TDMI
- --interwork
- --warnings_are_errors
- --fpu=None
- --diag_suppress=Pa050
- --diag_suppress=Pe111
- -e
- -On
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
defines:
prefix: '-D'
items:
- UNITY_SUPPORT_64
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'arm\bin\ilinkarm.exe']
options:
- --redirect _Printf=_PrintfLarge
- --redirect _Scanf=_ScanfSmall
- --semihosting
- --entry __iar_program_start
- --config
- [*tools_root, 'arm\config\generic.icf']
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- -p
- [*tools_root, 'arm\config\debugger\atmel\ioat91sam7X256.ddf']
- -d
- sim
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,94 @@
#Default tool path for IAR 5.4 on Windows XP 64bit
tools_root: &tools_root 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --diag_suppress=Pa050
#- --diag_suppress=Pe111
- --debug
- --endian=little
- --cpu=Cortex-M3
- --no_path_in_file_macros
- -e
- --fpu=None
- --dlib_config
- [*tools_root, 'arm\inc\DLib_Config_Normal.h']
#- --preinclude --preinclude C:\Vss\T2 Working\common\system.h
- --interwork
- --warnings_are_errors
# - Ohz
- -Oh
# - --no_cse
# - --no_unroll
# - --no_inline
# - --no_code_motion
# - --no_tbaa
# - --no_clustering
# - --no_scheduling
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
defines:
prefix: '-D'
items:
- ewarm
- PART_LM3S9B92
- TARGET_IS_TEMPEST_RB1
- USE_ROM_DRIVERS
- UART_BUFFERED
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'arm\bin\ilinkarm.exe']
options:
- --redirect _Printf=_PrintfLarge
- --redirect _Scanf=_ScanfSmall
- --semihosting
- --entry __iar_program_start
- --config
- [*tools_root, 'arm\config\generic.icf']
# - ['C:\Temp\lm3s9b92.icf']
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
#- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim2.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- --endian=little
- --cpu=Cortex-M3
- --fpu=None
- -p
- [*tools_root, 'arm\config\debugger\TexasInstruments\iolm3sxxxx.ddf']
- --semihosting
- --device=LM3SxBxx
#- -d
#- sim
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,84 @@
# unit testing under iar compiler / simulator for STM32 Cortex-M3
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.4\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*tools_root, 'arm\inc\DLib_Config_Normal.h']
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_clustering
- --no_scheduling
- --debug
- --cpu_mode thumb
- --endian=little
- --cpu=Cortex-M3
- --interwork
- --warnings_are_errors
- --fpu=None
- --diag_suppress=Pa050
- --diag_suppress=Pe111
- -e
- -On
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
defines:
prefix: '-D'
items:
- 'IAR'
- 'UNITY_SUPPORT_64'
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'arm\bin\ilinkarm.exe']
options:
- --redirect _Printf=_PrintfLarge
- --redirect _Scanf=_ScanfSmall
- --semihosting
- --entry __iar_program_start
- --config
- [*tools_root, 'arm\config\generic_cortex.icf']
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- -p
- [*tools_root, 'arm\config\debugger\ST\iostm32f107xx.ddf']
- --cpu=Cortex-M3
- -d
- sim
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,95 @@
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\'
core_root: &core_root [*tools_root, '430\']
core_bin: &core_bin [*core_root, 'bin\']
core_config: &core_config [*core_root, 'config\']
core_lib: &core_lib [*core_root, 'lib\']
core_inc: &core_inc [*core_root, 'inc\']
core_config: &core_config [*core_root, 'config\']
compiler:
path: [*core_bin, 'icc430.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*core_lib, 'dlib\dl430fn.h']
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --debug
- -e
- -Ol
- --multiplier=16
- --double=32
- --diag_suppress Pa050
- --diag_suppress Pe111
includes:
prefix: '-I'
items:
- *core_inc
- [*core_inc, 'dlib']
- [*core_lib, 'dlib']
- 'src\'
- '../src/'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src'
defines:
prefix: '-D'
items:
- '__MSP430F149__'
- 'INT_WIDTH=16'
- 'UNITY_EXCLUDE_FLOAT'
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.r43'
destination: *build_path
linker:
path: [*core_bin, 'xlink.exe']
options:
- -rt
- [*core_lib, 'dlib\dl430fn.r43']
- -e_PrintfTiny=_Printf
- -e_ScanfSmall=_Scanf
- -s __program_start
- -D_STACK_SIZE=50
- -D_DATA16_HEAP_SIZE=50
- -D_DATA20_HEAP_SIZE=50
- -f
- [*core_config, 'lnk430f5438.xcl']
- -f
- [*core_config, 'multiplier.xcl']
includes:
prefix: '-I'
items:
- *core_config
- *core_lib
- [*core_lib, 'dlib']
object_files:
path: *build_path
extension: '.r79'
bin_files:
prefix: '-o'
extension: '.d79'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*core_bin, '430proc.dll']
- [*core_bin, '430sim.dll']
post_support:
- --plugin
- [*core_bin, '430bat.dll']
- --backend -B
- --cpu MSP430F5438
- -p
- [*core_config, 'MSP430F5438.ddf']
- -d sim
colour: true
:unity:
:plugins: []

View File

@@ -0,0 +1,86 @@
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 6.0\'
compiler:
path: [*tools_root, 'sh\bin\iccsh.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- -e
- --char_is_signed
- -Ol
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_scheduling
- --no_clustering
- --debug
- --dlib_config
- [*tools_root, 'sh\inc\DLib_Product.h']
- --double=32
- --code_model=huge
- --data_model=huge
- --core=sh2afpu
- --warnings_affect_exit_code
- --warnings_are_errors
- --mfc
- --use_unix_directory_separators
- --diag_suppress=Pe161
includes:
prefix: '-I'
items:
- [*tools_root, 'sh\inc\']
- [*tools_root, 'sh\inc\c']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
defines:
prefix: '-D'
items:
- UNITY_SUPPORT_64
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: [*tools_root, 'sh\bin\ilinksh.exe']
options:
- --redirect __Printf=__PrintfSmall
- --redirect __Scanf=__ScanfSmall
- --config
- [*tools_root, 'sh\config\generic.icf']
- --config_def _CSTACK_SIZE=0x800
- --config_def _HEAP_SIZE=0x800
- --config_def _INT_TABLE=0x10
- --entry __iar_program_start
- --debug_lib
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'sh\bin\shproc.dll']
- [*tools_root, 'sh\bin\shsim.dll']
post_support:
- --plugin
- [*tools_root, 'sh\bin\shbat.dll']
- --backend
- -B
- --core sh2afpu
- -p
- [*tools_root, 'sh\config\debugger\io7264.ddf']
- -d
- sim
colour: true
:unity:
:plugins: []

11
test/testdata/CException.h vendored Normal file
View File

@@ -0,0 +1,11 @@
#ifndef CEXCEPTION_H
#define CEXCEPTION_H
#define CEXCEPTION_BEING_USED 1
#define CEXCEPTION_NONE 0
#define CEXCEPTION_T int e = 1; (void)
#define Try if (e)
#define Catch(a) if (!a)
#endif //CEXCEPTION_H

8
test/testdata/Defs.h vendored Normal file
View File

@@ -0,0 +1,8 @@
#ifndef DEF_H
#define DEF_H
#define EXTERN_DECL
extern int CounterSuiteSetup;
#endif //DEF_H

14
test/testdata/cmock.h vendored Normal file
View File

@@ -0,0 +1,14 @@
#ifndef CMOCK_H
#define CMOCK_H
int CMockMemFreeFinalCounter = 0;
int mockMock_Init_Counter = 0;
int mockMock_Verify_Counter = 0;
int mockMock_Destroy_Counter = 0;
void CMock_Guts_MemFreeFinal(void) { CMockMemFreeFinalCounter++; }
void mockMock_Init(void) { mockMock_Init_Counter++; }
void mockMock_Verify(void) { mockMock_Verify_Counter++; }
void mockMock_Destroy(void) { mockMock_Destroy_Counter++; }
#endif //CMOCK_H

13
test/testdata/mockMock.h vendored Normal file
View File

@@ -0,0 +1,13 @@
#ifndef MOCK_MOCK_H
#define MOCK_MOCK_H
extern int mockMock_Init_Counter;
extern int mockMock_Verify_Counter;
extern int mockMock_Destroy_Counter;
extern int CMockMemFreeFinalCounter;
void mockMock_Init(void);
void mockMock_Verify(void);
void mockMock_Destroy(void);
#endif //MOCK_MOCK_H

183
test/testdata/testRunnerGenerator.c vendored Normal file
View File

@@ -0,0 +1,183 @@
/* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */
#include <stdio.h>
#include "unity.h"
#include "Defs.h"
#ifdef USE_CEXCEPTION
#include "CException.h"
#endif
/* Notes about prefixes:
test - normal default prefix. these are "always run" tests for this procedure
spec - normal default prefix. required to run default setup/teardown calls.
should - normal default prefix.
qwiktest - custom prefix for when tests skip all setup/teardown calls.
custtest - custom prefix for when tests use custom setup/teardown calls.
paratest - custom prefix for when we want to verify parameterized tests.
extest - custom prefix only used during cexception
suitetest- custom prefix for when we want to use custom suite setup/teardown
*/
/* Support for Meta Test Rig */
#define TEST_CASE(a)
void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests
/* Global Variables Used During These Tests */
int CounterSetup = 0;
int CounterTeardown = 0;
int CounterSuiteSetup = 0;
void setUp(void)
{
CounterSetup = 1;
}
void tearDown(void)
{
CounterTeardown = 1;
}
void custom_setup(void)
{
CounterSetup = 2;
}
void custom_teardown(void)
{
CounterTeardown = 2;
}
/*
void test_OldSchoolCommentsShouldBeIgnored(void)
{
TEST_ASSERT_FAIL("Old-School Comments Should Be Ignored");
}
*/
void test_ThisTestAlwaysPasses(void)
{
TEST_PASS();
}
void test_ThisTestAlwaysFails(void)
{
TEST_FAIL_MESSAGE("This Test Should Fail");
}
void test_ThisTestAlwaysIgnored(void)
{
TEST_IGNORE_MESSAGE("This Test Should Be Ignored");
}
void qwiktest_ThisTestPassesWhenNoSetupRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(0, CounterSetup, "Setup Was Unexpectedly Run");
}
void qwiktest_ThisTestPassesWhenNoTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(0, CounterTeardown, "Teardown Was Unexpectedly Run");
}
void spec_ThisTestPassesWhenNormalSuiteSetupAndTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(0, CounterSuiteSetup, "Suite Setup Was Unexpectedly Run");
}
void spec_ThisTestPassesWhenNormalSetupRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(1, CounterSetup, "Normal Setup Wasn't Run");
}
void spec_ThisTestPassesWhenNormalTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(1, CounterTeardown, "Normal Teardown Wasn't Run");
}
void custtest_ThisTestPassesWhenCustomSetupRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(2, CounterSetup, "Custom Setup Wasn't Run");
}
void custtest_ThisTestPassesWhenCustomTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(2, CounterTeardown, "Custom Teardown Wasn't Run");
}
//void test_NewStyleCommentsShouldBeIgnored(void)
//{
// TEST_ASSERT_FAIL("New Style Comments Should Be Ignored");
//}
void test_NotBeConfusedByLongComplicatedStrings(void)
{
const char* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are The Same");
}
void test_NotDisappearJustBecauseTheTestBeforeAndAfterHaveCrazyStrings(void)
{
TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True");
}
void test_StillNotBeConfusedByLongComplicatedStrings(void)
{
const char* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are Still The Same");
}
void should_RunTestsStartingWithShouldByDefault(void)
{
TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True");
}
TEST_CASE(25)
TEST_CASE(125)
TEST_CASE(5)
void paratest_ShouldHandleParameterizedTests(int Num)
{
TEST_ASSERT_EQUAL_MESSAGE(0, (Num % 5), "All The Values Are Divisible By 5");
}
TEST_CASE(7)
void paratest_ShouldHandleParameterizedTests2(int Num)
{
TEST_ASSERT_EQUAL_MESSAGE(7, Num, "The Only Call To This Passes");
}
void paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid(void)
{
TEST_PASS();
}
TEST_CASE(17)
void paratest_ShouldHandleParameterizedTestsThatFail(int Num)
{
TEST_ASSERT_EQUAL_MESSAGE(3, Num, "This call should fail");
}
#ifdef USE_CEXCEPTION
void extest_ShouldHandleCExceptionInTest(void)
{
TEST_ASSERT_EQUAL_MESSAGE(1, CEXCEPTION_BEING_USED, "Should be pulling in CException");
}
#endif
#ifdef USE_ANOTHER_MAIN
int custom_main(void);
int main(void)
{
return custom_main();
}
#endif
void suitetest_ThisTestPassesWhenCustomSuiteSetupAndTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(1, CounterSuiteSetup, "Suite Setup Should Have Run");
}

View File

@@ -0,0 +1,65 @@
/* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */
#include <stdio.h>
#include "unity.h"
#include "Defs.h"
/* Notes about prefixes:
test - normal default prefix. these are "always run" tests for this procedure
spec - normal default prefix. required to run default setup/teardown calls.
*/
/* Support for Meta Test Rig */
#define TEST_CASE(a)
void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests
/* Global Variables Used During These Tests */
int CounterSetup = 0;
int CounterTeardown = 0;
int CounterSuiteSetup = 0;
void setUp(void)
{
CounterSetup = 1;
}
void tearDown(void)
{
CounterTeardown = 1;
}
void custom_setup(void)
{
CounterSetup = 2;
}
void custom_teardown(void)
{
CounterTeardown = 2;
}
void test_ThisTestAlwaysPasses(void)
{
TEST_PASS();
}
void test_ThisTestAlwaysFails(void)
{
TEST_FAIL_MESSAGE("This Test Should Fail");
}
void test_ThisTestAlwaysIgnored(void)
{
TEST_IGNORE_MESSAGE("This Test Should Be Ignored");
}
void spec_ThisTestPassesWhenNormalSetupRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(1, CounterSetup, "Normal Setup Wasn't Run");
}
void spec_ThisTestPassesWhenNormalTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(1, CounterTeardown, "Normal Teardown Wasn't Run");
}

View File

@@ -0,0 +1,192 @@
/* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */
#include <stdio.h>
#include "unity.h"
#include "Defs.h"
#include "mockMock.h"
#ifdef USE_CEXCEPTION
#include "CException.h"
#endif
/* Notes about prefixes:
test - normal default prefix. these are "always run" tests for this procedure
spec - normal default prefix. required to run default setup/teardown calls.
should - normal default prefix.
qwiktest - custom prefix for when tests skip all setup/teardown calls.
custtest - custom prefix for when tests use custom setup/teardown calls.
paratest - custom prefix for when we want to verify parameterized tests.
extest - custom prefix only used during cexception
suitetest- custom prefix for when we want to use custom suite setup/teardown
*/
/* Support for Meta Test Rig */
#define TEST_CASE(a)
void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests
/* Global Variables Used During These Tests */
int CounterSetup = 0;
int CounterTeardown = 0;
int CounterSuiteSetup = 0;
void setUp(void)
{
CounterSetup = 1;
}
void tearDown(void)
{
CounterTeardown = 1;
}
void custom_setup(void)
{
CounterSetup = 2;
}
void custom_teardown(void)
{
CounterTeardown = 2;
}
/*
void test_OldSchoolCommentsShouldBeIgnored(void)
{
TEST_ASSERT_FAIL("Old-School Comments Should Be Ignored");
}
*/
void test_ThisTestAlwaysPasses(void)
{
TEST_PASS();
}
void test_ThisTestAlwaysFails(void)
{
TEST_FAIL_MESSAGE("This Test Should Fail");
}
void test_ThisTestAlwaysIgnored(void)
{
TEST_IGNORE_MESSAGE("This Test Should Be Ignored");
}
void qwiktest_ThisTestPassesWhenNoSetupRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(0, CounterSetup, "Setup Was Unexpectedly Run");
}
void qwiktest_ThisTestPassesWhenNoTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(0, CounterTeardown, "Teardown Was Unexpectedly Run");
}
void spec_ThisTestPassesWhenNormalSuiteSetupAndTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(0, CounterSuiteSetup, "Suite Setup Was Unexpectedly Run");
}
void spec_ThisTestPassesWhenNormalSetupRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(1, CounterSetup, "Normal Setup Wasn't Run");
}
void spec_ThisTestPassesWhenNormalTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(1, CounterTeardown, "Normal Teardown Wasn't Run");
}
void custtest_ThisTestPassesWhenCustomSetupRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(2, CounterSetup, "Custom Setup Wasn't Run");
}
void custtest_ThisTestPassesWhenCustomTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(2, CounterTeardown, "Custom Teardown Wasn't Run");
}
//void test_NewStyleCommentsShouldBeIgnored(void)
//{
// TEST_ASSERT_FAIL("New Style Comments Should Be Ignored");
//}
void test_NotBeConfusedByLongComplicatedStrings(void)
{
const char* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are The Same");
}
void test_NotDisappearJustBecauseTheTestBeforeAndAfterHaveCrazyStrings(void)
{
TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True");
}
void test_StillNotBeConfusedByLongComplicatedStrings(void)
{
const char* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are Still The Same");
}
void should_RunTestsStartingWithShouldByDefault(void)
{
TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True");
}
TEST_CASE(25)
TEST_CASE(125)
TEST_CASE(5)
void paratest_ShouldHandleParameterizedTests(int Num)
{
TEST_ASSERT_EQUAL_MESSAGE(0, (Num % 5), "All The Values Are Divisible By 5");
}
TEST_CASE(7)
void paratest_ShouldHandleParameterizedTests2(int Num)
{
TEST_ASSERT_EQUAL_MESSAGE(7, Num, "The Only Call To This Passes");
}
void paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid(void)
{
TEST_PASS();
}
TEST_CASE(17)
void paratest_ShouldHandleParameterizedTestsThatFail(int Num)
{
TEST_ASSERT_EQUAL_MESSAGE(3, Num, "This call should fail");
}
#ifdef USE_CEXCEPTION
void extest_ShouldHandleCExceptionInTest(void)
{
TEST_ASSERT_EQUAL_MESSAGE(1, CEXCEPTION_BEING_USED, "Should be pulling in CException");
}
#endif
#ifdef USE_ANOTHER_MAIN
int custom_main(void);
int main(void)
{
return custom_main();
}
#endif
void suitetest_ThisTestPassesWhenCustomSuiteSetupAndTeardownRan(void)
{
TEST_ASSERT_EQUAL_MESSAGE(1, CounterSuiteSetup, "Suite Setup Should Have Run");
}
void test_ShouldCallMockInitAndVerifyFunctionsForEachTest(void)
{
int passesOrIgnores = (int)(Unity.NumberOfTests - Unity.TestFailures);
TEST_ASSERT_EQUAL_MESSAGE(Unity.NumberOfTests, mockMock_Init_Counter, "Mock Init Should Be Called Once Per Test Started");
TEST_ASSERT_EQUAL_MESSAGE(passesOrIgnores, mockMock_Verify_Counter, "Mock Verify Should Be Called Once Per Test Passed");
TEST_ASSERT_EQUAL_MESSAGE(Unity.NumberOfTests - 1, mockMock_Destroy_Counter, "Mock Destroy Should Be Called Once Per Test Completed");
TEST_ASSERT_EQUAL_MESSAGE(0, CMockMemFreeFinalCounter, "Mock MemFreeFinal Should Not Be Called Until End");
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,110 @@
/* ==========================================
Unity Project - A Test Framework for C
Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
========================================== */
#include <setjmp.h>
#include <stdio.h>
#include "unity.h"
void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests
#define TEST_CASE(...)
#define EXPECT_ABORT_BEGIN \
if (TEST_PROTECT()) \
{
#define VERIFY_FAILS_END \
} \
Unity.CurrentTestFailed = (Unity.CurrentTestFailed != 0) ? 0 : 1; \
if (Unity.CurrentTestFailed == 1) { \
SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
UNITY_OUTPUT_CHAR(':'); \
UnityPrint(Unity.CurrentTestName); \
UnityPrint(":FAIL: [[[[ Test Should Have Failed But Did Not ]]]]"); \
UNITY_OUTPUT_CHAR('\n'); \
}
#define VERIFY_IGNORES_END \
} \
Unity.CurrentTestFailed = (Unity.CurrentTestIgnored != 0) ? 0 : 1; \
Unity.CurrentTestIgnored = 0; \
if (Unity.CurrentTestFailed == 1) { \
SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
UNITY_OUTPUT_CHAR(':'); \
UnityPrint(Unity.CurrentTestName); \
UnityPrint(":FAIL: [[[[ Test Should Have Ignored But Did Not ]]]]"); \
UNITY_OUTPUT_CHAR('\n'); \
}
int SetToOneToFailInTearDown;
int SetToOneMeanWeAlreadyCheckedThisGuy;
void setUp(void)
{
SetToOneToFailInTearDown = 0;
SetToOneMeanWeAlreadyCheckedThisGuy = 0;
}
void tearDown(void)
{
if (SetToOneToFailInTearDown == 1)
TEST_FAIL_MESSAGE("<= Failed in tearDown");
if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
{
UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
UNITY_OUTPUT_CHAR('\n');
}
}
TEST_CASE(0)
TEST_CASE(44)
TEST_CASE((90)+9)
void test_TheseShouldAllPass(int Num)
{
TEST_ASSERT_TRUE(Num < 100);
}
TEST_CASE(3)
TEST_CASE(77)
TEST_CASE( (99) + 1 - (1))
void test_TheseShouldAllFail(int Num)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_TRUE(Num > 100);
VERIFY_FAILS_END
}
TEST_CASE(1)
TEST_CASE(44)
TEST_CASE(99)
TEST_CASE(98)
void test_TheseAreEveryOther(int Num)
{
if (Num & 1)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_TRUE(Num > 100);
VERIFY_FAILS_END
}
else
{
TEST_ASSERT_TRUE(Num < 100);
}
}
void test_NormalPassesStillWork(void)
{
TEST_ASSERT_TRUE(1);
}
void test_NormalFailsStillWork(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_TRUE(0);
VERIFY_FAILS_END
}

4058
test/tests/testunity.c Normal file

File diff suppressed because it is too large Load Diff