简体   繁体   English

使用 IAR 对 STM32L0x3 进行目标单元测试

[英]On Target Unit testing for STM32L0x3 using IAR

I want to have a test frame work in my IAR Project.我想在我的 IAR 项目中有一个测试框架工作。 The processor is an STM32L0.处理器是STM32L0。

What I've tried:我试过的:

  • https://github.com/cpputest/cpputest followed the turoial at : https://cpputest.github.io/stories.html Didn't work because there is only 64K Flash & 8K RAM https://github.com/cpputest/cpputest在 turoial 之后: https ://cpputest.github.io/stories.html 没有工作,因为只有 64K 闪存和 8K RAM

    在此处输入图片说明

    and its not enough for this framework这对这个框架来说还不够

  • https://github.com/ThrowTheSwitch/Unity.git I tried to intigrate into IAR Embedded workbench but had a lot of compiler errors also not enough space so I tried to run it on my Desktop. https://github.com/ThrowTheSwitch/Unity.git我试图融入 IAR 嵌入式工作台,但有很多编译器错误也没有足够的空间,所以我尝试在我的桌面上运行它。 This doesn't work because it has too many Hardware dependencies in the code..这不起作用,因为它在代码中有太多硬件依赖项..

  • Next I tried to just make "Pseudo" unit testing by putting a test routine at boot of the device which can be switched on and off by precompiler directives.接下来,我尝试通过在设备启动时放置一个测试例程来进行“伪”单元测试,该例程可以通过预编译器指令打开和关闭。

Like this (not finished):像这样(未完成):

#if PREFORM_TESTS
    TEST_run();
#endif  

And then with files:然后是文件:

#include "testAll.h"
#include "testEvent.h"
#include "stm32l0xx_hal.h"

void TEST_run(){
  TEST_EVENT_run();
}
void assert_failed(uint8_t* file, uint32_t line){
  while(1);  
}

#include "testEvent.h"
#include "testAll.h"
#include "event.h"
#include "stm32l0xx_hal.h"

void test_add_event();

void TEST_EVENT_run(){
    test_add_event();
}

void test_add_event(){
  ASSERT(1); 
}

How can I run Unit Tests on my STM32L0x3?如何在 STM32L0x3 上运行单元测试?

Generally for even embedded targets, code 'modules' are compiled on your desktop target.通常,即使是嵌入式目标,代码“模块”也会在您的桌面目标上编译。 So you would pull in the modules into your tests and stub out/mock hardware specific ones.因此,您可以将模块引入测试并存根/模拟特定于硬件的模块。

If there isn't enough space for putting a testing framework on the device, then perhaps you shouldn't (or find a more minimal one).如果没有足够的空间在设备上放置测试框架,那么也许您不应该(或找一个更小的)。 You will then have to write your tests in the application code without a testing framework, just as if you would write normal application code.然后,您将不得不在没有测试框架的应用程序代码中编写测试,就像编写普通应用程序代码一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM