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

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

修改为:

执行的时候必须连接实际硬件,DS-5并没有提供软件仿真器,并且需要另一个许可证,如下所示:
对 /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
请确保:
- 测试可执行文件 "D:\workspace\DS-5\.cpptest\calendar\unit-data\current_tubf179707\calendarTest.axf" 正常构建并运行
- 当运行测试时所有的依赖 DLL 在 PATH 环境变量中都可用
...失败。
对 /calendar 的 "Run DS-5 Test Executable (Software Model)" (执行)由于错误而结束。检查上述日志详情。
临时覆盖率数据清除中...
...完成。
通过创建专用的DS-5测试配置并调整编译器与链接器设置,成功实现了在目标硬件上执行单元测试。该方案有效验证了代码的运行时行为,与静态分析形成互补。Parasoft C/C++test与ARM DS-5的深度集成,为构建高可靠性嵌入式软件提供了从静态检测到动态验证的完整质量保障体系。
关于慧都
慧都科技(EVGET)成⽴于2003年,是⼀家⾏业数字化解决⽅案公司,⻓期专注于软件、油⽓与制造⾏业。公司基于深⼊的业务理解与管理洞察,以系统化的业务建模驱动技术落地,帮助企业实现智能化运营与⻓期竞争优势。
慧都科技作为Parasoft公司在中国区的官方授权合作伙伴,为国内企业提供Parasoft C/C++test产品的正版授权、定制化部署与全生命周期技术支持与服务。我们致力于助力客户精准贯彻功能安全标准、全面提升软件开发效率、有效管控项目风险,最终构建符合国际标准的高质量软件体系。
 023-68661681
                023-68661681
             返回
返回
 
                     
    						 
    						 
    						 
    						 
                    
发表评论