diff --git a/spec/lib/rex/arch/x86_spec.rb b/spec/lib/rex/arch/x86_spec.rb index ac40e94..edac06d 100644 --- a/spec/lib/rex/arch/x86_spec.rb +++ b/spec/lib/rex/arch/x86_spec.rb @@ -1039,4 +1039,45 @@ end end + describe ".register_names_to_ids" do + subject { described_class.register_names_to_ids(registers) } + + context "when registers are not provided" do + let(:registers) { nil } + + it "returns an empty Array" do + is_expected.to be_an Array + is_expected.to be_empty + end + end + + context "when registers are invalid" do + let(:registers) { "not-a-register" } + + it "raises an error" do + expect { subject }.to raise_error(NameError) + end + end + + context "when registers are valid" do + let(:registers) { " eax, ecx, edx, ebx, esp, ebp, esi, edi " } + + it "returns an Array" do + is_expected.to be_an Array + end + + it "returns an Integer for each register" do + expect(subject.length).to eq(8) + expect(subject[0]).to be_an Integer + expect(subject[1]).to be_an Integer + expect(subject[2]).to be_an Integer + expect(subject[3]).to be_an Integer + expect(subject[4]).to be_an Integer + expect(subject[5]).to be_an Integer + expect(subject[6]).to be_an Integer + expect(subject[7]).to be_an Integer + end + end + end + end diff --git a/spec/lib/rex/arch_spec.rb b/spec/lib/rex/arch_spec.rb index cccf235..461e7eb 100644 --- a/spec/lib/rex/arch_spec.rb +++ b/spec/lib/rex/arch_spec.rb @@ -118,6 +118,14 @@ end end + context "when arch is ARCH_PPCE500V2" do + let(:arch) { Rex::Arch::ARCH_PPCE500V2 } + let(:addr) { 0x41424344 } + it "packs addr as 32-bit unsigned, big-endian" do + is_expected.to eq("ABCD") + end + end + context "when arch is ARCH_SPARC" do let(:arch) { Rex::Arch::ARCH_SPARC } let(:addr) { 0x41424344 } @@ -230,13 +238,17 @@ { Rex::Arch::ARCH_X86 => Rex::Arch::ENDIAN_LITTLE, Rex::Arch::ARCH_X86_64 => Rex::Arch::ENDIAN_LITTLE, + Rex::Arch::ARCH_X64 => Rex::Arch::ENDIAN_LITTLE, Rex::Arch::ARCH_MIPS => Rex::Arch::ENDIAN_BIG, Rex::Arch::ARCH_MIPSLE => Rex::Arch::ENDIAN_LITTLE, Rex::Arch::ARCH_MIPSBE => Rex::Arch::ENDIAN_BIG, Rex::Arch::ARCH_MIPS64 => Rex::Arch::ENDIAN_BIG, + Rex::Arch::ARCH_MIPS64LE => Rex::Arch::ENDIAN_LITTLE, Rex::Arch::ARCH_PPC => Rex::Arch::ENDIAN_BIG, Rex::Arch::ARCH_PPC64LE => Rex::Arch::ENDIAN_LITTLE, + Rex::Arch::ARCH_PPCE500V2 => Rex::Arch::ENDIAN_BIG, Rex::Arch::ARCH_SPARC => Rex::Arch::ENDIAN_BIG, + Rex::Arch::ARCH_SPARC64 => Rex::Arch::ENDIAN_BIG, Rex::Arch::ARCH_ARMLE => Rex::Arch::ENDIAN_LITTLE, Rex::Arch::ARCH_ARMBE => Rex::Arch::ENDIAN_BIG, Rex::Arch::ARCH_AARCH64 => Rex::Arch::ENDIAN_LITTLE, @@ -245,6 +257,7 @@ Rex::Arch::ARCH_RISCV64BE => Rex::Arch::ENDIAN_BIG, Rex::Arch::ARCH_RISCV64LE => Rex::Arch::ENDIAN_LITTLE, Rex::Arch::ARCH_LOONGARCH64 => Rex::Arch::ENDIAN_LITTLE, + Rex::Arch::ARCH_ZARCH => Rex::Arch::ENDIAN_BIG, } end subject { described_class.endian(arch) }