PGO instrumented VSTest.Console.exe - visual-studio

I'm trying to run some tests on a DLL that has been instrumented with PGO. When I run it with the VSTest.Console.exe, I get the following error message:
Error message:
Failed to set up the execution context to run the test
My goal is to produce some PGC files for the DLL to see if the compiler can produce better code. BTW, the same thing happens with MSVS.
Does anyone have advice where I may find a PGO instrumented VSTest.Console.exe or another method for what I need?

Placing this DLL in the same directory as the targeted DLL, allows me to produce PGC files.
pgort140.dll

Related

MSTest DeploymentItem attribute causes SQLite.Interop.dll not found

The suite of unit tests I have immediately fails the test run with System.DllNotFoundException: Unable to load DLL 'SQLite.Interop.dll' which is a dependency required within the test [AssemblyInitialize] methods.
I've determined this is caused by executing any test that is using the [DeploymentItem] attribute and is the case for either a class or method. Any tests that do not use this attribute pass.
With Test Diagnostic logging enabled in VS2019 there are no obvious errors but I can see this config.
<RunSettings>
<RunConfiguration>
<ResultsDirectory>D:\Dev\****\src\TestResults</ResultsDirectory>
<SolutionDirectory>D:\Dev\****\src\</SolutionDirectory>
<TargetPlatform>X86</TargetPlatform>
<CollectSourceInformation>False</CollectSourceInformation>
</RunConfiguration>
</RunSettings>
My test projects are all configured for <PlatformTarget>AnyCPU</PlatformTarget> so I wonder if the SQLite.Interop.dll is not found because of an issue with x86 vs x64.
Where can I configure the <RunSettings>?
Why would SQLite.Interop.dll not be found?
UPDATE
Using procmon.exe filtering for testhost.exe and SQLite.Interop.dll I can see that a test without [DeploymentItem] attributes starts looking for the dll in the project bin\Debug folder which finds it at bin\Debug\x64\SQLite.Interop.dll.
Those tests with the attribute starts looking in the Test Results directory TestResults\...\Out then all across the machine C:\Windows, C:\Program Files, C:Users but never further under bin\Debug.
Running the same tests using VSTest.Console.exe does not have this issue.
How can I apply System.Data.SQLite from NuGet, interop dll not copied to output directory to the .\Out directory for the unit tests?
To resolve;
Configure unit tests by using a .runsettings file
Add setting <DisableAppDomain>True</DisableAppDomain>, see Configure a test run
Note that run settings cannot be retained at the project or solution level and need to be set in the IDE; https://developercommunity.visualstudio.com/content/problem/151608/ability-to-set-runsettings-in-project-file.html
Dave Anderson's answer did help, however we load custom modules into SQLite and this caused the 'Attempted to read or write protected memory' error. The work around for me was to remove <DisableAppDomain>True</DisableAppDomain> and use
[DeploymentItem(#"x86\SQLite.Interop.dll", "x86")]
[DeploymentItem(#"x64\SQLite.Interop.dll", "x64")]
on all tests or classes that needed to use SQLite

Can not get NUnit Runner task working

I've created NUnit Runner task, but it failes all the time.
As an executable I'm using nunit3-console.exe
My tests in .net 4.6.1 test project use NUnit3
This is how the job is configured:
nunit job configuration
After plan run I've got error:
Could not find test result reports in the C:\Users\dw\bamboo-home\xml- data\build-dir\DWT-BW-JOB1 directory.
Invalid argument: -xml=BW\14\TestResult.xml
I've found that is because NUnit runner task on Bamboo is designed to work with NUnit2. The "-xml" argument is not supported in NUnit3 console runner.
I've found somebody found a solution, but it does not work for me: http://vijayshinva.github.io/devops/bamboo/nunit/tdd/ci/2016/02/25/configure-atlassian-bamboo-nunit-runner-to-execute-nunit-3-tests.html
In my case I've got another error:
Could not find test result reports in the C:\Users\dw\bamboo-home\xml- data\build-dir\DWT-BW-JOB1 directory.
'nunit3-console.exe' is not recognized as an internal or external command, operable program or batch file.
Please, help resolve this issue. Thank you

GCOV profilling error : Error writing

I am trying to get coverage for my source file(main_source.c) tested using unit testing via gtest framework. In my program i am creating a shared object of the source file placed in directory A(--coverage flag was set while creation of .so file, I can see the gcno files in A folder). I have a test file which tests one or two .lo files present in this shared object. My test file is created in folder B which includes shared object created in the previous step for linking purposes. My test is running good, I am able to the get coverage for the test source file. I am getting an error "profiling: A/main_source.c:Error writing gcda files". Can anyone please help. Thank you in advance.

TeamCity and CTest test results

I have a number of unit tests written for my project, executed with CTest. I would like to integrate the results into my TeamCity build. I've downloaded and set up the plugin for my testing framework (Boost Test).
The problem that I have run into is that the tests run with CTest output to Testing/Temporary/LastTest.log, whereas TeamCity is trying to read the results from standard out. To get around this, my testing step is.
make test
cat Testing/Temporary/LastTest.log
which works, but feels like a hack.
Is there any way to get TeamCity to read from this file in addition to standard out? Alternatively, is there any way to tell ctest to output to standard out in addition to this LastTest.log file?
This question is similar, but I would like it to work for all output rather than just on failure: CMake: setting an environmental variable for ctest (or otherwise getting failed test output from ctest/make test automatically)
Teamcity has additional build features which allow to process CTest reports. I am not sure if it'll work or not but you could try adding an additional build feature in your build step to read CTest report.

Which MSBuild tasks initiate a call to SGen?

I have inherited a complex MSBuild script which builds & deploys multiple solutions. When I run the script I see the following error in log:
SGEN: Cannot generate serialization assembly
C:\B\268\Agents\Agents.XmlSerializers.dll
because it already exists. Use /force to force an overwrite of the
existing assembly.
I agree that Agents.XmlSerializers.dll exists. What I can't determine is which task caused it to be created and which one initiated the attempt to re-create it.
I have searched through the files in the build hierarchy for 'SGen' and found nothing. So I presume that SGen is called implicitly by two (or more) of the tasks in the build.
Can anyone point out what might call SGen?
Thanks.
In the Build Output window, look for...
Task "SGen"
Right above that is the actual "sgen.exe" command.
And as Pawell said, you need full details in your build output. Inside of Studio, it's Tools - Options... - Projects and Solutions - Build and Run - MSBuild project build output verbosity: Diagnostic.

Resources