Initial Commit
This commit is contained in:
33 files changed
+7500
No files matched your search
@@ -0,0 +1,52 @@
|
||||
# Tests of the hashes a PDB file finds names and records by, against the values
|
||||
# Microsoft's algorithms give, and of the digest naming a file.
|
||||
import std;
|
||||
import binary::pdb;
|
||||
import std::testing;
|
||||
|
||||
|
||||
@test def names_hash_as_microsofts_tools_hash_them(t: &mut tester): void {
|
||||
# Words, then a half word, then a byte, cases made alike.
|
||||
t.expects(pdb::hash_v1("") == 0x20240400);
|
||||
t.expects(pdb::hash_v1("a") == 0x20240441);
|
||||
t.expects(pdb::hash_v1("ab") == 0x20244649);
|
||||
t.expects(pdb::hash_v1("abc") == 0x2024460A);
|
||||
t.expects(pdb::hash_v1("abcd") == 0x646F8A62);
|
||||
t.expects(pdb::hash_v1("abcde") == 0x646F8A27);
|
||||
t.expects(pdb::hash_v1("/names") == 0x6D6CFC21);
|
||||
t.expects(pdb::hash_v1("main") == 0x6E64C225);
|
||||
t.expects(pdb::hash_v1("MAIN") == pdb::hash_v1("main"));
|
||||
}
|
||||
|
||||
@test def records_hash_by_crc_begun_at_zero(t: &mut tester): void {
|
||||
t.expects(pdb::hash_record("123456789") == 0x2DFD2D88);
|
||||
t.expects(pdb::hash_record("") == 0);
|
||||
}
|
||||
|
||||
@test def files_are_named_by_their_md5(t: &mut tester): void {
|
||||
val digest := pdb::md5_of("abc");
|
||||
val expected: u8[16] = [0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72];
|
||||
var same := true;
|
||||
for k in 0..16u {
|
||||
same = same && digest[k] == expected[k];
|
||||
}
|
||||
t.expects(same);
|
||||
val empty := pdb::md5_of("");
|
||||
t.expects(empty[0] == 0xd4 && empty[15] == 0x7e); # d41d8cd98f00b204e9800998ecf8427e
|
||||
}
|
||||
|
||||
@test def registers_are_numbered_as_codeview_numbers_them(t: &mut tester): void {
|
||||
t.expects(pdb::amd64_register(0, 8) == 328); # rax
|
||||
t.expects(pdb::amd64_register(3, 8) == 329); # rbx
|
||||
t.expects(pdb::amd64_register(5, 8) == 334); # rbp
|
||||
t.expects(pdb::amd64_register(6, 8) == 332); # rsi
|
||||
t.expects(pdb::amd64_register(15, 8) == 343); # r15
|
||||
t.expects(pdb::amd64_register(1, 4) == 18); # ecx
|
||||
t.expects(pdb::amd64_register(9, 4) == 361); # r9d
|
||||
t.expects(pdb::amd64_register(2, 2) == 11); # dx
|
||||
t.expects(pdb::amd64_register(7, 1) == 325); # dil
|
||||
t.expects(pdb::amd64_register(12, 1) == 348); # r12b
|
||||
t.expects(pdb::amd64_xmm(0) == 154);
|
||||
t.expects(pdb::amd64_xmm(7) == 161);
|
||||
t.expects(pdb::amd64_xmm(8) == 252);
|
||||
}
|
||||
Reference in new issue
Block a user