diff options
author | David Schleef <ds@schleef.org> | 2009-05-24 15:55:06 -0700 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2009-05-24 15:55:06 -0700 |
commit | 534dbcd277be736414af37590d4af4e3dfe70575 (patch) | |
tree | 9a1d0bd1fc8f7df7983901f54f487201483d7fe2 /testsuite/compile_opcodes_sys_c.c | |
parent | 4fac67acd462c4b994a405448e6c2abf6875cfcb (diff) | |
download | orc-534dbcd277be736414af37590d4af4e3dfe70575.tar.gz |
tests: fix up tests for new api
Diffstat (limited to 'testsuite/compile_opcodes_sys_c.c')
-rw-r--r-- | testsuite/compile_opcodes_sys_c.c | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/testsuite/compile_opcodes_sys_c.c b/testsuite/compile_opcodes_sys_c.c new file mode 100644 index 0000000..f109eef --- /dev/null +++ b/testsuite/compile_opcodes_sys_c.c @@ -0,0 +1,106 @@ + +#include "config.h" + +#include <stdio.h> + +#include <orc/orc.h> +#include <orc-test/orctest.h> + + +int error = FALSE; +int verbose = FALSE; + +void test_opcode (OrcStaticOpcode *opcode); +void test_opcode_const (OrcStaticOpcode *opcode); +void test_opcode_param (OrcStaticOpcode *opcode); + +int +main (int argc, char *argv[]) +{ + int i; + OrcOpcodeSet *opcode_set; + + orc_init(); + orc_test_init(); + + opcode_set = orc_opcode_set_get ("sys"); + + for(i=0;i<opcode_set->n_opcodes;i++){ + if (verbose) printf("/* %s %d,%d,%d %p */\n", + opcode_set->opcodes[i].name, + opcode_set->opcodes[i].dest_size[0], + opcode_set->opcodes[i].src_size[0], + opcode_set->opcodes[i].src_size[1], + opcode_set->opcodes[i].emulate); + test_opcode (opcode_set->opcodes + i); + } + + if (error) { + printf("test failed\n"); + return 1; + } else { + printf("test passed\n"); + return 0; + } +} + +void +test_opcode (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + OrcCompileResult result; + + p = orc_test_get_program_for_opcode (opcode); + if (!p) return; + + result = orc_program_compile_for_target (p, orc_target_get_by_name("c")); + if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { + printf("%s", orc_program_get_asm_code (p)); + error = TRUE; + return; + } + + orc_program_free (p); +} + +void +test_opcode_const (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + OrcCompileResult result; + + p = orc_test_get_program_for_opcode_const (opcode); + if (!p) return; + + result = orc_program_compile_for_target (p, orc_target_get_by_name("c")); + if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { + printf("%s", orc_program_get_asm_code (p)); + error = TRUE; + return; + } + + orc_program_free (p); +} + +void +test_opcode_param (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + OrcCompileResult result; + + p = orc_test_get_program_for_opcode_param (opcode); + if (!p) return; + + result = orc_program_compile_for_target (p, orc_target_get_by_name("c")); + if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { + printf("%s", orc_program_get_asm_code (p)); + error = TRUE; + return; + } + + orc_program_free (p); +} + + + + |