0

我需要在我的 C 项目中做一些单元测试,这将在 STM32F0 处理器中使用。我可以在 x64 gcc 上测试我的抽象代码,但问题是我需要一个带有 little-endian 的平台(STM32F0 默认为 little-endian)。我试图在 project.yml 文件中做一些修改。

:project:
  :use_exceptions: FALSE
  :use_test_preprocessor: TRUE
  :use_auxiliary_dependencies: TRUE
  :build_root: build
#  :release_build: TRUE
  :test_file_prefix: test_

#:release_build:
#  :output: MyApp.out
#  :use_assembly: FALSE

:environment:

:extension:
  :executable: .out

:paths:
  :test:
    - +:test/**
    - -:test/support
  :source:
    - ../CDynTransport/src/
  :support:
    - test/support

:defines:
  # in order to add common defines:
  #  1) remove the trailing [] from the :common: section
  #  2) add entries to the :common: section (e.g. :test: has TEST defined)
  :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: arm-none-eabi-gcc
    :arguments:
      - "${1}"
      - '-c'
      - '-g'
      - '-mcpu=cortex-m0'
      - '-mthumb'
      - '-Wall'
      - '-Wno-address'
      #- '-std=c99'
      #- '-pedantic'
      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE               #expands to -I search paths
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR   #expands to -I search paths
      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR  #expands to all -D defined symbols
      - -I"$": COLLECTION_PATHS_SOURCE_INCLUDE_VENDOR
      - '-DTEST'
      - '-DUNITY_EXCLUDE_STDINT_H'
      - '-DUNITY_EXCLUDE_LIMITS_H'
      - '-DUNITY_EXCLUDE_SIZEOF'
      - '-DUNITY_INCLUDE_DOUBLE'
      - '-DUNITY_SUPPORT_TEST_CASES'
      - '-DUNITY_INT_WIDTH=32'
      - '-DUNITY_LONG_WIDTH=32'
      - '-DUNITY_INCLUDE_CONFIG_H'
  :test_linker:
    :executable: arm-none-eabi-gcc
    :arguments:
      - '-lm'
      - '-mcpu=cortex-m0'
      - '-mthumb'
      - '-specs=nosys.specs'
      #- '-T targets/gcc_armcortexM3/qemu.ld'
  :test_simulator:
    :executable: qemu-system-arm
    :arguments:
      - -cpu cortex-m3
      - -M lm3s6965evb
      - -no-reboot
      - -nographic
      - -kernel

:plugins:
  :load_paths:
    - vendor/ceedling/plugins
  :enabled:
    - stdout_pretty_tests_report
    - module_generator

但我仍然有编译问题。例如:

Test 'test_command.c'
---------------------
Generating runner for test_command.c...
Compiling test_command_runner.c...
In file included from /home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/vendor/unity/src/unity.h:16:0,
                 from build/test/runners/test_command_runner.c:22:
/home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/vendor/unity/src/unity_internals.h:11:26: fatal error: unity_config.h: No such file or directory
 #include "unity_config.h"
                          ^
compilation terminated.
ERROR: Shell command failed.
> Shell executed command:
'arm-none-eabi-gcc build/test/runners/test_command_runner.c -c -g -mcpu=cortex-m0 -mthumb -Wall -Wno-address -I"test" -I"test/support" -I"../CDynTransport/src" -I"/home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/vendor/unity/src" -I"/home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/vendor/cmock/src" -I"build/test/mocks" -DTEST -I"../CDynTransport/src" -DTEST -DUNITY_EXCLUDE_STDINT_H -DUNITY_EXCLUDE_LIMITS_H -DUNITY_EXCLUDE_SIZEOF -DUNITY_INCLUDE_DOUBLE -DUNITY_SUPPORT_TEST_CASES -DUNITY_INT_WIDTH=32 -DUNITY_LONG_WIDTH=32 -DUNITY_INCLUDE_CONFIG_H'
> And exited with status: [1].

rake aborted!
ShellExecutionException: ShellExecutionException
/home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/lib/ceedling/tool_executor.rb:78:in `exec'
/home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/lib/ceedling/generator.rb:95:in `generate_object_file'
/home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/lib/ceedling/rules_tests.rake:17:in `block in <top (required)>'
/home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/lib/ceedling/task_invoker.rb:74:in `invoke_test_results'
/home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/lib/ceedling/test_invoker.rb:68:in `block in setup_and_invoke'
/home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/lib/ceedling/test_invoker.rb:32:in `setup_and_invoke'
/home/slawek/CentralInterface/CDynTransportTest/vendor/ceedling/lib/ceedling/tasks_tests.rake:11:in `block (2 levels) in <top (required)>'
Tasks: TOP => build/test/results/test_command.pass => build/test/out/test_command.out => build/test/out/test_command_runner.o
(See full trace by running task with --trace)

有人对 STM32 微控制器的 Ceedling 有现成的配置吗?

4

0 回答 0