ARM STM32 的 Ceedling CMock 设置
Ceedling CMock settings for ARM STM32
我一直在为 STM32 设置 Ceedling。 howto 非常稀少,到目前为止,我几乎没有 google。幸运的是,该框架相对于它的大小而言是相对透明的。 是PIC配置。我设置了类似的东西 (project.yml
):
...
: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 #[]
- STM32F103xB
- UNITY_INT_WIDTH=32
- CMOCK_MEM_INDEX_TYPE=uint32_t
- UNITY_LINE_TYPE=uint16_t
:test:
- *common_defines
- TEST
:test_preprocess:
- *common_defines
- TEST
到目前为止一切顺利(尚未尝试实际工作)。添加了这个定义
- CMOCK_MEM_PTR_AS_INT=uint32_t
我有一个警告:
/vendor/ceedling/vendor/cmock/src/cmock.c:105:40: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
index = *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)next - CMOCK_MEM_INDEX_SIZE);
难怪,因为next
是PC平台的64位指针。我仍然不确定是否必须控制 CMOCK_MEM_PTR_AS_INT
。这取决于 CMOCK_MEM_PTR_AS_INT
是否为关键目标 (ARM) 平台定义。
到目前为止我还没有找到STM32的例子。
这是来之不易的序列,完成了 Eclipse 集成:
安装 Ceedling:
$ gem install ceedling
创建 Ceedling 项目(故障排除 #215):
myproject $ cd ..
$ ceedling new myproject
$ cd myproject/vendor/
$ rm -rf ceedling/
$ git clone --recursive https://github.com/throwtheswitch/ceedling.git
修改vendor/ceedling/plugins/module_generator/config/module_generator.yml
:
:module_generator:
:project_root: ./
:source_root: Src/
:inc_root: Inc/
:test_root: test/
修改project.yml
:
...
:paths:
:test:
- +:test/**
- -:test/support
:source:
- Src/**
:include:
- Drivers/**
- Inc/**
:support:
- test/support
...
:defines:
:commmon: &common_defines # A nice typo, next to invisible :)
- STM32F103xB
...
:cmock:
:strippables:
- volatile
...
:plugins:
:load_paths:
- vendor/ceedling/plugins
:enabled:
# - stdout_pretty_tests_report
- stdout_gtestlike_tests_report
- module_generator
Eclipse C/C++单元插件配置:
Main/Project: 我的项目
Main/Application: /home/user/.gem/ruby/2.5.0/bin/ceedling
Main/Disable 自动构建
Arguments/Program 参数:clobber\ntest:all
Testing/Test 跑步者:Google 测试跑步者
环境:变量 TERM 值 xterm
我一直在为 STM32 设置 Ceedling。 howto 非常稀少,到目前为止,我几乎没有 google。幸运的是,该框架相对于它的大小而言是相对透明的。 project.yml
):
...
: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 #[]
- STM32F103xB
- UNITY_INT_WIDTH=32
- CMOCK_MEM_INDEX_TYPE=uint32_t
- UNITY_LINE_TYPE=uint16_t
:test:
- *common_defines
- TEST
:test_preprocess:
- *common_defines
- TEST
到目前为止一切顺利(尚未尝试实际工作)。添加了这个定义
- CMOCK_MEM_PTR_AS_INT=uint32_t
我有一个警告:
/vendor/ceedling/vendor/cmock/src/cmock.c:105:40: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
index = *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)next - CMOCK_MEM_INDEX_SIZE);
难怪,因为next
是PC平台的64位指针。我仍然不确定是否必须控制 CMOCK_MEM_PTR_AS_INT
。这取决于 CMOCK_MEM_PTR_AS_INT
是否为关键目标 (ARM) 平台定义。
到目前为止我还没有找到STM32的例子。
这是来之不易的序列,完成了 Eclipse 集成:
安装 Ceedling:
$ gem install ceedling
创建 Ceedling 项目(故障排除 #215):
myproject $ cd ..
$ ceedling new myproject
$ cd myproject/vendor/
$ rm -rf ceedling/
$ git clone --recursive https://github.com/throwtheswitch/ceedling.git
修改vendor/ceedling/plugins/module_generator/config/module_generator.yml
:
:module_generator:
:project_root: ./
:source_root: Src/
:inc_root: Inc/
:test_root: test/
修改project.yml
:
...
:paths:
:test:
- +:test/**
- -:test/support
:source:
- Src/**
:include:
- Drivers/**
- Inc/**
:support:
- test/support
...
:defines:
:commmon: &common_defines # A nice typo, next to invisible :)
- STM32F103xB
...
:cmock:
:strippables:
- volatile
...
:plugins:
:load_paths:
- vendor/ceedling/plugins
:enabled:
# - stdout_pretty_tests_report
- stdout_gtestlike_tests_report
- module_generator
Eclipse C/C++单元插件配置:
Main/Project: 我的项目
Main/Application:
/home/user/.gem/ruby/2.5.0/bin/ceedling
Main/Disable 自动构建
Arguments/Program 参数:clobber\ntest:all
Testing/Test 跑步者:Google 测试跑步者
环境:变量 TERM 值 xterm