• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    使用 Rational PureCoverage 診斷 C/C++ 程序覆蓋信息和用戶環境的集成

    發布: 2008-9-12 14:56 | 作者: 高偉斌 | 來源: www-128.ibm.com | 查看: 138次 | 進入軟件測試論壇討論

    領測軟件測試網
    Rational PureCoverage 是專門進行自動化運行分析代碼覆蓋信息的工具,是一個單獨的產品,也是 Rational PurifyPlus 家族中的一員?捎糜诟纳茟贸绦可靠性性能。在 Linux、UNIX 和 Windows 上都可使用和集成,PureCoverage 支持 C/C++、Java、.NET、Visual Basic 和 HTML。它可以實時診斷出應用程序覆蓋的函數或方法(包括調用次數)和代碼行信息。

    1 概述

    Rational PureCoverage 是專門進行自動化運行分析代碼覆蓋信息的工具,是一個單獨的產品,也是 Rational PurifyPlus 家族中的一員?捎糜诟纳茟贸绦蚩煽啃院托阅。在 Linux、UNIX 和 Windows 上都可使用和集成,PureCoverage 支持 C/C++、Java、.NET、Visual Basic 和 HTML。它可以實時診斷出應用程序覆蓋的函數或方法(包括調用次數)和代碼行信息。

    PureCoverage 產品除了有自己專門的用戶界面外,也可以和 Rational ClearQuest、Rational Robot、Rational Purify、IBM WebSphere Studio、Microsoft Visual Studio .NET、Microsoft Visual Studio 6 和 Microsoft Visual Basic 等無縫的集成,還可以用強大的命令行接口。所有通過圖形界面的 PureCoverage 功能都可用命令行來完成,此外 PureCoverage 還為命令行提供了更多的選項和功能。

    本文分別介紹了在 Linux / UNIX 和 Windows 上如何利用 PureCoverage 圖形界面和通過命令行工具分析 C/C++ 程序,對分析結果的整理和報告,以及和用戶環境的集成達到自動診斷和測試的目的。



    2 收集覆蓋信息數據

    2.1 在 Linux 或 UNIX 下收集覆蓋信息數據

    Linux 或 UNIX 下用 PureCoverage 要用 purecov 命令 Build 用戶程序,如果用戶還想通過 PureCoverage 獲得調用所有代碼行的信息,那么用戶程序還需要 Build 成 Debug 版本(如用 -g 選項)。用 purecov 封裝 Build 就是在執行 cc 或 gcc, g++ 前加 purecov 即可,例如:



    
    % purecov cc -g admetadata.cpp
    PureCoverage 2003a.06.15 Solaris 2 (32-bit) (c) Copyright IBM Corp. 1992, 2005 All rights reserved.
    Instrumenting: crti.o crt1.o values-xa.o admetadata.o libCstd.a... 
    libC_mtstubs.a. libcx.a... crtn.o Linking
    

    然后運行封裝好的可執行程序就可生成此程序所覆蓋的數據,例如:



    
      % ./a.out
    ****  PureCoverage instrumented a.out (pid 8480 at Mon Aug 31 04:25:00 2005)
      * PureCoverage 2003a.06.15 Solaris 2 (32-bit) (c) Copyright IBM Corp. 1992, 2005 All rights reserved.
      * For contact information type: "purecov -help"
      * Options settings: -purecov \
        -purecov-home=/usr/local/pure/releases/purecov.sol.2003a.06.15 \
        -cache-dir=/usr/local/pure/releases/purecov.sol.2003a.06.15/cache
      * License successfully checked out.
      * Command-line: ./a.out
    Hello, World
    
    ****  PureCoverage instrumented a.out (pid 8480)  ****
      * Preparing coverage data.. Please note this might take some time..
      * Saving coverage data to /net/ma-homes/homes/gaowb/a.out.pcv.
      * To view results type: purecov -view /net/ma-homes/homes/gaowb/a.out.pcv
      

    運行完后 PureCoverage 會保存覆蓋信息到一個擴展名為 pcv 的二進制文件,如果此文件已經存在, PureCoverage 缺省會更新合并此文件中的覆蓋信息。

    Windows 下用 PureCoverage 前先要 Build 好用戶程序,如果用戶還想通過 PureCoverage 獲得調用所有函數和代碼行的信息,那么用戶程序需要 Build 成 Debug 版本。Build 好用戶程序之后就可以用 PureCoverage 圖形界面工具或 coverage 命令行工具加參數生成覆蓋信息數據,PureCoverage 是一個實時診斷工具,所以在生成覆蓋信息數據時它會執行用戶程序。

    2.2 在 Windows 下用 PureCoverage 圖形界面收集覆蓋信息數據

    啟動"Rational PureCoverage"后,在歡迎界面點擊"Run"按鈕或從文件菜單或工具條選擇"Run"開始一個診斷程序,如圖1:


    圖1 PureCoverage 開始運行對話框
    圖1 PureCoverage 開始運行對話框

    在運行過程中 PureCoverage 會首先顯示一個包含當前狀態程序覆蓋情況的概要窗口,如圖2:


    圖2 PureCoverage 概要窗口
    圖2 PureCoverage 概要窗口

    2.3 在 Windows 下用其他開發工具集成調用 PureCoverage 收集和查看覆蓋信息數據

    為方便用戶開發和測試代碼,PureCoverage 可以集成到Microsoft Visual Studio 6,Microsoft Visual Studio .NET,Microsoft Visual Basic,Rational Robot,Rational ClearQuest 和 IBM WebSphere Studio 等開發工具。要在這些集成開發環境中使用 PureCoverage 請確保安裝 PureCoverage 時正確安裝了和這些開發工具的集成。下面的例圖3 是用 Microsoft Visual Studio 6 調用 PureCoverage 收集覆蓋信息數據:


    圖3 在 Microsoft Visual Studio 6 中調用 PureCoverage 來收集和查看覆蓋信息數據
    圖3 在 Microsoft Visual Studio 6 中調用 PureCoverage 來收集和查看覆蓋信息數據

    2.4 在 Windows 下用命令行工具收集覆蓋信息數據

    命令行工具用法如下:

    coverage [] []

    例如:

    coverage /SaveTextData="C:\pamsglib.txt" pamsglib.exe arg1 arg2 arg3

    下面是生成的結果實例:



    
    comment	PureCoverage text data file:
    comment	Data fields are separated by tabs.
    comment	Data appears in the following sections:
    comment	   Comment - These lines plus overall information about the run
    comment	   CoverageData - A spreadsheet-compatible table of tab-separated coverage results
    comment	   SourceLines - A table for each source file showing line numbers with line coverage
    comment	   (SourceLines is only available when at least one module is instrumented in line mode).
    
    comment	Program Name	S:\bugbert\nt_i386\pvtinstall\tests\admetadata.exe
    comment	Program Arguments	util miscthrow
    comment	Working Directory	S:\bugbert\test\admetadata\harness\util
    comment	User Name	gaowb
    comment	Program Version	2003.06.03 5352
    comment	Host Name	QWIN154
    comment	Machine Type	Intel Pentium 4 Model 3 Stepping 4
    comment	O/S Version	Windows NT 5.1.2600 Service Pack 2
    comment	#Processors	1
    comment	Physical Memory (MBytes)	2038
    comment	PID	0x1564
    comment	Language	C
    comment	Start Time	08/31/05 09:00:41
    comment	Stop Time	08/31/05 09:00:43
    comment	Dataset Size (bytes)	10313728
    comment	Elapsed Time (milliseconds)	12767979643649
    
    comment	CaseInsensitive	DeleteModule	Enabled	*MFC*.dll
    comment	CaseInsensitive	DeleteModule	Enabled	*MSVC*RT*.dll
    comment	CaseInsensitive	DeleteModule	Enabled	*MFC*.dll
    comment	CaseInsensitive	DeleteModule	Enabled	*MSVC*RT*.dll
    comment	CaseInsensitive	DeleteFile	Enabled	*Unknown Directory*
    comment	CaseInsensitive	DeleteFile	Enabled	*Unknown File*
    comment	CaseInsensitive	DeleteFile	Enabled	*pure_api.c
    comment	CaseInsensitive	DeleteFile	Enabled	*\\crt\\src*
    comment	CaseInsensitive	DeleteFile	Enabled	sys*
    comment	CaseInsensitive	DeleteFile	Enabled	intel*
    comment	CaseInsensitive	DeleteFile	Enabled	*Unknown Directory*
    comment	CaseInsensitive	DeleteFile	Enabled	*Unknown File*
    comment	CaseInsensitive	DeleteFile	Enabled	*pure_api.c
    comment	CaseInsensitive	DeleteFile	Enabled	*\\crt\\src*
    comment	CaseInsensitive	DeleteFile	Enabled	sys*
    comment	CaseInsensitive	DeleteFile	Enabled	intel*
    comment	CaseInsensitive	HideFunction	Disabled	*unknown_function*
    comment	CaseInsensitive	DeleteFunction	Enabled	SwitchToFiber
    comment	CaseInsensitive	DeleteFunction	Enabled	UnnamedFunction*
    comment	CaseInsensitive	DeleteFunction	Enabled	_*
    comment	CaseInsensitive	DeleteFunction	Enabled	$E*
    comment	CaseInsensitive	HideFunction	Disabled	*unknown_function*
    comment	CaseInsensitive	DeleteFunction	Enabled	SwitchToFiber
    comment	CaseInsensitive	DeleteFunction	Enabled	UnnamedFunction*
    comment	CaseInsensitive	DeleteFunction	Enabled	_*
    comment	CaseInsensitive	DeleteFunction	Enabled	$E*
    
    CoverageData	Name	Type	ParentSource	ParentModule	
    FunctionsUnused	FunctionsUsed	TotalFunctions	FunctionsPercent	
    LinesUnused	LinesUsed	TotalLines	LinesPercent	SourceLine	NumberOfCalls
    CoverageData	ThisRun	Run			10137	303	10440	      
    2.90	77049	838	77887	      1.08		21931797
    CoverageData	S:\bugbert\nt_i386\pvtinstall\tests\admetadata.exe	Module	
    		98	49	147	     33.33	243	260	503	     51.69		17283342
    CoverageData	S:\bugbert\nt_i386\pvtinstall\clearquest\CQPACKAGELIB.DLL	Module	
    		99	7	106	      6.60	192	15	207	      7.25		8478
    ... ...
    CoverageData	(Unknown Directory)	Directory	
    S:\bugbert\nt_i386\pvtinstall\tests\admetadata.exe	0	0	0	      
    0.00	0	0	0	      0.00		0
    CoverageData	\sys_nt\MSVC\common\include	Directory	
    S:\bugbert\nt_i386\pvtinstall\tests\admetadata.exe	3	1	4	     
    25.00	5	1	6	     16.67		2134067
    ... ...
    CoverageData	\bugbert\src\include\pamessage.h	SourceFile	\bugbert\src\include
    S:\bugbert\nt_i386\pvtinstall\tests\admetadata.exe	25	0	25	      
    0.00	25	0	25	      0.00		0
    CoverageData	\sys_nt\MSVC\common\mfc\include\afx.inl	SourceFile	
    \sys_nt\MSVC\common\mfc\include	S:\bugbert\nt_i386\pvtinstall\tests\admetadata.exe	
    9	7	16	     43.75	9	7	16	     43.75		6412263
    ... ...
    CoverageData	CGXGridRangeNameImp::GetRangeName(CGXGridCore *,char const*,CGXRange&)	
    Function	src\gxcrgnam.cpp	S:\bugbert\nt_i386\pvtinstall\clearquest\OG701CQAS.DLL	
    1	0	1	0.0	4	0	4	      0.00	119	0
    CoverageData	CGXGridRangeNameImp::DeleteRangeName
    (CGXGridCore *,char const*,CObject *,GXCmdType)	Function	
    src\gxcrgnam.cpp	S:\bugbert\nt_i386\pvtinstall\clearquest\OG701CQAS.DLL	
    1	0	1	0.0	16	0	16	      0.00	126	0
    ... ...
    
    SourceLines	\bugbert\src\include\pamessage.h	
    S:\bugbert\nt_i386\pvtinstall\tests\pamsglib.exe
    	LineNumber	LineCoverage
    	108.1	0
    	... ...
    	153.1	1
    	... ...
    ... ...
    



    3 查看和過濾覆蓋信息數據

    3.1 在 Linux 或 UNIX 下用 PureCoverage 查看器查看和過濾生成的覆蓋信息數據

    用 purecov -view 命令打開 PureCoverage 查看器可以顯示覆蓋信息,例如:



    
    % purecov -view a.out.pcv
    

    此命令將打開 PureCoverage 查看器圖形窗口,如圖4:


    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    TAG: purecoverage PureCoverage rational Rational RATIONAL 程序 環境 診斷

    21/212>

    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>