mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-05-19 03:41:18 +03:00
Added CSV test files for various instruction types and enabled comments in CSV files
This commit is contained in:
parent
3f4b9a8547
commit
d1d52af511
@ -12,6 +12,11 @@ public class RawFromFileDisassemblyTests(ITestOutputHelper output)
|
||||
[Theory]
|
||||
[InlineData("pushreg_tests.csv")]
|
||||
[InlineData("popreg_tests.csv")]
|
||||
[InlineData("pushimm_tests.csv")]
|
||||
[InlineData("nop_tests.csv")]
|
||||
[InlineData("xchg_tests.csv")]
|
||||
[InlineData("sub_tests.csv")]
|
||||
[InlineData("segment_override_tests.csv")]
|
||||
public void RunTests(string file)
|
||||
{
|
||||
// Load the CSV test file from embedded resources
|
||||
@ -28,7 +33,10 @@ public class RawFromFileDisassemblyTests(ITestOutputHelper output)
|
||||
{
|
||||
HasHeaderRecord = true,
|
||||
Delimiter = ";",
|
||||
BadDataFound = null // Ignore bad data
|
||||
BadDataFound = null, // Ignore bad data
|
||||
AllowComments = true, // Enable comments in CSV files
|
||||
Comment = '#', // Use # as the comment character
|
||||
IgnoreBlankLines = true // Skip empty lines
|
||||
};
|
||||
|
||||
using var streamReader = new StreamReader(stream);
|
||||
|
2
X86DisassemblerTests/TestData/nop_tests.csv
Normal file
2
X86DisassemblerTests/TestData/nop_tests.csv
Normal file
@ -0,0 +1,2 @@
|
||||
RawBytes;Instructions
|
||||
90;[{ "Mnemonic": "nop", "Operands": "" }]
|
Can't render this file because it contains an unexpected character in line 2 and column 7.
|
3
X86DisassemblerTests/TestData/pushimm_tests.csv
Normal file
3
X86DisassemblerTests/TestData/pushimm_tests.csv
Normal file
@ -0,0 +1,3 @@
|
||||
RawBytes;Instructions
|
||||
6810000000;[{ "Mnemonic": "push", "Operands": "0x00000010" }]
|
||||
6A10;[{ "Mnemonic": "push", "Operands": "0x10" }]
|
Can't render this file because it contains an unexpected character in line 2 and column 15.
|
7
X86DisassemblerTests/TestData/segment_override_tests.csv
Normal file
7
X86DisassemblerTests/TestData/segment_override_tests.csv
Normal file
@ -0,0 +1,7 @@
|
||||
RawBytes;Instructions
|
||||
26FF7510;[{ "Mnemonic": "push", "Operands": "dword ptr es:[ebp+0x10]" }]
|
||||
2EFF7510;[{ "Mnemonic": "push", "Operands": "dword ptr cs:[ebp+0x10]" }]
|
||||
36FF7510;[{ "Mnemonic": "push", "Operands": "dword ptr ss:[ebp+0x10]" }]
|
||||
3EFF7510;[{ "Mnemonic": "push", "Operands": "dword ptr ds:[ebp+0x10]" }]
|
||||
64FF7510;[{ "Mnemonic": "push", "Operands": "dword ptr fs:[ebp+0x10]" }]
|
||||
65FF7510;[{ "Mnemonic": "push", "Operands": "dword ptr gs:[ebp+0x10]" }]
|
Can't render this file because it contains an unexpected character in line 2 and column 13.
|
25
X86DisassemblerTests/TestData/sub_tests.csv
Normal file
25
X86DisassemblerTests/TestData/sub_tests.csv
Normal file
@ -0,0 +1,25 @@
|
||||
# SUB instruction tests
|
||||
# Format: RawBytes;Instructions
|
||||
RawBytes;Instructions
|
||||
|
||||
# Register-to-register SUB
|
||||
29D8;[{ "Mnemonic": "sub", "Operands": "eax, ebx" }]
|
||||
|
||||
# Register-to-memory SUB
|
||||
294B10;[{ "Mnemonic": "sub", "Operands": "dword ptr [ebx+0x10], ecx" }]
|
||||
|
||||
# Memory-to-register SUB
|
||||
2BD8;[{ "Mnemonic": "sub", "Operands": "ebx, eax" }]
|
||||
2B4B10;[{ "Mnemonic": "sub", "Operands": "ecx, dword ptr [ebx+0x10]" }]
|
||||
|
||||
# Immediate-to-register SUB (32-bit immediate)
|
||||
81E878563412;[{ "Mnemonic": "sub", "Operands": "eax, 0x12345678" }]
|
||||
|
||||
# Immediate-to-memory SUB (32-bit immediate)
|
||||
816B1078563412;[{ "Mnemonic": "sub", "Operands": "dword ptr [ebx+0x10], 0x12345678" }]
|
||||
|
||||
# Small immediate SUB (8-bit immediate)
|
||||
83E842;[{ "Mnemonic": "sub", "Operands": "eax, 0x42" }]
|
||||
|
||||
# Sign-extended immediate SUB (8-bit immediate sign-extended to 32-bit)
|
||||
83E8F0;[{ "Mnemonic": "sub", "Operands": "eax, 0xFFFFFFF0" }]
|
Can't render this file because it contains an unexpected character in line 6 and column 9.
|
8
X86DisassemblerTests/TestData/xchg_tests.csv
Normal file
8
X86DisassemblerTests/TestData/xchg_tests.csv
Normal file
@ -0,0 +1,8 @@
|
||||
RawBytes;Instructions
|
||||
91;[{ "Mnemonic": "xchg", "Operands": "eax, ecx" }]
|
||||
92;[{ "Mnemonic": "xchg", "Operands": "eax, edx" }]
|
||||
93;[{ "Mnemonic": "xchg", "Operands": "eax, ebx" }]
|
||||
94;[{ "Mnemonic": "xchg", "Operands": "eax, esp" }]
|
||||
95;[{ "Mnemonic": "xchg", "Operands": "eax, ebp" }]
|
||||
96;[{ "Mnemonic": "xchg", "Operands": "eax, esi" }]
|
||||
97;[{ "Mnemonic": "xchg", "Operands": "eax, edi" }]
|
Can't render this file because it contains an unexpected character in line 2 and column 7.
|
@ -30,9 +30,11 @@
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestData\popreg_tests.csv" />
|
||||
<EmbeddedResource Include="TestData\pushreg_tests.csv" />
|
||||
<None Remove="instruction_test.json" />
|
||||
<EmbeddedResource Include="instruction_test.json" />
|
||||
<None Remove="PushTests\push_tests.csv" />
|
||||
<EmbeddedResource Include="TestData\pushimm_tests.csv" />
|
||||
<EmbeddedResource Include="TestData\nop_tests.csv" />
|
||||
<EmbeddedResource Include="TestData\xchg_tests.csv" />
|
||||
<EmbeddedResource Include="TestData\sub_tests.csv" />
|
||||
<EmbeddedResource Include="TestData\segment_override_tests.csv" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,253 +0,0 @@
|
||||
[
|
||||
{
|
||||
"RawBytes": "6810000000",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "push",
|
||||
"Operands": "0x00000010"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "6A10",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "push",
|
||||
"Operands": "0x10"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "90",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "nop",
|
||||
"Operands": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "91",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "xchg",
|
||||
"Operands": "eax, ecx"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "92",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "xchg",
|
||||
"Operands": "eax, edx"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "93",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "xchg",
|
||||
"Operands": "eax, ebx"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "94",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "xchg",
|
||||
"Operands": "eax, esp"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "95",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "xchg",
|
||||
"Operands": "eax, ebp"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "96",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "xchg",
|
||||
"Operands": "eax, esi"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "97",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "xchg",
|
||||
"Operands": "eax, edi"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "29D8",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "eax, ebx"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "294B10",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "dword ptr [ebx+0x10], ecx"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "2BD8",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "ebx, eax"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "2B4B10",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "ecx, dword ptr [ebx+0x10]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "81E878563412",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "eax, 0x12345678"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "816B1078563412",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "dword ptr [ebx+0x10], 0x12345678"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "83E842",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "eax, 0x42"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "83E8F0",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "eax, 0xFFFFFFF0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "836B1042",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "dword ptr [ebx+0x10], 0x42"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "83EC10",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "esp, 0x10"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "83EC1029D82B4DFC",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "esp, 0x10"
|
||||
},
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "eax, ebx"
|
||||
},
|
||||
{
|
||||
"Mnemonic": "sub",
|
||||
"Operands": "ecx, dword ptr [ebp-0x04]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "26FF7510",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "push",
|
||||
"Operands": "dword ptr es:[ebp+0x10]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "2EFF7510",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "push",
|
||||
"Operands": "dword ptr cs:[ebp+0x10]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "36FF7510",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "push",
|
||||
"Operands": "dword ptr ss:[ebp+0x10]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "3EFF7510",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "push",
|
||||
"Operands": "dword ptr ds:[ebp+0x10]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "64FF7510",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "push",
|
||||
"Operands": "dword ptr fs:[ebp+0x10]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"RawBytes": "65FF7510",
|
||||
"Disassembled": [
|
||||
{
|
||||
"Mnemonic": "push",
|
||||
"Operands": "dword ptr gs:[ebp+0x10]"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user