Skip to content

Commit

Permalink
Fix java binding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danghvu committed Sep 27, 2014
1 parent 6dc1dd5 commit 53bbee3
Show file tree
Hide file tree
Showing 7 changed files with 416 additions and 8 deletions.
10 changes: 7 additions & 3 deletions bindings/java/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ else
endif

CAPSTONE_JAVA = Capstone.java Arm_const.java Arm64_const.java Mips_const.java \
X86_const.java Ppc_const.java Sparc_const.java Sysz_const.java \
Arm.java Arm64.java Mips.java X86.java Ppc.java Sparc.java Systemz.java
X86_const.java Xcore_const.java Ppc_const.java Sparc_const.java\
Sysz_const.java \
Arm.java Arm64.java Mips.java X86.java Xcore.java Ppc.java\
Sparc.java Systemz.java

all: gen_const capstone tests

Expand All @@ -40,7 +42,9 @@ endif

tests: jna
@mkdir -p $(OBJDIR)
javac -d $(OBJDIR) -classpath "$(JNA):$(BLDIR)/capstone.jar" Test.java TestArm.java TestArm64.java TestMips.java TestX86.java TestPpc.java TestSparc.java TestSystemz.java
javac -d $(OBJDIR) -classpath "$(JNA):$(BLDIR)/capstone.jar" Test.java\
TestArm.java TestArm64.java TestMips.java TestX86.java TestXcore.java\
TestPpc.java TestSparc.java TestSystemz.java

gen_const:
cd ../ && python const_generator.py java
Expand Down
2 changes: 1 addition & 1 deletion bindings/java/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static public String stringToHex(byte[] code) {
public static final byte[] SPARC_CODE = new byte[] { (byte)0x80, (byte)0xa0, (byte)0x40, (byte)0x02, (byte)0x85, (byte)0xc2, (byte)0x60, (byte)0x08, (byte)0x85, (byte)0xe8, (byte)0x20, (byte)0x01, (byte)0x81, (byte)0xe8, (byte)0x00, (byte)0x00, (byte)0x90, (byte)0x10, (byte)0x20, (byte)0x01, (byte)0xd5, (byte)0xf6, (byte)0x10, (byte)0x16, (byte)0x21, (byte)0x00, (byte)0x00, (byte)0x0a, (byte)0x86, (byte)0x00, (byte)0x40, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x12, (byte)0xbf, (byte)0xff, (byte)0xff, (byte)0x10, (byte)0xbf, (byte)0xff, (byte)0xff, (byte)0xa0, (byte)0x02, (byte)0x00, (byte)0x09, (byte)0x0d, (byte)0xbf, (byte)0xff, (byte)0xff, (byte)0xd4, (byte)0x20, (byte)0x60, (byte)0x00, (byte)0xd4, (byte)0x4e, (byte)0x00, (byte)0x16, (byte)0x2a, (byte)0xc2, (byte)0x80, (byte)0x03 };
public static final byte[] SYSZ_CODE = new byte[] { (byte)0xed, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x1a, (byte)0x5a, (byte)0x0f, (byte)0x1f, (byte)0xff, (byte)0xc2, (byte)0x09, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x07, (byte)0xf7, (byte)0xeb, (byte)0x2a, (byte)0xff, (byte)0xff, (byte)0x7f, (byte)0x57, (byte)0xe3, (byte)0x01, (byte)0xff, (byte)0xff, (byte)0x7f, (byte)0x57, (byte)0xeb, (byte)0x00, (byte)0xf0, (byte)0x00, (byte)0x00, (byte)0x24, (byte)0xb2, (byte)0x4f, (byte)0x00, (byte)0x78 };
public static final byte[] SPARCV9_CODE = new byte[] { (byte)0x81, (byte)0xa8, (byte)0x0a, (byte)0x24, (byte)0x89, (byte)0xa0, (byte)0x10, (byte)0x20, (byte)0x89, (byte)0xa0, (byte)0x1a, (byte)0x60, (byte)0x89, (byte)0xa0, (byte)0x00, (byte)0xe0 };
public static final byte[] XCORE_CODE = new byte[] { (byte)0xfe, (byte)0x0f, (byte)0xfe, (byte)0x17, (byte)0x13, (byte)0x17, (byte)0xc6, (byte)0xfe, (byte)0xec, (byte)0x17, (byte)0x97, (byte)0xf8, (byte)0xec, (byte)0x4f, (byte)0x1f, (byte)0xfd, (byte)0xec, (byte)0x37, (byte)0x0f, (byte)0xf2, (byte)0x45, (byte)0x5b, (byte)0xf9, (byte)0xfa, (byte)0x02, (byte)0x06, (byte)0x1b, (byte)0x10 };
public static final byte[] XCORE_CODE = new byte[] { (byte)0xfe, (byte)0x0f, (byte)0xfe, (byte)0x17, (byte)0x13, (byte)0x17, (byte)0xc6, (byte)0xfe, (byte)0xec, (byte)0x17, (byte)0x97, (byte)0xf8, (byte)0xec, (byte)0x4f, (byte)0x1f, (byte)0xfd, (byte)0xec, (byte)0x37, (byte)0x07, (byte)0xf2, (byte)0x45, (byte)0x5b, (byte)0xf9, (byte)0xfa, (byte)0x02, (byte)0x06, (byte)0x1b, (byte)0x10 };

static public void main(String argv[]) {
platform[] platforms = {
Expand Down
4 changes: 2 additions & 2 deletions bindings/java/TestX86.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public static void print_ins_detail(Capstone.CsInsn ins) {
// print SIB byte
System.out.printf("\tsib: 0x%x\n", operands.sib);
if (operands.sib != 0)
System.out.printf("\tsib_index: %s, sib_scale: %d, sib_base: %s\n",
ins.regName(operands.sibIndex), operands.sibScale, ins.regName(operands.sibBase));
System.out.printf("\t\tsib_base: %s\n\t\tsib_index: %s\n\t\tsib_scale: %d\n",
ins.regName(operands.sibBase), ins.regName(operands.sibIndex), operands.sibScale);
}

if (operands.sseCC != 0)
Expand Down
2 changes: 1 addition & 1 deletion bindings/java/TestXcore.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void print_ins_detail(Capstone.CsInsn ins) {
public static void main(String argv[]) {

final Test.platform[] all_tests = {
new Test.platform(Capstone.CS_ARCH_XCORE, Capstone.CS_MODE_BIG_ENDIAN, hexString2Byte(XCORE_CODE), "Xcore"),
new Test.platform(Capstone.CS_ARCH_XCORE, Capstone.CS_MODE_BIG_ENDIAN, hexString2Byte(XCORE_CODE), "XCore"),
};

for (int i=0; i<all_tests.length; i++) {
Expand Down
3 changes: 2 additions & 1 deletion bindings/java/capstone/Capstone.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ public CsInsn[] disasm(byte[] code, long address, long count) {
CsInsn[] allInsn = fromArrayRaw((_cs_insn[]) byref.toArray(c.intValue()));

// free allocated memory
cs.cs_free(p, c);
// cs.cs_free(p, c);
// FIXME(danghvu): Can't free because memory is still inside CsInsn

return allInsn;
}
Expand Down
Loading

0 comments on commit 53bbee3

Please sign in to comment.