diff options
author | dnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-06 16:22:19 +0000 |
---|---|---|
committer | dnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-05-06 16:22:19 +0000 |
commit | 6858cdb803535039de8724fae07e6c0a9e2fd973 (patch) | |
tree | a5087003f4b4bf7007cadc9c35cb1c45997e3102 /gcc/testsuite/lib/plugin-support.exp | |
parent | 07a202c2bef1393d406b8ad7985918f63b798b5b (diff) | |
download | gcc-6858cdb803535039de8724fae07e6c0a9e2fd973.tar.gz |
2009-05-06 Le-Chun Wu <lcwu@google.com>
* lib/plugin-support.exp: New file containing support procs for
plugin testcases.
* lib/target-supports.exp (check_plugin_available): New proc.
* gcc.dg/plugin/plugin.exp: New driver script for gcc testcases.
* gcc.dg/plugin/selfassign.c: New plugin source file.
* gcc.dg/plugin/self-assign-test-1.c: New test.
* gcc.dg/plugin/self-assign-test-2.c: Likewise.
* g++.dg/README: Add description for plugin test.
* g++.dg/dg.exp: Exclude plugin tests from the general test list.
* g++.dg/plugin/plugin.exp: New driver script for g++ testcases.
* g++.dg/plugin/selfassign.c: New plugin source file.
* g++.dg/plugin/self-assign-test-1.C: New test.
* g++.dg/plugin/self-assign-test-2.C: Likewise.
* g++.dg/plugin/self-assign-test-3.C: Likewise.
* g++.dg/plugin/dumb_plugin.c: New plugin source file.
* g++.dg/plugin/dumb-plugin-test-1.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147185 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/lib/plugin-support.exp')
-rw-r--r-- | gcc/testsuite/lib/plugin-support.exp | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/gcc/testsuite/lib/plugin-support.exp b/gcc/testsuite/lib/plugin-support.exp new file mode 100644 index 00000000000..f9017bb732d --- /dev/null +++ b/gcc/testsuite/lib/plugin-support.exp @@ -0,0 +1,102 @@ +# Copyright (C) 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. +# + +# This file contains the support procedures for testing the plugin mechanism. + +load_lib dg.exp +load_lib gcc.exp + +# +# plugin-get-options -- process test directives +# +# SRC is the full pathname of the plugin source file. +# +proc plugin-get-options { src } { + # dg-options sets a variable called dg-extra-tool-flags. + set dg-extra-tool-flags "" + + # dg-require-* sets dg-do-what. + upvar dg-do-what dg-do-what + + set tmp [dg-get-options $src] + foreach op $tmp { + set cmd [lindex $op 0] + if { ![string compare "dg-options" $cmd] } { + set status [catch "$op" errmsg] + if { $status != 0 } { + perror "src: $errmsg for \"$op\"\n" + unresolved "$src: $errmsg for \"$op\"" + return + } + } else { + # Ignore unrecognized dg- commands, but warn about them. + warning "plugin.exp does not support $cmd" + } + } + + # Return flags to use for compiling the plugin source file + return ${dg-extra-tool-flags} +} + +# +# plugin-test-execute -- build the plugin first and then compile the +# test files with the plugin. +# +# PLUGIN_SRC is the full pathname of the plugin source file. +# PLUGIN_TESTS is a list of input test source files. +# +proc plugin-test-execute { plugin_src plugin_tests } { + global srcdir objdir + global verbose + global GMPINC + + set basename [file tail $plugin_src] + set base [file rootname $basename] + set plugin_lib $base.so + + verbose "Test the plugin $basename" 1 + + # Build the plugin itself + set extra_flags [plugin-get-options $plugin_src] + + # Note that the plugin test support currently only works when the GCC + # build tree is available. (We make sure that is the case in plugin.exp.) + # Once we have figured out how/where to package/install GCC header files + # for general plugin support, we should modify the following include paths + # accordingly. + set gcc_srcdir "$srcdir/../.." + set gcc_objdir "$objdir/../../.." + set includes "-I. -I${srcdir} -I${gcc_srcdir}/gcc -I${gcc_objdir}/gcc \ + -I${gcc_srcdir}/include -I${gcc_srcdir}/libcpp/include \ + -I$GMPINC" + + set optstr "$includes $extra_flags -DIN_GCC -fPIC -shared" + + set status [target_compile "$optstr $plugin_src" "$plugin_lib" executable ""] + if { "$status" != "" } { + unresolved "$basename compilation, $optstr" + return + } + + # Compile the input source files with the plugin + global default_flags + set plugin_enabling_flags "-fplugin=./$plugin_lib" + dg-runtest $plugin_tests $plugin_enabling_flags $default_flags + + # Clean up + remote_file build delete $plugin_lib +} |