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的深度集成,为构建高可靠性嵌入式软件提供了从静态检测到动态验证的完整质量保障体系。

相关推荐
许彰午7 天前
39_Java单元测试JUnit入门
java·junit·单元测试
果子耶耶7 天前
让大模型帮我写单元测试,5个模型的覆盖率和边界处理能力实测
chatgpt·单元测试
川石课堂软件测试8 天前
APP自动化测试|高级手势操作&toast操作
css·功能测试·测试工具·microsoft·fiddler·单元测试·harmonyos
Thecozzy10 天前
单元测试 vs 手工测试:以水印功能为例
单元测试
HLAIA光子11 天前
AI Coding框架,打好TDD和SDD这两拳
单元测试·ai编程·代码规范
霸道流氓气质11 天前
Java 单元测试生成大量 Excel 测试数据实战指南
java·单元测试·excel
川石课堂软件测试11 天前
UI自动化测试|下拉选择框&弹出框&滚动条操作实践
开发语言·python·jmeter·ui·docker·单元测试·harmonyos
川石课堂软件测试12 天前
UI自动化测试|元素操作&浏览器操作实践
功能测试·测试工具·mysql·ui·docker·容器·单元测试
无聊的老谢12 天前
电信系统中的单元测试策略:构建高可靠性的微服务防线
数据库·微服务·单元测试