File tree Expand file tree Collapse file tree
src/Platform/Microsoft.Testing.Extensions.HangDump
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33
44using System . Globalization ;
5+ #if NETCOREAPP
6+ using System . Runtime . InteropServices ;
7+ #endif
58
69using Microsoft . Testing . Extensions . Diagnostics . Resources ;
710using Microsoft . Testing . Extensions . HangDump . Serializers ;
@@ -362,6 +365,13 @@ private async Task TakeDumpAsync()
362365 _ => throw ApplicationStateGuard . Unreachable ( ) ,
363366 } ;
364367
368+ // Wrap the dump path into "" when it has space in it, this is a workaround for this runtime issue: https://github.com/dotnet/diagnostics/issues/5020
369+ // It only affects windows. Otherwise the dump creation fails with: [createdump] The pid argument is no longer supported
370+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) && finalDumpFileName . Contains ( ' ' ) )
371+ {
372+ finalDumpFileName = $ "\" { finalDumpFileName } \" ";
373+ }
374+
365375 diagnosticsClient . WriteDump ( dumpType , finalDumpFileName , true ) ;
366376#else
367377 MiniDumpWriteDump . MiniDumpTypeOption miniDumpTypeOption = _dumpType . ToLowerInvariant ( ) . Trim ( ) switch
Original file line number Diff line number Diff line change @@ -47,6 +47,24 @@ public async Task HangDump_CustomFileName_CreateDump()
4747 Assert . IsTrue ( dumpFile is not null , $ "Dump file not found '{ TargetFrameworks . NetCurrent } '\n { testHostResult } '") ;
4848 }
4949
50+ public async Task HangDump_PathWithSpaces_CreateDump ( )
51+ {
52+ string resultDir = Path . Combine ( _testAssetFixture . TargetAssetPath , Guid . NewGuid ( ) . ToString ( "N" ) , TargetFrameworks . NetCurrent . Arguments ) ;
53+ string resultDirectory = Path . Combine ( resultDir , "directory with spaces" ) ;
54+ Directory . CreateDirectory ( resultDirectory ) ;
55+ var testHost = TestInfrastructure . TestHost . LocateFrom ( _testAssetFixture . TargetAssetPath , "HangDump" , TargetFrameworks . NetCurrent . Arguments ) ;
56+ TestHostResult testHostResult = await testHost . ExecuteAsync (
57+ $ """ --hangdump --hangdump-timeout 8s --hangdump-filename myhungdumpfile_%p.dmp --results-directory "{ resultDirectory } " """ ,
58+ new Dictionary < string , string >
59+ {
60+ { "SLEEPTIMEMS1" , "4000" } ,
61+ { "SLEEPTIMEMS2" , "20000" } ,
62+ } ) ;
63+ testHostResult . AssertExitCodeIs ( ExitCodes . TestHostProcessExitedNonGracefully ) ;
64+ string ? dumpFile = Directory . GetFiles ( resultDirectory , "myhungdumpfile_*.dmp" , SearchOption . AllDirectories ) . SingleOrDefault ( ) ;
65+ Assert . IsTrue ( dumpFile is not null , $ "Dump file not found '{ TargetFrameworks . NetCurrent } '\n { testHostResult } '") ;
66+ }
67+
5068 [ Arguments ( "Mini" ) ]
5169 [ Arguments ( "Heap" ) ]
5270 [ Arguments ( "Triage" ) ]
You can’t perform that action at this time.
0 commit comments