Skip to content

Commit b66a5e1

Browse files
authored
Show disk info when hang dump fails (#5404)
1 parent bec3038 commit b66a5e1

15 files changed

+223
-1
lines changed

src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,44 @@ public async Task OnTestHostProcessStartedAsync(ITestHostProcessInformation test
191191
await _logger.LogDebugAsync($"Connected to the test host server pipe '{_namedPipeClient.PipeName}'");
192192

193193
// Keep the custom thread to avoid to waste one from thread pool.
194-
_activityIndicatorTask = _task.RunLongRunning(ActivityTimerAsync, "[HangDump] ActivityTimerAsync", cancellation);
194+
_activityIndicatorTask = _task.RunLongRunning(
195+
async () =>
196+
{
197+
try
198+
{
199+
await ActivityTimerAsync();
200+
}
201+
catch (Exception e)
202+
{
203+
await _outputDisplay.DisplayAsync(this, new ErrorMessageOutputDeviceData(string.Format(CultureInfo.InvariantCulture, ExtensionResources.HangDumpFailed, e.ToString(), GetDiskInfo())));
204+
throw;
205+
}
206+
}, "[HangDump] ActivityTimerAsync", cancellation);
195207
}
196208
catch (OperationCanceledException) when (cancellation.IsCancellationRequested)
197209
{
198210
}
199211
}
200212

213+
private static string GetDiskInfo()
214+
{
215+
var builder = new StringBuilder();
216+
DriveInfo[] allDrives = DriveInfo.GetDrives();
217+
218+
foreach (DriveInfo d in allDrives)
219+
{
220+
builder.AppendLine(CultureInfo.InvariantCulture, $"Drive {d.Name}");
221+
if (d.IsReady)
222+
{
223+
builder.AppendLine(CultureInfo.InvariantCulture, $" Available free space: {d.AvailableFreeSpace} bytes");
224+
builder.AppendLine(CultureInfo.InvariantCulture, $" Total free space: {d.TotalFreeSpace} bytes");
225+
builder.AppendLine(CultureInfo.InvariantCulture, $" Total size: {d.TotalSize} bytes");
226+
}
227+
}
228+
229+
return builder.ToString();
230+
}
231+
201232
public async Task OnTestHostProcessExitedAsync(ITestHostProcessInformation testHostProcessInformation, CancellationToken cancellation)
202233
{
203234
if (cancellation.IsCancellationRequested)

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@
138138
<data name="HangDumpExtensionDisplayName" xml:space="preserve">
139139
<value>Hang dump</value>
140140
</data>
141+
<data name="HangDumpFailed" xml:space="preserve">
142+
<value>The following exception occurred while taking hang dump:
143+
{0}
144+
145+
Disk info:
146+
{1}</value>
147+
<comment>{0} - the exception that occurred.
148+
{1} - disk info detailing free space</comment>
149+
</data>
141150
<data name="HangDumpFileNameOptionDescription" xml:space="preserve">
142151
<value>Specify the name of the dump file</value>
143152
</data>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.cs.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">Výpis paměti při zablokování</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">Zadejte název souboru výpisu paměti.</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.de.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">Absturzspeicherabbild</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">Namen der Speicherabbilddatei angeben</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.es.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">Volcado de memoria</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">Especificar el nombre del archivo de volcado</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.fr.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">Blocage de l’image mémoire</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">Spécifier le nom du fichier de vidage</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.it.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">Dump di blocco</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">Specificare il nome del file di dump</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ja.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">ハング ダンプ</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">ダンプ ファイルの名前を指定する</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ko.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">덤프 중단</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">덤프 파일의 이름 지정</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pl.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">Zrzut zawieszenia</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">Określ nazwę pliku zrzutu</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pt-BR.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">Despejo de travamento</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">Especifique o nome do arquivo de despejo</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ru.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">Дамп зависания</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">Укажите имя файла дампа зависания</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.tr.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">Askı dökümü</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">Döküm dosyasının adını belirtin</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hans.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">挂起转储</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">指定转储文件的名称</target>

src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hant.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@
3737
<target state="translated">擱置傾印</target>
3838
<note />
3939
</trans-unit>
40+
<trans-unit id="HangDumpFailed">
41+
<source>The following exception occurred while taking hang dump:
42+
{0}
43+
44+
Disk info:
45+
{1}</source>
46+
<target state="new">The following exception occurred while taking hang dump:
47+
{0}
48+
49+
Disk info:
50+
{1}</target>
51+
<note>{0} - the exception that occurred.
52+
{1} - disk info detailing free space</note>
53+
</trans-unit>
4054
<trans-unit id="HangDumpFileNameOptionDescription">
4155
<source>Specify the name of the dump file</source>
4256
<target state="translated">指定傾印檔案的名稱</target>

0 commit comments

Comments
 (0)