我正在为一个嵌入式应用程序开发一个特性,我使用Ceedling (它构建在团结测试框架之上)来测试它。我遇到的一个问题是,我需要使用C源文件中的功能,而Ceedling没有编译/链接我的单元测试文件。
根据Ceedling文件:
Ceedling知道通过每个测试文件中包含的#include列表编译和链接到每个单独的测试可执行文件的文件。配置的搜索目录中与测试文件中包含的头文件相对应的任何C源文件都将被编译并链接到生成的测试夹具可执行文件中。
问题是,我在单元测试中包含了一个头文件"RTOS.h“,以获得对embOS RTOS函数的访问,但是这些函数是在"RTOSInit.c”和"os7m_tl__dp.a“中定义的,根据本文档,Ceedling只在单元测试代码中看到#include "RTOS.h"时才会查找"RTOS.c”。
我正在寻找的是一种手动指定在生成测试运行程序可执行文件时应该编译和链接这些附加文件的方法。这似乎是Ceedling的一个非常基本的要求,但我无法从文档中找到这样的方法。
我也有把这作为一个问题提出在Ceedling Github网站上。
作为参考,下面给出我当前的"project.yml“文件(由Ceedling使用):
:project:
:use_exceptions: FALSE
:use_test_preprocessor: FALSE
:use_auxiliary_dependencies: TRUE
:build_root: build
:release_build: FALSE
:test_file_prefix: test_
:environment:
- :path:
- 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.5\arm\bin'
- 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.5\common\bin'
- #{ENV['PATH']}
:extension:
:executable: .out
:paths:
:test:
- +:test/**
- -:test/support
:source:
- src/main/c/**
- src/main/include/**
- src/main/resources/**
:support:
- test/support
:defines:
:commmon: &common_defines []
:test:
- *common_defines
- TEST
:test_preprocess:
- *common_defines
- TEST
:cmock:
:mock_prefix: mock_
:when_no_prototypes: :warn
:enforce_strict_ordering: TRUE
:plugins:
- :ignore
- :callback
:treat_as:
uint8: HEX8
uint16: HEX16
uint32: UINT32
int8: INT8
bool: UINT8
:tools:
:test_compiler:
:executable: iccarm
:name: 'IAR test compiler'
:arguments:
- -D _DLIB_FILE_DESCRIPTOR=1
- --debug
- --endian=little
- --cpu=Cortex-M3
- -e
- --fpu=None
- -Ol
- --preprocess "${3}"
- --dlib_config "C:/Program Files (x86)/IAR Systems/Embedded Workbench 6.5/arm/INC/c/DLib_Config_Normal.h"
- -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE
- -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
- -o "${2}"
- --diag_suppress=Pa050
- '"${1}"'
:test_linker:
:executable: ilinkarm
:name: 'IAR test linker'
:arguments:
- --vfe
- --redirect _Printf=_PrintfFull
- --redirect _Scanf=_ScanfFull
- --semihosting
- --config "C:/Program Files (x86)/IAR Systems/Embedded Workbench 6.5/arm/config/generic_cortex.icf"
- --map "${3}"
- -o "${2}"
- '"${1}"'
:test_fixture:
:executable: cspybat
:name: 'CSpyBat test runner'
:arguments:
- '"C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.5\arm\bin\armproc.dll"'
- '"C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.5\arm\bin\armsim2.dll"'
- '"${1}"'
- --plugin "C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.5\arm\bin\armbat.dll"
- --backend -B
- --endian=little
- --cpu=Cortex-M3
- --fpu=None
- --semihosting
:plugins:
:load_paths:
- vendor/ceedling/plugins
:enabled:
- stdout_pretty_tests_report
- module_generator
...发布于 2017-04-04 11:51:11
在测试nOS实时操作系统时,我也遇到了同样的问题,我使用空的头文件强制Ceedling编译相应的源文件。幸运的是,联合中添加了一个新的宏来解决这个问题。只需在测试文件的顶部添加类似的内容:
TEST_FILE("source_file_to_compile.c")https://stackoverflow.com/questions/41182876
复制相似问题