Parasoft C/C++test如何在ARM DS-5环境中进行测试(下)

在嵌入式开发中,尤其是基于ARM架构的安全关键领域,单元测试是验证代码在目标硬件上运行时行为正确性的关键环节,对于保障最终产品的可靠性至关重要。前面介绍了Parasoft C/C++test在ARM DS-5环境中的集成步骤,包括插件安装、项目配置及静态分析的实现过程。下面将介绍如何利用Parasoft C/C++test开展单元测试,包括配置、执行及解决可能遇到的许可证问题,完成从静态检查到动态运行的完整测试闭环。

单元测试

对于DS-5项目需要使用如下內建配置作为基准并修改

复制之后对如下图所示部分根据实际项目做修改:

修改为:

执行的时候必须连接实际硬件,DS-5并没有提供软件仿真器,并且需要另一个许可证,如下所示:

lang-js 复制代码
对 /calendar 的 "Run DS-5 Test Executable (Software Model)" 开始(执行) ...

正在收集用于执行的测试...
...完成。
执行流程准备中...
...完成。
用户信息...
This execution flow starts external processes using predefined command lines,
please review these commands and adjust to suit your environment.

...完成。
属性的设置: stub_config_file = D:\workspace\DS-5\.cpptest\calendar\unit-data\current_tubf179707/stubconfig.xml
属性的设置: stub_config_header_file = D:\workspace\DS-5\.cpptest\calendar\unit-data\current_tubf179707/cpptest_stubconfig.h
属性的设置: sm_exe = D:\DS-5\sw\models\bin\FVP_EB_Cortex-A8
测试用例查找中...
...完成。
[calendar.c] 源代码预编译中: /calendar/calendar.c ...
[calendar.c] ...结果是最新的。
正在为 /calendar/calendar.c 追加包括的测试用例 ...
...结果是最新的。
[calendar.c] 插桩准备中: /calendar/calendar.c ...
[calendar.c] ...结果是最新的。
为: /calendar/calendar.c 的静态覆盖率数据读取中...
...完成。
静态覆盖数据发送中...
...完成。
桩函数源代码插桩中: D:\Parasoft\C++testforEclipse\10.3\engine\etc\safestubs\safe_stubs_win32.c ...
...结果是最新的。
符号数据读取中...
...完成。
正在检查缺少的定义...
...结果是最新的。
可用的定义数据读取中...
...完成。
正在分析缺少的定义...
...完成。
桩函数配置中...
为函数: int scanf(const char *__restrict__, ...) 使用 原始 定义
为函数: int printf(const char *__restrict__, ...) 使用 原始 定义
为函数: void nextday(void) 使用 原始 定义
为函数: void calcDaysInMonth(void) 使用 原始 定义
...完成。
桩函数配置头文件创建中...
...结果是最新的。
测试运行文件创建中...
...结果是最新的。
运行时库构建中...
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestApi.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestCoverage.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestErrorMessages.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestMemoryAnalysis.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestMessage.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestRuntime.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestStackTrace.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestStreams.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestThread.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestThreadData.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestTime.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestTypeLimits.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\CppTestUtils.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\common\CppTestAlloc.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\common\CppTestList.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\common\CppTestMarshall.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\common\CppTestMemory.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\common\CppTestProperties.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\common\CppTestString.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\common\CppTestTree.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransport.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportFile.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportFileBuffered.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportFileSplit.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportHewSimIO.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportITM.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportLauterbachFDX.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportNXT.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportRenrxGDB.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportRS232Common.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportRS232STM32F103ZE.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportRS232Unix.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportRS232Win32.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportTemplate.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportUnixSocket.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportUnixSocketUDP.c ...
...结果是最新的。
源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\runtime\src\transport\CppTestTransportWinSocket.c ...
...结果是最新的。
...完成。
[calendar.c] 插桩的源代码编译中: /calendar/calendar.c ...
[safe_stubs_win32.c] 插桩的源代码编译中: D:\Parasoft\C++testforEclipse\10.3\engine\etc\safestubs\safe_stubs_win32.c ...
[cpptest_testrunner.c] 源代码编译中: D:\workspace\DS-5\.cpptest\calendar\unit-data\current_tubf179707\cpptest_testrunner.c ...
[safe_stubs_win32.c] ...结果是最新的。
[calendar.c] ...结果是最新的。
[cpptest_testrunner.c] ...结果是最新的。
测试项目链接中...
...结果是最新的。
移除文件 D:\workspace\DS-5\.cpptest\calendar\unit-data\current_tubf179707/cpptest_results.tlog
移除文件 D:\workspace\DS-5\.cpptest\calendar\unit-data\current_tubf179707/cpptest_results.clog
Running Test Executable...
D:\DS-5\sw\models\bin\FVP_EB_Cortex-A8 -a D:\workspace\DS-5\.cpptest\calendar\unit-data\current_tubf179707/calendarTest.axf -C coretile.core.semihosting-cmd_line="D:\workspace\DS-5\.cpptest\calendar\unit-data\current_tubf179707/calendarTest.axf --start-after=0"
terminal_0: Listening for serial connection on port 5000
terminal_1: Listening for serial connection on port 5001
terminal_3: Listening for serial connection on port 5002
terminal_2: Listening for serial connection on port 5003
WARNING: baseboard.mmc: MMC backing store file mmc.dat could not be used
INFO: baseboard.mmc backing store: no image file connected
Error: No License found:

ERROR: License check failed!
Either the license file or the license server could not be found.
Please set the environment variable 'ARMLMD_LICENSE_FILE'
to your license file location or refer to the ARM_FLEXnet_Guide
for instructions on where to obtain a license file, where to install
the license file, and how to setup a license server.

Error Code : -1

Fatal Error: Call of CADISimulationFactory::Instantiate(..) did not return a CADISimulation.
...完成。
测试日志读取中...
找不到测试日志文件。: D:\workspace\DS-5\.cpptest\calendar\unit-data\current_tubf179707\cpptest_results.tlog
请确保:
1. 测试可执行文件 "D:\workspace\DS-5\.cpptest\calendar\unit-data\current_tubf179707\calendarTest.axf" 正常构建并运行
2. 当运行测试时所有的依赖 DLL 在 PATH 环境变量中都可用
...失败。

对 /calendar 的 "Run DS-5 Test Executable (Software Model)" (执行)由于错误而结束。检查上述日志详情。
临时覆盖率数据清除中...
...完成。

通过创建专用的DS-5测试配置并调整编译器与链接器设置,成功实现了在目标硬件上执行单元测试。该方案有效验证了代码的运行时行为,与静态分析形成互补。Parasoft C/C++test与ARM DS-5的深度集成,为构建高可靠性嵌入式软件提供了从静态检测到动态验证的完整质量保障体系。

相关推荐
汽车仪器仪表相关领域2 天前
Kvaser Hybrid CAN/LIN 单通道三合一总线分析仪:高性价比CAN FD/LIN集成测试利器
运维·服务器·网络·数据挖掘·数据分析·单元测试·集成测试
一路往蓝-Anbo2 天前
第十章:TDD部署 —— Ceedling 环境的深度集成
stm32·单片机·嵌入式硬件·单元测试·测试驱动开发·tdd
川石课堂软件测试3 天前
使用mock进行接口测试教程
数据库·python·功能测试·测试工具·华为·单元测试·appium
芒鸽4 天前
鸿蒙应用测试实战:从单元测试到自动化测试
华为·单元测试·harmonyos
MC皮蛋侠客5 天前
Google Test 单元测试指南
c++·单元测试·google test
英俊潇洒美少年6 天前
前端 Jest 单元测试零基础实战:模板、提效、避坑、面试题(Vue 项目可用)
前端·vue.js·单元测试
测试员周周10 天前
【Appium 系列】第18节-重试与容错 — 移动端测试的稳定性保障
人工智能·python·功能测试·ui·单元测试·appium·测试用例
测试员周周10 天前
【Appium 系列】第17节-XMind用例转换 — 从思维导图到 YAML
java·服务器·人工智能·单元测试·appium·测试用例·xmind
一路往蓝-Anbo10 天前
第五章:如何对 HAL 库本身进行单元测试?
网络·数据结构·stm32·单片机·嵌入式硬件·单元测试·tdd