Skip to content

Commit a742e84

Browse files
authored
Use ntdll instead of sqldk for ordinal tests (#96)
1 parent 360f730 commit a742e84

5 files changed

Lines changed: 28 additions & 24 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
!Target/Release/*.xml
3131
!Target/Release/Tests
3232
- name: Prep for running tests
33-
run: ./downloadsyms.ps1 '${{ secrets.SQLDKDLL_URL }}' '${{ secrets.XESPINS_ZIP_URL }}' '${{ secrets.XEWAIT_URL }}'
33+
run: ./downloadsyms.ps1
3434
working-directory: Tests/TestCases
3535
shell: powershell
3636
- name: Run tests

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ $tf/
8585
UpgradeLog*.XML
8686
UpgradeLog*.htm
8787
Target
88-
/Tests/TestCases/TestOrdinal/sqldk.dll
89-
/Tests/TestCases/TestOrdinal/sqldk.zip
88+
/Tests/TestCases/TestOrdinal/ntdll.dll
89+
/Tests/TestCases/TestOrdinal/ntdll.pdb
9090
/Tests/TestCases/ImportXEL/*.xel
9191
/Tests/TestCases/ImportXEL/*.zip
9292
/Tests/TestCases/SourceInformation/*.zip

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ When you submit a pull request, a CLA bot will automatically determine whether y
4747
* If needed, you may also need to manually obtain the current versions of the following files:
4848
* symsrv.dll and dbghelp.dll (from the x64 / AMD64 Windows Debugger package, part of Windows SDK and many other tools) are used under the terms published [here](https://docs.microsoft.com/en-us/legal/windows-sdk/redist#debugging-tools-for-windows).
4949
* msdia140.dll and msdia140.dll.manifest are components of Visual Studio 2022 used under the terms as published [here](https://docs.microsoft.com/en-us/visualstudio/releases/2022/redistribution).
50-
* Tests are implemented using [MSTest v2](https://docs.microsoft.com/en-us/visualstudio/test/mstest-update-to-mstestv2?view=vs-2022#why-upgrade-to-mstestv2). Please try to ensure that tests are passing before submitting a PR. In order to run tests, you will need to run the Tests\TestCases\downloadsyms.ps1 file to gather pre-requisites. Watch for warnings from the script - there are typically 3 files you will need to gather manually (instructions provided in the PowerShell script).
50+
* Tests are implemented using [MSTest v2](https://docs.microsoft.com/en-us/visualstudio/test/mstest-update-to-mstestv2?view=vs-2022#why-upgrade-to-mstestv2). Please try to ensure that tests are passing before submitting a PR.
51+
* Prior to running tests, you need to execute the [downloadsyms.ps1](./Tests/TestCases/downloadsyms.ps1) file once as shown below:
52+
``` cmd
53+
cd .\SQLCallStackResolver\Tests\TestCases
54+
powershell < .\downloadsyms.ps1
55+
```
56+
Monitor for any warnings shown by the script and address them if needed.
57+
5158
* When a PR is submitted, there is a GitHub Actions workflow which will build the project and run tests. PRs cannot merge till the workflow succeeds.
5259

5360
# Notes

Tests/TestCases/downloadsyms.ps1

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License - see LICENSE file in this repo.
33

4-
param ($sqldkDownloadURL, $spinsXelZipDownloadURL, $waitCompletedXelDownloadUrl)
54
$msdlurl = "https://msdl.microsoft.com/download/symbols/"
65
$ProgressPreference = "SilentlyContinue"
76

@@ -46,26 +45,24 @@ if (-not (test-path $localpath)) {
4645
dir $localpath
4746
}
4847

49-
$localpath = "./TestOrdinal/sqldk.zip"
48+
$localpath = "./TestOrdinal/ntdll.pdb"
5049
if (-not (test-path $localpath)) {
51-
try {
52-
Invoke-WebRequest -UseBasicParsing -uri $sqldkDownloadURL -OutFile $localpath -ErrorAction Ignore
53-
Expand-Archive -Path $localpath -DestinationPath "./TestOrdinal"
54-
dir "./TestOrdinal"
55-
} catch {}
50+
Invoke-WebRequest -UseBasicParsing -uri ($msdlurl + "ntdll.pdb/309B7D2A275C49A1917EC6033A73D0ED1/ntdll.pdb") -OutFile $localpath
51+
dir $localpath
5652
}
5753

58-
$localpath = "./TestOrdinal/sqldk.dll"
59-
if (-not (test-path $localpath)) {
60-
Write-Warning "You must manually download CU14 for SQL 2016 SP1 (KB 4488535) and extract the sqldk.dll from that install to TestOrdinal/sqldk.dll"
54+
$localpath = "./TestOrdinal/ntdll.dll"
55+
if (-not (test-path $localpath)) {
56+
Invoke-WebRequest -UseBasicParsing -uri ($msdlurl + "ntdll.dll/57AE642E1ad000/ntdll.dll") -OutFile $localpath
57+
dir "./TestOrdinal"
6158
}
6259

6360
### ImportXEL
6461
mkdir -Force "./ImportXEL" -ErrorAction Ignore
6562
$localpath = "./ImportXEL/XESpins_0_131627061603030000.xel"
6663
if (-not (test-path $localpath)) {
6764
try {
68-
Invoke-WebRequest -UseBasicParsing -uri $spinsXelZipDownloadURL -OutFile ($localpath + ".zip") -ErrorAction Ignore
65+
Invoke-WebRequest -UseBasicParsing -uri "https://github.com/arvindshmicrosoft/SQLCallStackResolver/raw/main/docs/SQLSat696/Demos/LOCK_HASH/XESpins_0_131627061603030000.zip" -OutFile ($localpath + ".zip") -ErrorAction Ignore
6966
Expand-Archive -Path ($localpath + ".zip") -DestinationPath "./ImportXEL"
7067
}
7168
catch{ }
@@ -79,7 +76,7 @@ if (-not (test-path $localpath)) {
7976
$localpath = "./ImportXEL/xe_wait_completed_0_132353446563350000.xel"
8077
if (-not (test-path $localpath)){
8178
try{
82-
Invoke-WebRequest -UseBasicParsing -uri $waitCompletedXelDownloadUrl -OutFile $localpath -ErrorAction Ignore
79+
Invoke-WebRequest -UseBasicParsing -uri "https://github.com/arvindshmicrosoft/SQLCallStackResolver/raw/main/docs/SQLSat696/Demos/xe_wait_completed_0_132353446563350000.xel" -OutFile $localpath -ErrorAction Ignore
8380
}
8481
catch {}
8582

Tests/Tests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public class Tests {
6262
using var csr = new StackResolver();
6363
using var cts = new CancellationTokenSource();
6464
var dllPaths = new List<string> { Path.GetTempPath(), @"..\..\..\Tests\TestCases\TestOrdinal", Path.GetTempPath() }; // use different paths to validate the multi-path handling
65-
var ret = await csr.ResolveCallstacksAsync(await csr.GetListofCallStacksAsync("sqldk!Ordinal298+00000000000004A5\r\n00007FF818405E70 Module(sqldk+0000000000003505) (Ordinal298 + 00000000000004A5)", false, cts), @"..\..\..\Tests\TestCases\TestOrdinal", false, dllPaths, false, false, false, true, false, false, null, cts);
66-
Assert.AreEqual("sqldk!SOS_Scheduler::SwitchContext+941\r\nsqldk!SOS_Scheduler::SwitchContext+941", ret.Trim());
65+
var ret = await csr.ResolveCallstacksAsync(await csr.GetListofCallStacksAsync("ntdll!Ordinal298+00000000000004A5\r\n00007FF818405E70 Module(ntdll+0000000000091735) (Ordinal298 + 00000000000004A5)", false, cts), @"..\..\..\Tests\TestCases\TestOrdinal", false, dllPaths, false, false, false, true, false, false, null, cts);
66+
Assert.AreEqual("ntdll!NtOpenKeyEx+5\r\nntdll!NtOpenKeyEx+5", ret.Trim());
6767
}
6868

6969
/// Test the resolution of a "regular" symbol with input specifying a hex offset into module.
@@ -720,12 +720,12 @@ private string PrepareLargeXEventInput() {
720720

721721
/// Test for exported symbols
722722
[TestMethod][TestCategory("Unit")] public void ExportedSymbols() {
723-
var ret = ExportedSymbol.GetExports(@"..\..\..\Tests\TestCases\TestOrdinal\sqldk.dll");
724-
Assert.AreEqual(931, ret.Count);
725-
Assert.AreEqual((uint)1095072, ret[15].Address);
726-
Assert.AreEqual((uint)897568, ret[259].Address);
727-
Assert.AreEqual((uint)58752, ret[684].Address);
728-
Assert.AreEqual((uint)1447120, ret[1161].Address);
723+
var ret = ExportedSymbol.GetExports(@"..\..\..\Tests\TestCases\TestOrdinal\ntdll.dll");
724+
Assert.AreEqual(2183, ret.Count);
725+
Assert.AreEqual((uint)0xd14c0, ret[15].Address);
726+
Assert.AreEqual((uint)0x90b30, ret[259].Address);
727+
Assert.AreEqual((uint)0x74110, ret[684].Address);
728+
Assert.AreEqual((uint)0x19db0, ret[1161].Address);
729729
}
730730

731731
[TestMethod][TestCategory("Unit")] public async Task IsUrlValid() {

0 commit comments

Comments
 (0)