Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
d7004788
T
Third Party Unity
项目概览
OpenHarmony
/
Third Party Unity
大约 1 年 前同步成功
通知
34
Star
144
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Unity
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d7004788
编写于
5月 04, 2019
作者:
M
Mark VanderVoord
提交者:
GitHub
5月 04, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #377 from elliot-gawthrop/execution-time-embedded
Execution time improvements
上级
2697770a
076f0fff
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
59 addition
and
41 deletion
+59
-41
auto/generate_test_runner.rb
auto/generate_test_runner.rb
+2
-0
src/unity.c
src/unity.c
+3
-2
src/unity_internals.h
src/unity_internals.h
+52
-37
test/tests/testunity.c
test/tests/testunity.c
+2
-2
未找到文件。
auto/generate_test_runner.rb
浏览文件 @
d7004788
...
@@ -300,6 +300,7 @@ class UnityTestRunnerGenerator
...
@@ -300,6 +300,7 @@ class UnityTestRunnerGenerator
output
.
puts
(
' Unity.CurrentTestLineNumber = TestLineNum; \\'
)
output
.
puts
(
' Unity.CurrentTestLineNumber = TestLineNum; \\'
)
output
.
puts
(
' if (UnityTestMatches()) { \\'
)
if
@options
[
:cmdline_args
]
output
.
puts
(
' if (UnityTestMatches()) { \\'
)
if
@options
[
:cmdline_args
]
output
.
puts
(
' Unity.NumberOfTests++; \\'
)
output
.
puts
(
' Unity.NumberOfTests++; \\'
)
output
.
puts
(
' UNITY_EXEC_TIME_START(); \\'
)
output
.
puts
(
' CMock_Init(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Init(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' UNITY_CLR_DETAILS(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' UNITY_CLR_DETAILS(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' if (TEST_PROTECT()) \\'
)
output
.
puts
(
' if (TEST_PROTECT()) \\'
)
...
@@ -316,6 +317,7 @@ class UnityTestRunnerGenerator
...
@@ -316,6 +317,7 @@ class UnityTestRunnerGenerator
output
.
puts
(
' CMock_Verify(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Verify(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' } \\'
)
output
.
puts
(
' } \\'
)
output
.
puts
(
' CMock_Destroy(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Destroy(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' UNITY_EXEC_TIME_STOP(); \\'
)
output
.
puts
(
' UnityConcludeTest(); \\'
)
output
.
puts
(
' UnityConcludeTest(); \\'
)
output
.
puts
(
' } \\'
)
if
@options
[
:cmdline_args
]
output
.
puts
(
' } \\'
)
if
@options
[
:cmdline_args
]
output
.
puts
(
"}
\n
"
)
output
.
puts
(
"}
\n
"
)
...
...
src/unity.c
浏览文件 @
d7004788
...
@@ -599,7 +599,7 @@ void UnityConcludeTest(void)
...
@@ -599,7 +599,7 @@ void UnityConcludeTest(void)
Unity
.
CurrentTestFailed
=
0
;
Unity
.
CurrentTestFailed
=
0
;
Unity
.
CurrentTestIgnored
=
0
;
Unity
.
CurrentTestIgnored
=
0
;
UNITY_
EXEC_TIME_RESET
();
UNITY_
PRINT_EXEC_TIME
();
UNITY_PRINT_EOL
();
UNITY_PRINT_EOL
();
UNITY_FLUSH_CALL
();
UNITY_FLUSH_CALL
();
}
}
...
@@ -1712,6 +1712,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
...
@@ -1712,6 +1712,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
Unity
.
CurrentTestLineNumber
=
(
UNITY_LINE_TYPE
)
FuncLineNum
;
Unity
.
CurrentTestLineNumber
=
(
UNITY_LINE_TYPE
)
FuncLineNum
;
Unity
.
NumberOfTests
++
;
Unity
.
NumberOfTests
++
;
UNITY_CLR_DETAILS
();
UNITY_CLR_DETAILS
();
UNITY_EXEC_TIME_START
();
if
(
TEST_PROTECT
())
if
(
TEST_PROTECT
())
{
{
setUp
();
setUp
();
...
@@ -1721,6 +1722,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
...
@@ -1721,6 +1722,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
{
{
tearDown
();
tearDown
();
}
}
UNITY_EXEC_TIME_STOP
();
UnityConcludeTest
();
UnityConcludeTest
();
}
}
...
@@ -1735,7 +1737,6 @@ void UnityBegin(const char* filename)
...
@@ -1735,7 +1737,6 @@ void UnityBegin(const char* filename)
Unity
.
TestIgnores
=
0
;
Unity
.
TestIgnores
=
0
;
Unity
.
CurrentTestFailed
=
0
;
Unity
.
CurrentTestFailed
=
0
;
Unity
.
CurrentTestIgnored
=
0
;
Unity
.
CurrentTestIgnored
=
0
;
UNITY_EXEC_TIME_RESET
();
UNITY_CLR_DETAILS
();
UNITY_CLR_DETAILS
();
UNITY_OUTPUT_START
();
UNITY_OUTPUT_START
();
...
...
src/unity_internals.h
浏览文件 @
d7004788
...
@@ -40,10 +40,6 @@
...
@@ -40,10 +40,6 @@
#include <limits.h>
#include <limits.h>
#endif
#endif
#ifndef UNITY_EXCLUDE_TIME_H
#include <time.h>
#endif
/*-------------------------------------------------------
/*-------------------------------------------------------
* Guess Widths If Not Specified
* Guess Widths If Not Specified
*-------------------------------------------------------*/
*-------------------------------------------------------*/
...
@@ -299,42 +295,67 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
...
@@ -299,42 +295,67 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
#define UNITY_OUTPUT_COMPLETE()
#define UNITY_OUTPUT_COMPLETE()
#endif
#endif
#ifndef UNITY_EXEC_TIME_RESET
#ifdef UNITY_INCLUDE_EXEC_TIME
#ifdef UNITY_INCLUDE_EXEC_TIME
#define UNITY_EXEC_TIME_RESET()\
#if !defined(UNITY_EXEC_TIME_START) && \
Unity.CurrentTestStartTime = 0;\
!defined(UNITY_EXEC_TIME_STOP) && \
Unity.CurrentTestStopTime = 0;
!defined(UNITY_PRINT_EXEC_TIME) && \
#else
!defined(UNITY_TIME_TYPE)
#define UNITY_EXEC_TIME_RESET()
/* If none any of these macros are defined then try to provide a default implementation */
#endif
#if defined(UNITY_CLOCK_MS)
/* This is a simple way to get a default implementation on platforms that support getting a millisecond counter */
#define UNITY_TIME_TYPE UNITY_UINT
#define UNITY_EXEC_TIME_START() Unity.CurrentTestStartTime = UNITY_CLOCK_MS()
#define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS()
#define UNITY_PRINT_EXEC_TIME() { \
UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \
UnityPrint(" ("); \
UnityPrintNumberUnsigned(execTimeMs); \
UnityPrint(" ms)"); \
}
#elif defined(_WIN32)
#include <time.h>
#define UNITY_TIME_TYPE clock_t
#define UNITY_GET_TIME(t) t = (clock_t)((clock() * 1000) / CLOCKS_PER_SEC)
#define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime)
#define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime)
#define UNITY_PRINT_EXEC_TIME() { \
UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \
UnityPrint(" ("); \
UnityPrintNumberUnsigned(execTimeMs); \
UnityPrint(" ms)"); \
}
#elif defined(__unix__)
#include <time.h>
#define UNITY_TIME_TYPE struct timespec
#define UNITY_GET_TIME(t) clock_gettime(CLOCK_MONOTONIC, &t)
#define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime)
#define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime)
#define UNITY_PRINT_EXEC_TIME() { \
UNITY_UINT execTimeMs = ((Unity.CurrentTestStopTime.tv_sec - Unity.CurrentTestStartTime.tv_sec) * 1000L); \
execTimeMs += ((Unity.CurrentTestStopTime.tv_nsec - Unity.CurrentTestStartTime.tv_nsec) / 1000000L); \
UnityPrint(" ("); \
UnityPrintNumberUnsigned(execTimeMs); \
UnityPrint(" ms)"); \
}
#endif
#endif
#endif
#endif
#ifndef UNITY_EXEC_TIME_START
#ifndef UNITY_EXEC_TIME_START
#ifdef UNITY_INCLUDE_EXEC_TIME
#define UNITY_EXEC_TIME_START() do{}while(0)
#define UNITY_EXEC_TIME_START() Unity.CurrentTestStartTime = UNITY_CLOCK_MS();
#else
#define UNITY_EXEC_TIME_START()
#endif
#endif
#endif
#ifndef UNITY_EXEC_TIME_STOP
#ifndef UNITY_EXEC_TIME_STOP
#ifdef UNITY_INCLUDE_EXEC_TIME
#define UNITY_EXEC_TIME_STOP() do{}while(0)
#define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS();
#else
#define UNITY_EXEC_TIME_STOP()
#endif
#endif
#ifndef UNITY_TIME_TYPE
#define UNITY_TIME_TYPE UNITY_UINT
#endif
#endif
#ifndef UNITY_PRINT_EXEC_TIME
#ifndef UNITY_PRINT_EXEC_TIME
#ifdef UNITY_INCLUDE_EXEC_TIME
#define UNITY_PRINT_EXEC_TIME() do{}while(0)
#define UNITY_PRINT_EXEC_TIME() \
UnityPrint(" (");\
UNITY_COUNTER_TYPE execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime);\
UnityPrintNumberUnsigned(execTimeMs);\
UnityPrint(" ms)");
#else
#define UNITY_PRINT_EXEC_TIME()
#endif
#endif
#endif
/*-------------------------------------------------------
/*-------------------------------------------------------
...
@@ -451,8 +472,8 @@ struct UNITY_STORAGE_T
...
@@ -451,8 +472,8 @@ struct UNITY_STORAGE_T
UNITY_COUNTER_TYPE
CurrentTestFailed
;
UNITY_COUNTER_TYPE
CurrentTestFailed
;
UNITY_COUNTER_TYPE
CurrentTestIgnored
;
UNITY_COUNTER_TYPE
CurrentTestIgnored
;
#ifdef UNITY_INCLUDE_EXEC_TIME
#ifdef UNITY_INCLUDE_EXEC_TIME
UNITY_
COUNTER
_TYPE
CurrentTestStartTime
;
UNITY_
TIME
_TYPE
CurrentTestStartTime
;
UNITY_
COUNTER
_TYPE
CurrentTestStopTime
;
UNITY_
TIME
_TYPE
CurrentTestStopTime
;
#endif
#endif
#ifndef UNITY_EXCLUDE_SETJMP_H
#ifndef UNITY_EXCLUDE_SETJMP_H
jmp_buf
AbortFrame
;
jmp_buf
AbortFrame
;
...
@@ -671,12 +692,6 @@ extern const char UnityStrErr64[];
...
@@ -671,12 +692,6 @@ extern const char UnityStrErr64[];
#define TEST_ABORT() return
#define TEST_ABORT() return
#endif
#endif
#ifndef UNITY_EXCLUDE_TIME_H
#define UNITY_CLOCK_MS() (UNITY_COUNTER_TYPE)((clock() * 1000) / CLOCKS_PER_SEC)
#else
#define UNITY_CLOCK_MS()
#endif
/* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */
/* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */
#ifndef RUN_TEST
#ifndef RUN_TEST
#ifdef __STDC_VERSION__
#ifdef __STDC_VERSION__
...
...
test/tests/testunity.c
浏览文件 @
d7004788
...
@@ -104,8 +104,8 @@ void testUnitySizeInitializationReminder(void)
...
@@ -104,8 +104,8 @@ void testUnitySizeInitializationReminder(void)
UNITY_COUNTER_TYPE
CurrentTestFailed
;
UNITY_COUNTER_TYPE
CurrentTestFailed
;
UNITY_COUNTER_TYPE
CurrentTestIgnored
;
UNITY_COUNTER_TYPE
CurrentTestIgnored
;
#ifdef UNITY_INCLUDE_EXEC_TIME
#ifdef UNITY_INCLUDE_EXEC_TIME
UNITY_
COUNTER
_TYPE
CurrentTestStartTime
;
UNITY_
TIME
_TYPE
CurrentTestStartTime
;
UNITY_
COUNTER
_TYPE
CurrentTestStopTime
;
UNITY_
TIME
_TYPE
CurrentTestStopTime
;
#endif
#endif
#ifndef UNITY_EXCLUDE_SETJMP_H
#ifndef UNITY_EXCLUDE_SETJMP_H
jmp_buf
AbortFrame
;
jmp_buf
AbortFrame
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录