From 86f1f1e46f67d14af50b007347474241656c341d Mon Sep 17 00:00:00 2001 From: dmalcolm Date: Fri, 6 Feb 2015 23:19:32 +0000 Subject: [PATCH] PR jit/64752 - Rewrite jit testsuite to eliminate use of "file" gcc/testsuite/ChangeLog: PR jit/64752 * jit.dg/create-code-for-hello-world-executable.h: New file, taken from jit.dg/test-compile-to-executable.c's create_code, with a clarification of the output message. * jit.dg/harness.h (CHECK_NO_ERRORS): Add test and __func__ to the pass/fail message. (test_jit): Use CHECK_NO_ERRORS when calling gcc_jit_context_compile_to_file. * jit.dg/jit.exp (jit-dg-test): Update grep for rename of jit-verify-compile-to-file to jit-verify-output-file-was-created. (jit-setup-compile-to-file): Likewise. Add a verbose comment about deletions that are attempted. (jit-verify-compile-to-file): Rename to... (jit-verify-output-file-was-created): ...this, and drop the attempt to run "file" and verify the output. (jit-verify-assembler): New function. (jit-verify-object): New function. (jit-verify-dynamic-library): New function. * jit.dg/test-compile-to-assembler.c (create_code): Eliminate in favor of an implementation from new file create-code-for-hello-world-executable.h, which also adds a "main". (dg-final): Replace jit-verify-compile-to-file with jit-verify-output-file-was-created, and invoke new function jit-verify-assembler. * jit.dg/test-compile-to-dynamic-library.c (create_code): Clarify the output message. (dg-final): Replace jit-verify-compile-to-file with jit-verify-output-file-was-created, and invoke new function jit-verify-dynamic-library. * jit.dg/test-compile-to-executable.c (create_code): Eliminate in favor of an implementation from new file create-code-for-hello-world-executable.h, which also adds a "main". (dg-final): Replace jit-verify-compile-to-file with jit-verify-output-file-was-created. Strengthen the expected stdout from the built executable. * jit.dg/test-compile-to-object.c (create_code): Eliminate in favor of an implementation from new file create-code-for-hello-world-executable.h, which also adds a "main". (dg-final): Replace jit-verify-compile-to-file with jit-verify-output-file-was-created, and invoke new function jit-verify-object. * jit.dg/verify-dynamic-library.c: New source file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220494 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 48 ++++++ gcc/testsuite/jit.dg/harness.h | 5 +- gcc/testsuite/jit.dg/jit.exp | 187 +++++++++++++++++---- gcc/testsuite/jit.dg/test-compile-to-assembler.c | 78 ++------- .../jit.dg/test-compile-to-dynamic-library.c | 7 +- gcc/testsuite/jit.dg/test-compile-to-executable.c | 123 ++------------ gcc/testsuite/jit.dg/test-compile-to-object.c | 78 ++------- 7 files changed, 248 insertions(+), 278 deletions(-) rewrite gcc/testsuite/jit.dg/test-compile-to-assembler.c (86%) rewrite gcc/testsuite/jit.dg/test-compile-to-executable.c (92%) rewrite gcc/testsuite/jit.dg/test-compile-to-object.c (86%) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e10f7782b44..dbe52cf0fd6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,51 @@ +2015-02-06 David Malcolm + + PR jit/64752 + * jit.dg/create-code-for-hello-world-executable.h: New file, taken + from jit.dg/test-compile-to-executable.c's create_code, with a + clarification of the output message. + * jit.dg/harness.h (CHECK_NO_ERRORS): Add test and __func__ to the + pass/fail message. + (test_jit): Use CHECK_NO_ERRORS when calling + gcc_jit_context_compile_to_file. + * jit.dg/jit.exp (jit-dg-test): Update grep for rename of + jit-verify-compile-to-file to jit-verify-output-file-was-created. + (jit-setup-compile-to-file): Likewise. Add a verbose comment + about deletions that are attempted. + (jit-verify-compile-to-file): Rename to... + (jit-verify-output-file-was-created): ...this, and drop the + attempt to run "file" and verify the output. + (jit-verify-assembler): New function. + (jit-verify-object): New function. + (jit-verify-dynamic-library): New function. + * jit.dg/test-compile-to-assembler.c (create_code): Eliminate in + favor of an implementation from new file + create-code-for-hello-world-executable.h, which also adds a + "main". + (dg-final): Replace jit-verify-compile-to-file with + jit-verify-output-file-was-created, and invoke new function + jit-verify-assembler. + * jit.dg/test-compile-to-dynamic-library.c (create_code): Clarify + the output message. + (dg-final): Replace jit-verify-compile-to-file with + jit-verify-output-file-was-created, and invoke new function + jit-verify-dynamic-library. + * jit.dg/test-compile-to-executable.c (create_code): Eliminate in + favor of an implementation from new file + create-code-for-hello-world-executable.h, which also adds a + "main". + (dg-final): Replace jit-verify-compile-to-file with + jit-verify-output-file-was-created. Strengthen the expected stdout + from the built executable. + * jit.dg/test-compile-to-object.c (create_code): Eliminate in + favor of an implementation from new file + create-code-for-hello-world-executable.h, which also adds a + "main". + (dg-final): Replace jit-verify-compile-to-file with + jit-verify-output-file-was-created, and invoke new function + jit-verify-object. + * jit.dg/verify-dynamic-library.c: New source file. + 2015-02-06 Sebastian Pop Brian Rzycki diff --git a/gcc/testsuite/jit.dg/harness.h b/gcc/testsuite/jit.dg/harness.h index a702a23a27b..907da5620b1 100644 --- a/gcc/testsuite/jit.dg/harness.h +++ b/gcc/testsuite/jit.dg/harness.h @@ -112,9 +112,9 @@ static char test[1024]; do { \ const char *err = gcc_jit_context_get_first_error (CTXT); \ if (err) \ - fail ("error unexpectedly occurred: %s", err); \ + fail ("%s: %s: error unexpectedly occurred: %s", test, __func__, err); \ else \ - pass ("no errors occurred"); \ + pass ("%s: %s: no errors occurred", test, __func__); \ } while (0) /* Hooks that testcases should provide. */ @@ -362,6 +362,7 @@ test_jit (const char *argv0, void *user_data) gcc_jit_context_compile_to_file (ctxt, (OUTPUT_KIND), (OUTPUT_FILENAME)); + CHECK_NO_ERRORS (ctxt); #else /* #ifdef TEST_COMPILING_TO_FILE */ /* This actually calls into GCC and runs the build, all in a mutex for now. */ diff --git a/gcc/testsuite/jit.dg/jit.exp b/gcc/testsuite/jit.dg/jit.exp index c853f22adde..d13f6b5e191 100644 --- a/gcc/testsuite/jit.dg/jit.exp +++ b/gcc/testsuite/jit.dg/jit.exp @@ -375,11 +375,10 @@ proc jit-dg-test { prog do_what extra_tool_flags } { append extra_tool_flags " -lpthread" } - # Any test case that uses - # { dg-final { jit-verify-compile-to-file FOO } } + # Any test case that uses jit-verify-output-file-was-created # needs to call jit-setup-compile-to-file here. # (is there a better way to handle setup/finish pairs in dg?) - set tmp [grep $prog "jit-verify-compile-to-file"] + set tmp [grep $prog "jit-verify-output-file-was-created"] if {![string match "" $tmp]} { jit-setup-compile-to-file $prog } @@ -601,7 +600,7 @@ proc jit-get-output-filename {prog} { return "" } -# For testcases that use jit-verify-compile-to-file, +# For testcases that use jit-verify-output-file-was-created # delete OUTPUT_FILENAME beforehand, to ensure that the # testcase is indeed creating it. @@ -610,21 +609,13 @@ proc jit-setup-compile-to-file { prog } { set output_filename [jit-get-output-filename $prog] verbose " output_filename: $output_filename" if {![string match "" $output_filename]} { + verbose " deleting any $output_filename" catch "exec rm -f $output_filename" } } -# Locate OUTPUT_FILENAME within the testcase. Verify -# that a file with that name was created, and that -# the output of running the "file" utility on it -# matches the given regex. -# For use by the various test-compile-to-*.c testcases. - -proc jit-verify-compile-to-file {args} { - verbose "jit-verify-compile-to-file: $args" - - set file_regex [lindex $args 0] - verbose "file_regex: $file_regex" +proc jit-verify-output-file-was-created { args } { + verbose "jit-verify-output-file-was-created: $args" upvar 2 prog prog verbose "prog: $prog" @@ -636,25 +627,7 @@ proc jit-verify-compile-to-file {args} { pass "$output_filename exists" } else { fail "$output_filename does not exist" - return - } - - # Run "file" on OUTPUT_FILENAME, and verify that the output - # matches $file_regex. - spawn -noecho "file" $output_filename - set file_id $spawn_id - expect "\n" { - verbose "got newline: $expect_out(buffer)" - set classification $expect_out(buffer) - verbose "classification: $classification" - if { [regexp $file_regex $classification] } { - pass "'file' output on $output_filename matched: $file_regex" - } else { - fail "'file' output on $output_filename did not match: $file_regex" - } } - set $spawn_id $file_id - close } # Verify that the given file exists, and is executable. @@ -709,6 +682,154 @@ proc jit-run-executable { args } { } } +# Assuming that a .s file has been written out named +# OUTPUT_FILENAME, invoke the driver to try to turn it into +# an executable, and try to run the result. +# For use by the test-compile-to-assembler.c testcase. +proc jit-verify-assembler { args } { + verbose "jit-verify-assembler: $args" + + set dg-output-text [lindex $args 0] + verbose "dg-output-text: ${dg-output-text}" + + upvar 2 name name + verbose "name: $name" + + upvar 2 prog prog + verbose "prog: $prog" + set asm_filename [jit-get-output-filename $prog] + verbose " asm_filename: ${asm_filename}" + + # Name the built executable as OUTPUT_FILENAME with + # ".exe" appended. + set executable_from_asm ${asm_filename}.exe + verbose " executable_from_asm: ${executable_from_asm}" + + # Invoke the driver to assemble/link the .s file to the .exe + set comp_output [gcc_target_compile \ + ${asm_filename} \ + ${executable_from_asm} \ + "executable" \ + "{}"] + if ![jit_check_compile \ + "$name" \ + "assemble/link of ${asm_filename}" \ + ${executable_from_asm} \ + $comp_output] then { + return + } + + # Verify that the executable was created. + if { [file exists $executable_from_asm] == 1} { + pass "$executable_from_asm exists" + } else { + fail "$executable_from_asm does not exist" + } + + # Run it and verify that the output matches the regex. + jit-run-executable ${executable_from_asm} ${dg-output-text} +} + +# Assuming that a .o file has been written out named +# OUTPUT_FILENAME, invoke the driver to try to turn it into +# an executable, and try to run the result. +# For use by the test-compile-to-object.c testcase. +proc jit-verify-object { args } { + verbose "jit-verify-object: $args" + + set dg-output-text [lindex $args 0] + verbose "dg-output-text: ${dg-output-text}" + + upvar 2 name name + verbose "name: $name" + + upvar 2 prog prog + verbose "prog: $prog" + set obj_filename [jit-get-output-filename $prog] + verbose " obj_filename: ${obj_filename}" + + # Name the linked executable as OUTPUT_FILENAME with + # ".exe" appended. + set executable_from_obj ${obj_filename}.exe + verbose " executable_from_obj: ${executable_from_obj}" + + # Invoke the driver to link the .o file to the .exe + set comp_output [gcc_target_compile \ + ${obj_filename} \ + ${executable_from_obj} \ + "executable" \ + "{}"] + if ![jit_check_compile \ + "$name" \ + "link of ${obj_filename}" \ + ${executable_from_obj} \ + $comp_output] then { + return + } + + # Verify that the executable was created. + if { [file exists $executable_from_obj] == 1} { + pass "$executable_from_obj exists" + } else { + fail "$executable_from_obj does not exist" + } + + # Run it and verify that the output matches the regex. + jit-run-executable ${executable_from_obj} ${dg-output-text} +} + +# Assuming that a .so file has been written out named +# OUTPUT_FILENAME, build a test executable to use it, +# and try to run the result. +# For use by the test-compile-to-dynamic-library.c testcase. +proc jit-verify-dynamic-library { args } { + verbose "jit-verify-object: $args" + + global srcdir + global subdir + + set dg-output-text [lindex $args 0] + verbose "dg-output-text: ${dg-output-text}" + + upvar 2 name name + verbose "name: $name" + + upvar 2 prog prog + verbose "prog: $prog" + set obj_filename [jit-get-output-filename $prog] + verbose " obj_filename: ${obj_filename}" + + # Build a test executable from + # verify-dynamic-library.c + set test_src "verify-dynamic-library.c" + set test_executable ${test_src}.exe + verbose " test_executable: ${test_executable}" + + # Invoke the driver to build the test executable + set comp_output [gcc_target_compile \ + $srcdir/$subdir/${test_src} \ + ${test_executable} \ + "executable" \ + "{additional_flags=-ldl}"] + if ![jit_check_compile \ + "$name" \ + "build of ${test_executable}" \ + ${test_executable} \ + $comp_output] then { + return + } + + # Verify that the test executable was created. + if { [file exists $test_executable] == 1} { + pass "$test_executable exists" + } else { + fail "$test_executable does not exist" + } + + # Run it and verify that the output matches the regex. + jit-run-executable ${test_executable} ${dg-output-text} +} + # A way to invoke "jit-run-executable" with the given regex, # using OUTPUT_FILENAME within the testcase to determine # the name of the executable to run. diff --git a/gcc/testsuite/jit.dg/test-compile-to-assembler.c b/gcc/testsuite/jit.dg/test-compile-to-assembler.c dissimilarity index 86% index c5b282c2870..e3a6d2edd20 100644 --- a/gcc/testsuite/jit.dg/test-compile-to-assembler.c +++ b/gcc/testsuite/jit.dg/test-compile-to-assembler.c @@ -1,65 +1,13 @@ -#include -#include - -#include "libgccjit.h" - -#define TEST_COMPILING_TO_FILE -#define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_ASSEMBLER -#define OUTPUT_FILENAME "output-of-test-compile-to-assembler.c.s" -#include "harness.h" - -void -create_code (gcc_jit_context *ctxt, void *user_data) -{ - /* Let's try to inject the equivalent of: - void - hello_world (const char *name) - { - // a test comment - printf ("hello %s\n", name); - } - */ - gcc_jit_type *void_type = - gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID); - gcc_jit_type *const_char_ptr_type = - gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_CONST_CHAR_PTR); - gcc_jit_param *param_name = - gcc_jit_context_new_param (ctxt, NULL, const_char_ptr_type, "name"); - gcc_jit_function *func = - gcc_jit_context_new_function (ctxt, NULL, - GCC_JIT_FUNCTION_EXPORTED, - void_type, - "hello_world", - 1, ¶m_name, - 0); - - gcc_jit_param *param_format = - gcc_jit_context_new_param (ctxt, NULL, const_char_ptr_type, "format"); - gcc_jit_function *printf_func = - gcc_jit_context_new_function (ctxt, NULL, - GCC_JIT_FUNCTION_IMPORTED, - gcc_jit_context_get_type ( - ctxt, GCC_JIT_TYPE_INT), - "printf", - 1, ¶m_format, - 1); - gcc_jit_rvalue *args[2]; - args[0] = gcc_jit_context_new_string_literal (ctxt, "hello %s\n"); - args[1] = gcc_jit_param_as_rvalue (param_name); - - gcc_jit_block *block = gcc_jit_function_new_block (func, NULL); - - gcc_jit_block_add_comment ( - block, NULL, - "a test comment"); - - gcc_jit_block_add_eval ( - block, NULL, - gcc_jit_context_new_call (ctxt, - NULL, - printf_func, - 2, args)); - gcc_jit_block_end_with_void_return (block, NULL); -} - -/* { dg-final { jit-verify-compile-to-file "assembler source text" } } */ +#include +#include + +#include "libgccjit.h" + +#define TEST_COMPILING_TO_FILE +#define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_ASSEMBLER +#define OUTPUT_FILENAME "output-of-test-compile-to-assembler.c.s" +#include "harness.h" +#include "create-code-for-hello-world-executable.h" + +/* { dg-final { jit-verify-output-file-was-created "" } } */ +/* { dg-final { jit-verify-assembler "hello from ./output-of-test-compile-to-assembler.c.s.exe" } } */ diff --git a/gcc/testsuite/jit.dg/test-compile-to-dynamic-library.c b/gcc/testsuite/jit.dg/test-compile-to-dynamic-library.c index 095f75127f3..c29e6f6d628 100644 --- a/gcc/testsuite/jit.dg/test-compile-to-dynamic-library.c +++ b/gcc/testsuite/jit.dg/test-compile-to-dynamic-library.c @@ -16,7 +16,7 @@ create_code (gcc_jit_context *ctxt, void *user_data) hello_world (const char *name) { // a test comment - printf ("hello %s\n", name); + printf ("hello from %s\n", name); } */ gcc_jit_type *void_type = @@ -44,7 +44,7 @@ create_code (gcc_jit_context *ctxt, void *user_data) 1, ¶m_format, 1); gcc_jit_rvalue *args[2]; - args[0] = gcc_jit_context_new_string_literal (ctxt, "hello %s\n"); + args[0] = gcc_jit_context_new_string_literal (ctxt, "hello from %s\n"); args[1] = gcc_jit_param_as_rvalue (param_name); gcc_jit_block *block = gcc_jit_function_new_block (func, NULL); @@ -62,4 +62,5 @@ create_code (gcc_jit_context *ctxt, void *user_data) gcc_jit_block_end_with_void_return (block, NULL); } -/* { dg-final { jit-verify-compile-to-file "shared object.+dynamically linked" } } */ +/* { dg-final { jit-verify-output-file-was-created "" } } */ +/* { dg-final { jit-verify-dynamic-library "hello from ./verify-dynamic-library.c.exe" } } */ diff --git a/gcc/testsuite/jit.dg/test-compile-to-executable.c b/gcc/testsuite/jit.dg/test-compile-to-executable.c dissimilarity index 92% index 8d7b428b89f..2fb0bd91cc9 100644 --- a/gcc/testsuite/jit.dg/test-compile-to-executable.c +++ b/gcc/testsuite/jit.dg/test-compile-to-executable.c @@ -1,110 +1,13 @@ -#include -#include - -#include "libgccjit.h" - -#define TEST_COMPILING_TO_FILE -#define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_EXECUTABLE -#define OUTPUT_FILENAME "output-of-test-compile-to-executable.c.exe" -#include "harness.h" - -void -create_code (gcc_jit_context *ctxt, void *user_data) -{ - /* Let's try to inject the equivalent of: - static void - hello_world (const char *name) - { - // a test comment - printf ("hello %s\n", name); - } - - extern int - main (int argc, char **argv) - { - hello_world (argv[0]); - return 0; - } - */ - gcc_jit_type *void_type = - gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID); - gcc_jit_type *const_char_ptr_type = - gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_CONST_CHAR_PTR); - gcc_jit_param *param_name = - gcc_jit_context_new_param (ctxt, NULL, const_char_ptr_type, "name"); - gcc_jit_function *func = - gcc_jit_context_new_function (ctxt, NULL, - GCC_JIT_FUNCTION_INTERNAL, - void_type, - "hello_world", - 1, ¶m_name, - 0); - - gcc_jit_param *param_format = - gcc_jit_context_new_param (ctxt, NULL, const_char_ptr_type, "format"); - gcc_jit_function *printf_func = - gcc_jit_context_new_function (ctxt, NULL, - GCC_JIT_FUNCTION_IMPORTED, - gcc_jit_context_get_type ( - ctxt, GCC_JIT_TYPE_INT), - "printf", - 1, ¶m_format, - 1); - gcc_jit_rvalue *args[2]; - args[0] = gcc_jit_context_new_string_literal (ctxt, "hello %s\n"); - args[1] = gcc_jit_param_as_rvalue (param_name); - - gcc_jit_block *block = gcc_jit_function_new_block (func, NULL); - - gcc_jit_block_add_comment ( - block, NULL, - "a test comment"); - - gcc_jit_block_add_eval ( - block, NULL, - gcc_jit_context_new_call (ctxt, - NULL, - printf_func, - 2, args)); - gcc_jit_block_end_with_void_return (block, NULL); - - gcc_jit_type *int_type = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); - gcc_jit_param *param_argc = - gcc_jit_context_new_param (ctxt, NULL, int_type, "argc"); - gcc_jit_type *char_ptr_ptr_type = - gcc_jit_type_get_pointer ( - gcc_jit_type_get_pointer ( - gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_CHAR))); - gcc_jit_param *param_argv = - gcc_jit_context_new_param (ctxt, NULL, char_ptr_ptr_type, "argv"); - gcc_jit_param *params[2] = {param_argc, param_argv}; - gcc_jit_function *func_main = - gcc_jit_context_new_function (ctxt, NULL, - GCC_JIT_FUNCTION_EXPORTED, - int_type, - "main", - 2, params, - 0); - block = gcc_jit_function_new_block (func_main, NULL); - gcc_jit_rvalue *zero = gcc_jit_context_zero (ctxt, int_type); - args[0] = gcc_jit_context_new_cast ( - ctxt, - NULL, - gcc_jit_lvalue_as_rvalue ( - gcc_jit_context_new_array_access ( - ctxt, - NULL, - gcc_jit_param_as_rvalue (param_argv), - zero)), - const_char_ptr_type); - gcc_jit_block_add_eval ( - block, NULL, - gcc_jit_context_new_call (ctxt, - NULL, - func, - 1, args)); - gcc_jit_block_end_with_return (block, NULL, zero); -} - -/* { dg-final { jit-verify-compile-to-file "executable" } } */ -/* { dg-final { jit-verify-executable "hello .*" } } */ +#include +#include + +#include "libgccjit.h" + +#define TEST_COMPILING_TO_FILE +#define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_EXECUTABLE +#define OUTPUT_FILENAME "output-of-test-compile-to-executable.c.exe" +#include "harness.h" +#include "create-code-for-hello-world-executable.h" + +/* { dg-final { jit-verify-output-file-was-created "" } } */ +/* { dg-final { jit-verify-executable "hello from ./output-of-test-compile-to-executable.c.exe" } } */ diff --git a/gcc/testsuite/jit.dg/test-compile-to-object.c b/gcc/testsuite/jit.dg/test-compile-to-object.c dissimilarity index 86% index 1f7fcc6e549..81d41c21d40 100644 --- a/gcc/testsuite/jit.dg/test-compile-to-object.c +++ b/gcc/testsuite/jit.dg/test-compile-to-object.c @@ -1,65 +1,13 @@ -#include -#include - -#include "libgccjit.h" - -#define TEST_COMPILING_TO_FILE -#define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_OBJECT_FILE -#define OUTPUT_FILENAME "output-of-test-compile-to-object.c.o" -#include "harness.h" - -void -create_code (gcc_jit_context *ctxt, void *user_data) -{ - /* Let's try to inject the equivalent of: - void - hello_world (const char *name) - { - // a test comment - printf ("hello %s\n", name); - } - */ - gcc_jit_type *void_type = - gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID); - gcc_jit_type *const_char_ptr_type = - gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_CONST_CHAR_PTR); - gcc_jit_param *param_name = - gcc_jit_context_new_param (ctxt, NULL, const_char_ptr_type, "name"); - gcc_jit_function *func = - gcc_jit_context_new_function (ctxt, NULL, - GCC_JIT_FUNCTION_EXPORTED, - void_type, - "hello_world", - 1, ¶m_name, - 0); - - gcc_jit_param *param_format = - gcc_jit_context_new_param (ctxt, NULL, const_char_ptr_type, "format"); - gcc_jit_function *printf_func = - gcc_jit_context_new_function (ctxt, NULL, - GCC_JIT_FUNCTION_IMPORTED, - gcc_jit_context_get_type ( - ctxt, GCC_JIT_TYPE_INT), - "printf", - 1, ¶m_format, - 1); - gcc_jit_rvalue *args[2]; - args[0] = gcc_jit_context_new_string_literal (ctxt, "hello %s\n"); - args[1] = gcc_jit_param_as_rvalue (param_name); - - gcc_jit_block *block = gcc_jit_function_new_block (func, NULL); - - gcc_jit_block_add_comment ( - block, NULL, - "a test comment"); - - gcc_jit_block_add_eval ( - block, NULL, - gcc_jit_context_new_call (ctxt, - NULL, - printf_func, - 2, args)); - gcc_jit_block_end_with_void_return (block, NULL); -} - -/* { dg-final { jit-verify-compile-to-file "relocatable" } } */ +#include +#include + +#include "libgccjit.h" + +#define TEST_COMPILING_TO_FILE +#define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_OBJECT_FILE +#define OUTPUT_FILENAME "output-of-test-compile-to-object.c.o" +#include "harness.h" +#include "create-code-for-hello-world-executable.h" + +/* { dg-final { jit-verify-output-file-was-created "" } } */ +/* { dg-final { jit-verify-object "hello from ./output-of-test-compile-to-object.c.o.exe" } } */ -- 2.11.4.GIT