首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何手动指定Ceedling未能拾取的源文件?

如何手动指定Ceedling未能拾取的源文件?
EN

Stack Overflow用户
提问于 2016-12-16 10:58:01
回答 1查看 4.5K关注 0票数 3

我正在为一个嵌入式应用程序开发一个特性,我使用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使用):

代码语言:javascript
复制
: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
...
EN

回答 1

Stack Overflow用户

发布于 2017-04-04 11:51:11

在测试nOS实时操作系统时,我也遇到了同样的问题,我使用空的头文件强制Ceedling编译相应的源文件。幸运的是,联合中添加了一个新的宏来解决这个问题。只需在测试文件的顶部添加类似的内容:

代码语言:javascript
复制
TEST_FILE("source_file_to_compile.c")
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41182876

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档