Environment coverage test under VS

1. Install the VS enterprise version and try it. After installation, the corresponding tools seem to be installed.

2. Start instrumenting dll:
these executable files are all in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools\x64
Batch code collection code
vsinstr /coverage D:\shary\V2017_publish\ Note for nclibd.dll 
: a. nclibd.dll is the dll file to be tested
            b. The pdb file needs to be generated at the same time when
            compiling c. The /profile option of link needs to be opened when compiling
If successful, the following information will be displayed:
The original file has been backed up to D:\shary\V2017_publish\nclibd.dll.orig
has successfully detected the file D:\shary\V2017_publish\nclibd.dll

3. Start monitoring:
Batch code Favorite code
vsperfcmd /start:coverage /output:c:\test\sample.coverage


or available
start vsperfmon -coverage -output:"D:\a.coverage"

It will display:

Start in standalone mode
File name: d:\a.coverage

4. At this time, you can use various test methods to call the dll to be tested for testing, and the coverage rate will be counted in the output file above.

5. Terminate monitoring of
batch codes
vsperfcmd /shutdown  

All data has been written to the file, but can only be opened with VS. But all the previous operations can be performed without opening VS.

In addition:
/Profile option settings:
First, open the solution or project file of the program you need to test, and it is necessary to specify the settings of the program to be tested. It is recommended that you use the Debug compilation mode. If you use the Release compilation mode, the program will not be able to analyze the function symbols. Please click Project->Properties->Configuration Properties->Linker->Command Line in VS, fill in /Profile in the Additional options on the right, (ie Connector->Command Line->Other options, manually add /Profile parameter), which means you tell the linker Linker that this program needs to be used for the VS Profiler. It is very important for newbies to note that after the program performance tuning is completed, you need to remove this added option and use Release to compile and link to generate a program that can be released.


6. After opening the file "d:\a.coverage", you can view the results through VS. The interface called can be viewed through the global function.


Question 1:
run -> C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools\x64>vsinstr /coverage "D:\shary\NMTCLIB_Stand\bin\nclibd.dll" The error is as follows:
Error VSP1033 : The file "D:\shary\NMTCLIB_Stand\bin\nclibd.dll" does not contain a recognized executable image


7. Use batch to automate the above process:
@set localFolder=D:\shary\NMTCLIB_Stand\bin\
@set nclibFolder=\\192.168.1.110\test\nclib\20170516

@set codetrunkpath=%localFolder%/../
@set VStools="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools\x64"

@copy %nclibFolder% %localFolder% /y

@cd /d  %VStools%
vsinstr /coverage "%localFolder%\nclibd.dll"
vsperfcmd /start:coverage /output:%localFolder%\unittest.coverage

@goto MSBUILD

:MSBUILD
call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" amd64
msbuild %codetrunkpath%Test\NCLibTestFramework\code\NCLibUnitTest.sln /t:rebuild /p:Configuration=Release /p:platform=x64 /m
%codetrunkpath%bin\NCLibUnitTest.exe --gtest_filter=*regression*  > %codetrunkpath%NCLIB.log


Because the build time is relatively long, the final shutdown cannot be put into the batch, and a separate shutdown is required.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326382316&siteId=291194637