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

相关推荐
JosieBook17 小时前
【SpringBoot】30 核心功能 - 单元测试 - JUnit5 单元测试简介与常用注解实战详解
spring boot·后端·单元测试
l1t21 小时前
对luasql-duckdb PR的测试
c语言·数据库·单元测试·lua·duckdb
卓码软件测评1 天前
单元测试、集成测试和系统测试的联系和区别是什么?
功能测试·单元测试·测试用例·集成测试·可用性测试
安冬的码畜日常1 天前
【JUnit实战3_20】第十一章:用 Gradle 运行 JUnit 测试实战
测试工具·junit·单元测试·gradle·软件构建·groovy·junit5
安冬的码畜日常2 天前
【JUnit实战3_19】第十章:用 Maven 3 运行 JUnit 测试(下)
java·测试工具·junit·单元测试·maven·junit5
董广明2 天前
单元测试(JUnit、Mockito、PowerMock )
java·经验分享·junit·单元测试
aloha_7892 天前
软件测试工程师面试准备
单元测试·压力测试
安冬的码畜日常2 天前
【JUnit实战3_13】第八章:mock 对象模拟技术在细粒度测试中的应用(上)
测试工具·junit·单元测试·junit5·mock模拟·mock对象·mock objects