From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24982 invoked by alias); 14 Mar 2011 21:06:07 -0000 Received: (qmail 24971 invoked by uid 22791); 14 Mar 2011 21:06:05 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Mar 2011 21:06:00 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 966391B4055; Mon, 14 Mar 2011 21:05:57 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Cc: toolchain-devel@blackfin.uclinux.org Subject: [PATCH] sim: tests: support .S/.c files Date: Mon, 14 Mar 2011 21:23:00 -0000 Message-Id: <1300136769-5921-1-git-send-email-vapier@gentoo.org> In-Reply-To: <1300057848-2316-1-git-send-email-vapier@gentoo.org> References: <1300057848-2316-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00749.txt.bz2 Rather than requiring all sim tests to be preprocessed .s files, add support for .S and .c files so we can easily write code using a higher level language like C. Signed-off-by: Mike Frysinger 2011-03-14 Mike Frysinger * sim-defs.exp: Support cc tag in test files. (run_sim_test): Support global_cc_options in boards files. Convert assembler options into compiler options (c_as_options) with -Wa. Convert linker options into compiler options (c_ld_options) with -Wl. Compile .c and .S files into .x programs. --- sim/testsuite/lib/sim-defs.exp | 48 ++++++++++++++++++++++++++++++++------- 1 files changed, 39 insertions(+), 9 deletions(-) diff --git a/sim/testsuite/lib/sim-defs.exp b/sim/testsuite/lib/sim-defs.exp index 1e65817..c8093a2 100644 --- a/sim/testsuite/lib/sim-defs.exp +++ b/sim/testsuite/lib/sim-defs.exp @@ -169,6 +169,7 @@ proc sim_run { prog sim_opts prog_opts redir options } { # mach: [all | machine names] # as[(mach-list)]: # ld[(mach-list)]: +# cc[(mach-list)]: # sim[(mach-list)]: # progopts: # output: program output pattern to match with string-match @@ -190,6 +191,7 @@ proc run_sim_test { name requested_machs } { global cpu_option global global_as_options global global_ld_options + global global_cc_options global global_sim_options if [string match "*/*" $name] { @@ -207,6 +209,7 @@ proc run_sim_test { name requested_machs } { # Clear default options set opts(as) "" set opts(ld) "" + set opts(cc) "" set opts(progopts) "" set opts(sim) "" set opts(output) "" @@ -222,6 +225,9 @@ proc run_sim_test { name requested_machs } { if ![info exists global_ld_options] { set global_ld_options "" } + if ![info exists global_cc_options] { + set global_cc_options "" + } if ![info exists global_sim_options] { set global_sim_options "" } @@ -234,6 +240,9 @@ proc run_sim_test { name requested_machs } { if [info exists opts(ld,$m)] { unset opts(ld,$m) } + if [info exists opts(cc,$m)] { + unset opts(cc,$m) + } if [info exists opts(sim,$m)] { unset opts(sim,$m) } @@ -310,23 +319,44 @@ proc run_sim_test { name requested_machs } { if [info exists cpu_option] { set as_options "$as_options $cpu_option=$mach" } - set comp_output [target_assemble $sourcefile ${name}.o "$as_options $global_as_options"] - - if ![string match "" $comp_output] { - verbose -log "$comp_output" 3 - fail "$mach $testname (assembling)" - continue - } + regsub {(^ *| +)([^ ]+)} "$as_options $global_as_options" { -Wa,\2} c_as_options if ![info exists opts(ld,$mach)] { set opts(ld,$mach) $opts(ld) } + regsub {(^ *| +)([^ ]+)} "$opts(ld,$mach) $global_ld_options" { -Wl,\2} c_ld_options + + if ![info exists opts(cc,$mach)] { + set opts(cc,$mach) $opts(cc) + } + + if [string match "*.c" $sourcefile] { + set comp_output [target_compile $sourcefile ${name}.x "executable" \ + [list "incdir=$srcdir/$subdir" "additional_flags=$c_as_options $c_ld_options $opts(cc,$mach) $global_cc_options"]] + set method "compiling/linking" + } else { + if [string match "*.S" $sourcefile] { + set comp_output [target_compile $sourcefile ${name}.o "object" \ + [list "incdir=$srcdir/$subdir" "additional_flags=$c_as_options"]] + set method "compiling" + } else { + set comp_output [target_assemble $sourcefile ${name}.o "$as_options $global_as_options"] + set method "assembling" + } + + if ![string match "" $comp_output] { + verbose -log "$comp_output" 3 + fail "$mach $testname (${method})" + continue + } - set comp_output [target_link ${name}.o ${name}.x "$opts(ld,$mach) $global_ld_options"] + set comp_output [target_link ${name}.o ${name}.x "$opts(ld,$mach) $global_ld_options"] + set method "linking" + } if ![string match "" $comp_output] { verbose -log "$comp_output" 3 - fail "$mach $testname (linking)" + fail "$mach $testname (${method})" continue } -- 1.7.4.1