From: David Schleef Date: Wed, 1 Apr 2009 18:47:46 +0000 (-0700) Subject: Add another test X-Git-Tag: orc-0.4.0~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=28100ba8d952a0a67298689a6ad5bff76fa1c25d;p=platform%2Fupstream%2Forc.git Add another test --- diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 7b33bfe..ade3650 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -1,7 +1,7 @@ -TESTS = test1 test2 test3 test4 test5 test_local_opcode_execution +TESTS = test1 test2 test3 test4 test5 test_local_opcode_execution test_compile -orcbin_PROGRAMS = test1 test2 test3 test4 test5 test_local_opcode_execution +orcbin_PROGRAMS = test1 test2 test3 test4 test5 test_local_opcode_execution test_compile AM_CFLAGS = $(ORC_CFLAGS) LIBS = $(ORC_LIBS) $(top_builddir)/orc-test/liborc-test-0.3.la diff --git a/testsuite/test_compile.c b/testsuite/test_compile.c new file mode 100644 index 0000000..75b6386 --- /dev/null +++ b/testsuite/test_compile.c @@ -0,0 +1,128 @@ + +#include "config.h" + +#include +#include + +#include +#include + + +int error = 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;in_opcodes;i++){ + 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); + } + for(i=0;in_opcodes;i++){ + printf("/* %s const %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_const (opcode_set->opcodes + i); + } + for(i=0;in_opcodes;i++){ + printf("/* %s param %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_param (opcode_set->opcodes + i); + } + + if (error) return 1; + return 0; +} + +void +test_opcode (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + char s[40]; + + if (opcode->src_size[1] == 0) { + p = orc_program_new_ds (opcode->dest_size[0], opcode->src_size[0]); + } else { + p = orc_program_new_dss (opcode->dest_size[0], opcode->src_size[0], + opcode->src_size[1]); + } + + sprintf(s, "test_%s", opcode->name); + orc_program_set_name (p, s); + + orc_program_append_str (p, opcode->name, "d1", "s1", "s2"); + + orc_test_gcc_compile (p); + + orc_program_free (p); +} + +void +test_opcode_const (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + char s[40]; + + if (opcode->src_size[1] == 0) return; + + p = orc_program_new_ds (opcode->dest_size[0], opcode->src_size[0]); + orc_program_add_constant (p, opcode->src_size[1], 1, "c1"); + + sprintf(s, "test_const_%s", opcode->name); + orc_program_set_name (p, s); + + orc_program_append_str (p, opcode->name, "d1", "s1", "c1"); + + orc_test_gcc_compile (p); + + orc_program_free (p); +} + +void +test_opcode_param (OrcStaticOpcode *opcode) +{ + OrcProgram *p; + char s[40]; + int ret; + + if (opcode->src_size[1] == 0) return; + + p = orc_program_new_ds (opcode->dest_size[0], opcode->src_size[0]); + orc_program_add_parameter (p, opcode->src_size[1], "p1"); + + sprintf(s, "test_param_%s", opcode->name); + orc_program_set_name (p, s); + + orc_program_append_str (p, opcode->name, "d1", "s1", "p1"); + + ret = orc_test_gcc_compile (p); + if (!ret) { + printf("%s", orc_program_get_asm_code (p)); + } + + orc_program_free (p); +} +