Skip to content

Commit 5ad163a

Browse files
Copilotbrianrob
andcommitted
Fix test issues: Move PrepareTestData to individual tests and debug HTTP test
Co-authored-by: brianrob <[email protected]>
1 parent 324c3bd commit 5ad163a

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

src/TraceEvent/TraceEvent.Tests/Symbols/SymbolReaderTests.cs

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ public SymbolReaderTests(ITestOutputHelper output)
3636
{
3737
_handler = new InterceptingHandler();
3838
_symbolReader = new SymbolReader(TextWriter.Null, nt_symbol_path: null, httpClientDelegatingHandler: _handler);
39-
PrepareTestData();
4039
}
4140

4241

4342
[Fact]
4443
public void NativeCppPdbHasValidSourceInfo()
4544
{
45+
PrepareTestData();
4646
var pdbFile = _symbolReader.OpenNativeSymbolFile(Path.Combine(s_inputPdbDir, FileName_CppConPdb));
4747
using (pdbFile as IDisposable)
4848
{
@@ -65,6 +65,7 @@ public void NativeCppPdbHasValidSourceInfo()
6565
[Fact]
6666
public void ManagedWinPdbHasValidSourceInfo1()
6767
{
68+
PrepareTestData();
6869
var pdbFile = _symbolReader.OpenSymbolFile(Path.Combine(s_inputPdbDir, "CsDesktopProj.pdb"));
6970
using (pdbFile as IDisposable)
7071
{
@@ -88,6 +89,7 @@ public void ManagedWinPdbHasValidSourceInfo1()
8889
[Fact]
8990
public void ManagedWinPdbHasValidSourceInfo2()
9091
{
92+
PrepareTestData();
9193
var pdbFile = _symbolReader.OpenSymbolFile(Path.Combine(s_inputPdbDir, FileName_CsDesktopPdbWithSourceLink));
9294
using (pdbFile as IDisposable)
9395
{
@@ -113,6 +115,7 @@ public void ManagedWinPdbHasValidSourceInfo2()
113115
[Fact]
114116
public void PortablePdbHasValidSourceInfo()
115117
{
118+
PrepareTestData();
116119
var pdbFile = _symbolReader.OpenSymbolFile(Path.Combine(s_inputPdbDir, FileName_CsPortablePdb1));
117120
using (pdbFile as IDisposable)
118121
{
@@ -138,6 +141,7 @@ public void PortablePdbHasValidSourceInfo()
138141
[Fact]
139142
public void SourceLinkUrlsAreEscaped()
140143
{
144+
PrepareTestData();
141145
var pdbFile = _symbolReader.OpenSymbolFile(Path.Combine(s_inputPdbDir, FileName_CsPortablePdbEscapeSourceLink));
142146
using (pdbFile as IDisposable)
143147
{
@@ -168,6 +172,7 @@ public void SourceLinkUrlsAreEscaped()
168172
[InlineData(FileName_CppConPdb, 4096)]
169173
public void ChecksumMatchAllowsAlternateLineEndings(string pdbName, uint metadataTokenOrRva)
170174
{
175+
PrepareTestData();
171176
var pdbFile = _symbolReader.OpenSymbolFile(Path.Combine(s_inputPdbDir, pdbName));
172177
using (pdbFile as IDisposable)
173178
{
@@ -232,6 +237,7 @@ public void ChecksumMatchAllowsAlternateLineEndings(string pdbName, uint metadat
232237
[InlineData(0x06000001 /*Test.get_X*/, "int X=>0;")]
233238
public void EmbeddedSourceCanBeLoaded(uint methodToken, string expectedSubstring)
234239
{
240+
PrepareTestData();
235241
string pdbName = FileName_CsPortableEmbeddedSource;
236242
var pdbFile = _symbolReader.OpenSymbolFile(Path.Combine(s_inputPdbDir, pdbName));
237243
using (pdbFile as IDisposable)
@@ -300,6 +306,7 @@ private static string ReadAllTextIncludingBOM(string path)
300306
[InlineData(FileName_CsPortablePdb1)]
301307
public void PdbFileLockingIsCorrect(string pdbFileName)
302308
{
309+
PrepareTestData();
303310
const int E_WIN32_ERROR_SHARING_VIOLATION = -2147024864;
304311

305312
string tempPdbPath = Path.Combine(Path.GetTempPath(), pdbFileName);
@@ -469,23 +476,37 @@ public void HttpRequestIncludesMsfzAcceptHeader()
469476
});
470477

471478
// This will trigger an HTTP request that should include the Accept header
472-
var method = typeof(SymbolReader).GetMethod("GetPhysicalFileFromServer",
479+
var method = typeof(SymbolReader).GetMethod("GetFileFromServer",
473480
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
474481

475-
var result = (bool)method.Invoke(_symbolReader, new object[] {
482+
Assert.NotNull(method);
483+
484+
var result = (string)method.Invoke(_symbolReader, new object[] {
476485
"https://test.example.com",
477486
"test.pdb",
478-
targetPath,
479-
null
487+
targetPath
480488
});
481489

482-
// Verify that the download was successful
483-
Assert.True(result, "GetPhysicalFileFromServer should succeed with MSFZ content");
490+
// Debug: Check what actually happened
491+
Output.WriteLine($"Result: {result}");
492+
Output.WriteLine($"Target path exists: {File.Exists(targetPath)}");
493+
var msfzDir = Path.Combine(Path.GetDirectoryName(targetPath), "msfz0");
494+
Output.WriteLine($"MSFZ dir exists: {Directory.Exists(msfzDir)}");
495+
if (Directory.Exists(msfzDir))
496+
{
497+
var msfzFile = Path.Combine(msfzDir, Path.GetFileName(targetPath));
498+
Output.WriteLine($"MSFZ file exists: {File.Exists(msfzFile)}");
499+
}
500+
501+
// Verify that the download was successful and returned the MSFZ path
502+
Assert.NotNull(result);
503+
Assert.Contains("msfz0", result);
484504

485505
// The file should have been moved to msfz0 subdirectory since it's an MSFZ file
486-
var msfzPath = Path.Combine(Path.GetDirectoryName(targetPath), "msfz0", Path.GetFileName(targetPath));
487-
Assert.True(File.Exists(msfzPath), "MSFZ file should be moved to msfz0 subdirectory");
506+
var expectedMsfzPath = Path.Combine(Path.GetDirectoryName(targetPath), "msfz0", Path.GetFileName(targetPath));
507+
Assert.True(File.Exists(expectedMsfzPath), "MSFZ file should be moved to msfz0 subdirectory");
488508
Assert.False(File.Exists(targetPath), "Original file should not exist after move");
509+
Assert.Equal(expectedMsfzPath, result);
489510
}
490511
finally
491512
{

0 commit comments

Comments
 (0)