From 522a57e47a44249b7250ff2efb06e12b2f3e4a6a Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sun, 24 May 2009 14:07:50 -0700 Subject: [PATCH] clean up files after running tests --- orc-test/orctest.c | 63 ++++++++++++++++++++++++++++++++++++--------------- testsuite/Makefile.am | 2 ++ 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/orc-test/orctest.c b/orc-test/orctest.c index 9024a00..d2b0da4 100644 --- a/orc-test/orctest.c +++ b/orc-test/orctest.c @@ -19,16 +19,30 @@ orc_test_init (void) } - - OrcTestResult orc_test_gcc_compile (OrcProgram *p) { char cmd[200]; + char *base; + char source_filename[100]; + char obj_filename[100]; + char dis_filename[100]; + char dump_filename[100]; + char dump_obj_filename[100]; + char dump_dis_filename[100]; int ret; FILE *file; OrcCompileResult result; + base = "temp-orc-test"; + + sprintf(source_filename, "%s-source.s", base); + sprintf(obj_filename, "%s-source.o", base); + sprintf(dis_filename, "%s-source.dis", base); + sprintf(dump_filename, "%s-dump.bin", base); + sprintf(dump_obj_filename, "%s-dump.o", base); + sprintf(dump_dis_filename, "%s-dump.dis", base); + result = orc_program_compile (p); if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { return ORC_TEST_INDETERMINATE; @@ -36,28 +50,32 @@ orc_test_gcc_compile (OrcProgram *p) fflush (stdout); - file = fopen ("tmp.s", "w"); + file = fopen (source_filename, "w"); fprintf(file, "%s", orc_program_get_asm_code (p)); fclose (file); - file = fopen ("dump", "w"); + file = fopen (dump_filename, "w"); ret = fwrite(p->code, p->code_size, 1, file); fclose (file); #if defined(HAVE_POWERPC) - ret = system ("gcc -Wa,-mregnames -Wall -c tmp.s"); + sprintf (cmd, "gcc -Wa,-mregnames -Wall -c %s -o %d", source_filename, + obj_filename); #else - ret = system ("gcc -Wall -c tmp.s"); + sprintf (cmd, "gcc -Wall -c %s -o %s", source_filename, + obj_filename); #endif + ret = system (cmd); if (ret != 0) { - printf("gcc failed\n"); - return FALSE; + ORC_ERROR ("gcc failed"); + return ORC_TEST_FAILED; } - ret = system ("objdump -dr tmp.o >tmp.dis"); + sprintf (cmd, "objdump -dr %s >%s", obj_filename, dis_filename); + ret = system (cmd); if (ret != 0) { - printf("objdump failed\n"); - return FALSE; + ORC_ERROR ("objdump failed"); + return ORC_TEST_FAILED; } sprintf (cmd, "objcopy -I binary " @@ -72,26 +90,35 @@ orc_test_gcc_compile (OrcProgram *p) #endif "--rename-section .data=.text " "--redefine-sym _binary_dump_start=%s " - "dump tmp.o", p->name); + "%s %s", p->name, dump_filename, dump_obj_filename); ret = system (cmd); if (ret != 0) { printf("objcopy failed\n"); - return FALSE; + return ORC_TEST_FAILED; } - ret = system ("objdump -Dr tmp.o >tmp-dump.dis"); + sprintf (cmd, "objdump -Dr %s >%s", dump_obj_filename, dump_dis_filename); + ret = system (cmd); if (ret != 0) { printf("objdump failed\n"); - return FALSE; + return ORC_TEST_FAILED; } - ret = system ("diff -u tmp.dis tmp-dump.dis"); + sprintf (cmd, "diff -u %s %s", dis_filename, dump_dis_filename); + ret = system (cmd); if (ret != 0) { printf("diff failed\n"); - return FALSE; + return ORC_TEST_FAILED; } - return TRUE; + remove (source_filename); + remove (obj_filename); + remove (dis_filename); + remove (dump_filename); + remove (dump_obj_filename); + remove (dump_dis_filename); + + return ORC_TEST_OK; } diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index a6fd37a..8d5d0b1 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -11,6 +11,8 @@ XFAIL_TESTS = \ orcbin_PROGRAMS = $(TESTS) +CLEANFILES = temp-orc-test-* + AM_CFLAGS = $(ORC_CFLAGS) LIBS = $(ORC_LIBS) $(top_builddir)/orc-test/liborc-test-0.3.la -- 2.7.4