Skip to content

Commit bf398fc

Browse files
committed
Added CMSIS pack description file (pdsc).
1 parent 0547aab commit bf398fc

File tree

6 files changed

+404
-0
lines changed

6 files changed

+404
-0
lines changed

ThrowTheSwitch.Unity.pdsc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<package schemaVersion="1.3" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="PACK.xsd">
4+
<name>Unity</name>
5+
<description>Unity, Unit Testing for C</description>
6+
<vendor>ThrowTheSwitch</vendor>
7+
<!-- <license>license.txt</license> -->
8+
<url>https://github.com/JonatanAntoni/Unity/archive/</url>
9+
10+
<releases>
11+
<release version="1.0.0-dev1">
12+
Initial version
13+
Based on Unity release 2.4.1
14+
</release>
15+
</releases>
16+
17+
<conditions>
18+
<condition id="Unity Framework">
19+
<description>Unity Framework</description>
20+
<require Cclass="Unity" Cgroup="Framework"/>
21+
</condition>
22+
</conditions>
23+
24+
<components>
25+
<component Cclass="Unity" Cgroup="Framework" Cversion="2.4.1">
26+
<description>Unity Test API</description>
27+
<files>
28+
<file category="include" name="src/"/>
29+
<file category="sourceC" name="src/unity.c"/>
30+
<file category="sourceC" attr="template" name="template/main.c" version="1.0.0" select="Unity Framework 'main' function."/>
31+
<file category="sourceC" attr="template" name="template/test.c" version="1.0.0" select="Unity Framework test."/>
32+
</files>
33+
</component>
34+
35+
<component Cclass="Unity" Cgroup="Fixture" Cversion="2.4.1" condition="Unity Framework">
36+
<description>Unity Test Fixture</description>
37+
<files>
38+
<file category="include" name="extras/fixture/src"/>
39+
<file category="sourceC" name="extras/fixture/src/unity_fixture.c"/>
40+
<file category="sourceC" attr="template" name="extras/fixture/template/main.c" version="1.0.0" select="Unity Fixture 'main' function."/>
41+
<file category="sourceC" attr="template" name="extras/fixture/template/fixture.c" version="1.0.0" select="Unity Fixture test fixture group."/>
42+
</files>
43+
</component>
44+
</components>
45+
46+
</package>

extras/fixture/template/fixture.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
#include "unity_fixture.h"
3+
4+
TEST_GROUP(group);
5+
6+
TEST_SETUP(group)
7+
{
8+
}
9+
10+
TEST_TEAR_DOWN(group)
11+
{
12+
}
13+
14+
TEST(group, test)
15+
{
16+
/* do assertions here */
17+
}
18+
19+
TEST_GROUP_RUNNER(group)
20+
{
21+
RUN_TEST_CASE(group, test);
22+
}

extras/fixture/template/main.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
#include "RTE_Components.h"
3+
#include CMSIS_device_header
4+
5+
#ifdef RTE_Compiler_EventRecorder
6+
#include "EventRecorder.h"
7+
#endif
8+
9+
#include "unity_fixture.h"
10+
11+
static void runAllTests(void)
12+
{
13+
RUN_TEST_GROUP(group);
14+
}
15+
16+
/*=======MAIN=====*/
17+
int main(void)
18+
{
19+
// System Initialization
20+
SystemCoreClockUpdate();
21+
22+
#ifdef RTE_Compiler_EventRecorder
23+
// Initialize and start Event Recorder
24+
(void)EventRecorderInitialize(EventRecordError, 1U);
25+
(void)EventRecorderEnable (EventRecordAll, 0xFEU, 0xFEU);
26+
#endif
27+
28+
UnityMain(0U, NULL, runAllTests);
29+
30+
for(;;);
31+
}

template/main.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
#include "RTE_Components.h"
3+
#include CMSIS_device_header
4+
5+
#ifdef RTE_Compiler_EventRecorder
6+
#include "EventRecorder.h"
7+
#endif
8+
9+
#include "unity.h"
10+
11+
#define RUN_TEST(TestFunc, TestLineNum) \
12+
{ \
13+
Unity.CurrentTestName = #TestFunc; \
14+
Unity.CurrentTestLineNumber = TestLineNum; \
15+
Unity.NumberOfTests++; \
16+
if (TEST_PROTECT()) \
17+
{ \
18+
setUp(); \
19+
TestFunc(); \
20+
} \
21+
if (TEST_PROTECT()) \
22+
{ \
23+
tearDown(); \
24+
} \
25+
UnityConcludeTest(); \
26+
}
27+
28+
/*=======External Functions This Runner Calls=====*/
29+
extern void setUp(void);
30+
extern void tearDown(void);
31+
32+
33+
/*=======MAIN=====*/
34+
int main(void)
35+
{
36+
// System Initialization
37+
SystemCoreClockUpdate();
38+
39+
#ifdef RTE_Compiler_EventRecorder
40+
// Initialize and start Event Recorder
41+
(void)EventRecorderInitialize(EventRecordError, 1U);
42+
(void)EventRecorderEnable (EventRecordAll, 0xFEU, 0xFEU);
43+
#endif
44+
45+
UnityBegin("");
46+
47+
// RUN_TEST(test, 20);
48+
49+
(void)UnityEnd();
50+
51+
for(;;);
52+
}

template/test.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
#include "unity.h"
3+
4+
void setUp(void)
5+
{
6+
}
7+
8+
void tearDown(void)
9+
{
10+
}
11+
12+
void test(void)
13+
{
14+
}

0 commit comments

Comments
 (0)