From 4ccac53e9f4a61ca16e5505243c743c50d17662b Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sat, 5 Aug 2023 13:47:11 -0700 Subject: [PATCH] X64EmitterTest: Check bytes instead of disassembly in JMP test Check bytes directly to avoid ambiguity in the disassembly between short and near jumps, which could hypothetically cause the test to pass when it shouldn't. --- Source/UnitTests/Common/x64EmitterTest.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Source/UnitTests/Common/x64EmitterTest.cpp b/Source/UnitTests/Common/x64EmitterTest.cpp index b435a6fdb2..7c5b010ae5 100644 --- a/Source/UnitTests/Common/x64EmitterTest.cpp +++ b/Source/UnitTests/Common/x64EmitterTest.cpp @@ -297,15 +297,13 @@ TEST_F(x64EmitterTest, POP_Register) TEST_F(x64EmitterTest, JMP) { - emitter->NOP(6); - emitter->JMP(code_buffer); - ExpectDisassembly("multibyte nop " - "jmp .-8"); + emitter->NOP(1); + emitter->JMP(code_buffer, XEmitter::Jump::Short); + ExpectBytes({/* nop */ 0x90, /* short jmp */ 0xeb, /* offset -3 */ 0xfd}); - emitter->NOP(6); + emitter->NOP(1); emitter->JMP(code_buffer, XEmitter::Jump::Near); - ExpectDisassembly("multibyte nop " - "jmp .-11"); + ExpectBytes({/* nop */ 0x90, /* near jmp */ 0xe9, /* offset -6 */ 0xfa, 0xff, 0xff, 0xff}); } TEST_F(x64EmitterTest, JMPptr_Register)