diff options
Diffstat (limited to 'gcc-4.7/libitm/testsuite')
23 files changed, 1588 insertions, 0 deletions
diff --git a/gcc-4.7/libitm/testsuite/Makefile.am b/gcc-4.7/libitm/testsuite/Makefile.am new file mode 100644 index 000000000..561b7e254 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/Makefile.am @@ -0,0 +1,13 @@ +## Process this file with automake to produce Makefile.in. + +AUTOMAKE_OPTIONS = foreign dejagnu + +# May be used by various substitution variables. +gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) + +EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \ + echo $(top_builddir)/../expect/expect; else echo expect; fi) + +_RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \ + echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi) +RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)" diff --git a/gcc-4.7/libitm/testsuite/Makefile.in b/gcc-4.7/libitm/testsuite/Makefile.in new file mode 100644 index 000000000..094e44de5 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/Makefile.in @@ -0,0 +1,442 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = testsuite +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/asmcfi.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/enable.m4 \ + $(top_srcdir)/../config/futex.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/mmap.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/override.m4 \ + $(top_srcdir)/../config/stdint.m4 \ + $(top_srcdir)/../config/tls.m4 \ + $(top_srcdir)/../config/weakref.m4 \ + $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ + $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +DEJATOOL = $(PACKAGE) +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +HWCAP_LDFLAGS = @HWCAP_LDFLAGS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPT_LDFLAGS = @OPT_LDFLAGS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +RANLIB = @RANLIB@ +SECTION_LDFLAGS = @SECTION_LDFLAGS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XCFLAGS = @XCFLAGS@ +XLDFLAGS = @XLDFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +config_path = @config_path@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +enable_shared = @enable_shared@ +enable_static = @enable_static@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +libtool_VERSION = @libtool_VERSION@ +link_itm = @link_itm@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +multi_basedir = @multi_basedir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +toolexecdir = @toolexecdir@ +toolexeclibdir = @toolexeclibdir@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = foreign dejagnu + +# May be used by various substitution variables. +gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) +EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \ + echo $(top_builddir)/../expect/expect; else echo expect; fi) + +_RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \ + echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi) + +RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)" +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign testsuite/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +check-DEJAGNU: site.exp + srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ + EXPECT=$(EXPECT); export EXPECT; \ + runtest=$(RUNTEST); \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \ + if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \ + then :; else exit_status=1; fi; \ + done; \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi; \ + exit $$exit_status +site.exp: Makefile + @echo 'Making a new site.exp file...' + @echo '## these variables are automatically generated by make ##' >site.tmp + @echo '# Do not edit here. If you wish to override these values' >>site.tmp + @echo '# edit the last section' >>site.tmp + @echo 'set srcdir $(srcdir)' >>site.tmp + @echo "set objdir `pwd`" >>site.tmp + @echo 'set build_alias "$(build_alias)"' >>site.tmp + @echo 'set build_triplet $(build_triplet)' >>site.tmp + @echo 'set host_alias "$(host_alias)"' >>site.tmp + @echo 'set host_triplet $(host_triplet)' >>site.tmp + @echo 'set target_alias "$(target_alias)"' >>site.tmp + @echo 'set target_triplet $(target_triplet)' >>site.tmp + @echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp + @test ! -f site.exp || \ + sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp + @-rm -f site.bak + @test ! -f site.exp || mv site.exp site.bak + @mv site.tmp site.exp + +distclean-DEJAGNU: + -rm -f site.exp site.bak + -l='$(DEJATOOL)'; for tool in $$l; do \ + rm -f $$tool.sum $$tool.log; \ + done + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-DEJAGNU distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \ + clean-libtool distclean distclean-DEJAGNU distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/gcc-4.7/libitm/testsuite/config/default.exp b/gcc-4.7/libitm/testsuite/config/default.exp new file mode 100644 index 000000000..b5e53fc79 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/config/default.exp @@ -0,0 +1,17 @@ +# Copyright (C) 2011 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 2 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 this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +load_lib "standard.exp" diff --git a/gcc-4.7/libitm/testsuite/lib/libitm-dg.exp b/gcc-4.7/libitm/testsuite/lib/libitm-dg.exp new file mode 100644 index 000000000..f684ce899 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/lib/libitm-dg.exp @@ -0,0 +1,21 @@ +# 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 2 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 this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +proc libitm-dg-test { prog do_what extra_tool_flags } { + return [gcc-dg-test-1 libitm_target_compile $prog $do_what $extra_tool_flags] +} + +proc libitm-dg-prune { system text } { + return [gcc-dg-prune $system $text] +} diff --git a/gcc-4.7/libitm/testsuite/lib/libitm.exp b/gcc-4.7/libitm/testsuite/lib/libitm.exp new file mode 100644 index 000000000..b2556d140 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/lib/libitm.exp @@ -0,0 +1,228 @@ +# 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 2 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 this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Damn dejagnu for not having proper library search paths for load_lib. +# We have to explicitly load everything that gcc-dg.exp wants to load. + +proc load_gcc_lib { filename } { + global srcdir loaded_libs + + load_file $srcdir/../../gcc/testsuite/lib/$filename + set loaded_libs($filename) "" +} + +load_lib dg.exp +load_gcc_lib file-format.exp +load_gcc_lib target-supports.exp +load_gcc_lib target-supports-dg.exp +load_gcc_lib scanasm.exp +load_gcc_lib scandump.exp +load_gcc_lib scanrtl.exp +load_gcc_lib scantree.exp +load_gcc_lib scanipa.exp +load_gcc_lib prune.exp +load_gcc_lib target-libpath.exp +load_gcc_lib wrapper.exp +load_gcc_lib gcc-defs.exp +load_gcc_lib torture-options.exp +load_gcc_lib timeout.exp +load_gcc_lib timeout-dg.exp +load_gcc_lib gcc-dg.exp + +set dg-do-what-default run + +# +# GCC_UNDER_TEST is the compiler under test. +# + +set libitm_compile_options "" + +# +# libitm_init +# + +if [info exists TOOL_OPTIONS] { + set multilibs [get_multilibs $TOOL_OPTIONS] +} else { + set multilibs [get_multilibs] +} + +proc libitm_init { args } { + global srcdir blddir objdir tool_root_dir + global libitm_initialized + global tmpdir + global blddir + global gluefile wrap_flags + global ALWAYS_CFLAGS + global CFLAGS + global TOOL_EXECUTABLE TOOL_OPTIONS + global GCC_UNDER_TEST + global TESTING_IN_BUILD_TREE + global target_triplet + global always_ld_library_path + + set blddir [lookfor_file [get_multilibs] libitm] + + # We set LC_ALL and LANG to C so that we get the same error + # messages as expected. + setenv LC_ALL C + setenv LANG C + + if ![info exists GCC_UNDER_TEST] then { + if [info exists TOOL_EXECUTABLE] { + set GCC_UNDER_TEST $TOOL_EXECUTABLE + } else { + set GCC_UNDER_TEST "[find_gcc]" + } + } + + if ![info exists tmpdir] { + set tmpdir "/tmp" + } + + if [info exists gluefile] { + unset gluefile + } + + if {![info exists CFLAGS]} { + set CFLAGS "" + } + + # Locate libgcc.a so we don't need to account for different values of + # SHLIB_EXT on different platforms + set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] + if {$gccdir != ""} { + set gccdir [file dirname $gccdir] + } + + # Compute what needs to be put into LD_LIBRARY_PATH + set always_ld_library_path ".:${blddir}/.libs" + + # Compute what needs to be added to the existing LD_LIBRARY_PATH. + if {$gccdir != ""} { + # Add AIX pthread directory first. + if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } { + append always_ld_library_path ":${gccdir}/pthread" + } + append always_ld_library_path ":${gccdir}" + set compiler [lindex $GCC_UNDER_TEST 0] + + if { [is_remote host] == 0 && [which $compiler] != 0 } { + foreach i "[exec $compiler --print-multi-lib]" { + set mldir "" + regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir + set mldir [string trimright $mldir "\;@"] + if { "$mldir" == "." } { + continue + } + if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { + append always_ld_library_path ":${gccdir}/${mldir}" + } + } + } + } + + set ALWAYS_CFLAGS "" + if { $blddir != "" } { + lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/" + lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}" + lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs" + } + lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.." + + # We use atomic operations in the testcases to validate results. + if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) + && [check_effective_target_ia32] } { + lappend ALWAYS_CFLAGS "additional_flags=-march=i486" + } + + if [istarget *-*-darwin*] { + lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc" + } + + if [istarget sparc*-*-*] { + lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9" + } + + if [info exists TOOL_OPTIONS] { + lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS" + } + + # Make sure that lines are not wrapped. That can confuse the + # error-message parsing machinery. + lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0" + + # Turn on transactional memory support. + lappend ALWAYS_CFLAGS "additional_flags=-fgnu-tm" +} + +# +# libitm_target_compile -- compile a source file +# + +proc libitm_target_compile { source dest type options } { + global blddir + global libitm_compile_options + global gluefile wrap_flags + global ALWAYS_CFLAGS + global GCC_UNDER_TEST + global lang_test_file + global lang_library_path + global lang_link_flags + + if { [info exists lang_test_file] } { + if { $blddir != "" } { + lappend options "ldflags=-L${blddir}/${lang_library_path}" + } + lappend options "ldflags=${lang_link_flags}" + } + + if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { + lappend options "libs=${gluefile}" + lappend options "ldflags=${wrap_flags}" + } + + lappend options "additional_flags=[libio_include_flags]" + lappend options "timeout=[timeout_value]" + lappend options "compiler=$GCC_UNDER_TEST" + + set options [concat $libitm_compile_options $options] + + if [info exists ALWAYS_CFLAGS] { + set options [concat "$ALWAYS_CFLAGS" $options] + } + + set options [dg-additional-files-options $options $source] + + set result [target_compile $source $dest $type $options] + + return $result +} + +proc libitm_option_help { } { + send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n" +} + +proc libitm_option_proc { option } { + if [regexp "^--additional_options," $option] { + global libitm_compile_options + regsub "--additional_options," $option "" option + foreach x [split $option ","] { + lappend libitm_compile_options "additional_flags=$x" + } + return 1 + } else { + return 0 + } +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c++/c++.exp b/gcc-4.7/libitm/testsuite/libitm.c++/c++.exp new file mode 100644 index 000000000..ed9b4e8dd --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c++/c++.exp @@ -0,0 +1,78 @@ +# Copyright (C) 2011, 2012 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 2 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 this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +load_lib libitm-dg.exp + +global shlib_ext + +set shlib_ext [get_shlib_extension] +# The C++ tests should be linked with g++, which defaults to -shared-libgcc. +# Doing that is currently too intrusive, so hardcode here. +set lang_link_flags "-shared-libgcc -lstdc++" +set lang_test_file_found 0 +set lang_library_path "../libstdc++-v3/src/.libs" + +# Initialize dg. +dg-init + +set blddir [lookfor_file [get_multilibs] libitm] + + +if { $blddir != "" } { + # Look for a static libstdc++ first. + if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] { + set lang_test_file "${lang_library_path}/libstdc++.a" + set lang_test_file_found 1 + # We may have a shared only build, so look for a shared libstdc++. + } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] { + set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}" + set lang_test_file_found 1 + } else { + puts "No libstdc++ library found, will not execute c++ tests" + } +} elseif { [info exists GXX_UNDER_TEST] } { + set lang_test_file_found 1 + # Needs to exist for libitm.exp. + set lang_test_file "" +} else { + puts "GXX_UNDER_TEST not defined, will not execute c++ tests" +} + +if { $lang_test_file_found } { + # Gather a list of all tests. + set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]] + + if { $blddir != "" } { + set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" + } else { + set ld_library_path "$always_ld_library_path" + } + append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] + set_ld_library_path_env_vars + + set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags" + if { [file exists $flags_file] } { + set libstdcxx_includes [exec sh $flags_file --build-includes] + } else { + set libstdcxx_includes "" + } + + # Main loop. + dg-runtest $tests "" $libstdcxx_includes +} + +# All done. +dg-finish diff --git a/gcc-4.7/libitm/testsuite/libitm.c++/dropref.C b/gcc-4.7/libitm/testsuite/libitm.c++/dropref.C new file mode 100644 index 000000000..c9bdfff32 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c++/dropref.C @@ -0,0 +1,12 @@ +/* { dg-xfail-run-if "unsupported" { *-*-* } } */ +#include <libitm.h> + +char *pp; + +int main() +{ + __transaction_atomic { + _ITM_dropReferences (pp, 555); + } + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c++/eh-1.C b/gcc-4.7/libitm/testsuite/libitm.c++/eh-1.C new file mode 100644 index 000000000..49e2213e1 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c++/eh-1.C @@ -0,0 +1,36 @@ +// { dg-do run } + +extern "C" void abort (); + +int dothrow; +int g; + +static void f1() +{ + g++; + if (dothrow) + throw 1; +} + +static void f2() +{ + __transaction_atomic { + f1(); + } +} + +int main() +{ + dothrow = 0; + f2(); + + dothrow = 1; + try { + f2(); + } catch (...) { + } + + if (g != 2) + abort (); + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c++/static_ctor.C b/gcc-4.7/libitm/testsuite/libitm.c++/static_ctor.C new file mode 100644 index 000000000..1420fd328 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c++/static_ctor.C @@ -0,0 +1,40 @@ +/* { dg-do run } */ +/* { dg-options "-pthread" } */ +/* { dg-skip-if "PR libitm/51822" { *-*-* } } */ +/* Tests static constructors inside of transactional code. */ + +#include <pthread.h> +#include <stdlib.h> + +int f(int x) __attribute__((noinline,transaction_safe)); +int f(int x) +{ + static int y = x; + return y*x; +} + +static void *thread (void *) +{ + int bar; + __transaction_atomic { bar = f(10); } + if (bar != 100) + abort(); + return 0; +} + +int main() +{ + int bar; + + // First, initialize y in another thread. + pthread_t pt; + pthread_create(&pt, NULL, thread, NULL); + pthread_join(pt, NULL); + + // Now y should already be initialized. + __transaction_atomic { bar = f(20); } + if (bar != 200) + abort(); + + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c++/throwdown.C b/gcc-4.7/libitm/testsuite/libitm.c++/throwdown.C new file mode 100644 index 000000000..8c6550865 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c++/throwdown.C @@ -0,0 +1,13 @@ +// { dg-do compile } + +#include <libitm.h> + +static void throwit() { + throw 1; +} + +void tranfunc() { + __transaction_atomic { + throwit(); + } +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/c.exp b/gcc-4.7/libitm/testsuite/libitm.c/c.exp new file mode 100644 index 000000000..f7229a5bc --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/c.exp @@ -0,0 +1,44 @@ +# 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 2 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 this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +if [info exists lang_library_path] then { + unset lang_library_path + unset lang_link_flags +} +if [info exists lang_test_file] then { + unset lang_test_file +} + +load_lib libitm-dg.exp + +# If a testcase doesn't have special options, use these. +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS "-O2" +} + +# Initialize dg. +dg-init + +# Gather a list of all tests. +set tests [lsort [find $srcdir/$subdir *.c]] + +set ld_library_path $always_ld_library_path +append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] +set_ld_library_path_env_vars + +# Main loop. +dg-runtest $tests "" $DEFAULT_CFLAGS + +# All done. +dg-finish diff --git a/gcc-4.7/libitm/testsuite/libitm.c/cancel.c b/gcc-4.7/libitm/testsuite/libitm.c/cancel.c new file mode 100644 index 000000000..28276db07 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/cancel.c @@ -0,0 +1,55 @@ +#include <stdlib.h> +#include <libitm.h> + +unsigned char pp[100]; + +void __attribute((transaction_may_cancel_outer,noinline)) cancel1() +{ + __transaction_cancel [[outer]]; +} + +int a, b; + +int main() +{ + a = b = 0; + + __transaction_atomic { + a = 1; + __transaction_atomic { + b = 1; + __transaction_cancel; + } + } + if (a != 1 || b != 0) + abort(); + if (_ITM_inTransaction() != outsideTransaction) + abort(); + + __transaction_atomic [[outer]] { + a = 2; + __transaction_atomic { + b = 2; + __transaction_cancel [[outer]]; + } + } + if (a != 1 || b != 0) + abort(); + if (_ITM_inTransaction() != outsideTransaction) + abort(); + + __transaction_atomic [[outer]] { + a = 2; + __transaction_atomic { + b = 2; + __transaction_cancel [[outer]]; + cancel1(); + } + } + if (a != 1 || b != 0) + abort(); + if (_ITM_inTransaction() != outsideTransaction) + abort(); + + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/clone-1.c b/gcc-4.7/libitm/testsuite/libitm.c/clone-1.c new file mode 100644 index 000000000..03e62664d --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/clone-1.c @@ -0,0 +1,28 @@ +/* Verify that we can look up tm clone of transaction_callable + and transaction_pure. */ + +#include <stdlib.h> +#include <libitm.h> + +static int x; + +int __attribute__((transaction_pure)) pure(int i) +{ + return i+2; +} + +int __attribute__((transaction_callable)) callable(void) +{ + return ++x; +} + +int main() +{ + if (_ITM_getTMCloneSafe (&pure) != &pure) + abort (); + + if (_ITM_getTMCloneSafe (&callable) == NULL) + abort (); + + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/dropref-2.c b/gcc-4.7/libitm/testsuite/libitm.c/dropref-2.c new file mode 100644 index 000000000..5bb2726db --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/dropref-2.c @@ -0,0 +1,36 @@ +/* { dg-xfail-run-if "unsupported" { *-*-* } } */ +#include <stdlib.h> +#include <libitm.h> + +/* Test that _ITM_dropReferences() forces a commit of given chunk. */ + +unsigned char pp[100]; + +int main() +{ + int i; + + for(i=0; i < 100; ++i) + pp[i]=0x22; + + __transaction_atomic { + for(i=0; i < 100; ++i) + pp[i]=0x33; + + /* This should write-through pp[0..49]... */ + _ITM_dropReferences (pp, 50); + + /* ...while this should revert everything but pp[0..49]. */ + __transaction_cancel; + } + + for(i=0; i < 50; ++i) + if (pp[i] != 0x33) + abort(); + + for(i=50; i < 100; ++i) + if (pp[i] != 0x22) + abort(); + + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/dropref.c b/gcc-4.7/libitm/testsuite/libitm.c/dropref.c new file mode 100644 index 000000000..c9bdfff32 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/dropref.c @@ -0,0 +1,12 @@ +/* { dg-xfail-run-if "unsupported" { *-*-* } } */ +#include <libitm.h> + +char *pp; + +int main() +{ + __transaction_atomic { + _ITM_dropReferences (pp, 555); + } + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/memcpy-1.c b/gcc-4.7/libitm/testsuite/libitm.c/memcpy-1.c new file mode 100644 index 000000000..03b381285 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/memcpy-1.c @@ -0,0 +1,160 @@ +/* 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 2 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 this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Verify memcpy operation. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/mman.h> +#include <libitm.h> + +#define BEG_TRANSACTION \ + _ITM_beginTransaction (pr_instrumentedCode | pr_hasNoAbort \ + | pr_hasNoIrrevocable) +#define END_TRANSACTION \ + _ITM_commitTransaction () + +#define MEMCPY _ITM_memcpyRtWt + +static unsigned char *buf1, *buf2; +static size_t bufsize, page_size; +static int fail; + +static void +do_test (size_t align1, size_t align2, size_t len) +{ + size_t i, j; + unsigned char *s1, *s2; + unsigned char c1, c2; + + if (align1 + len >= bufsize) + return; + if (align2 + len >= bufsize) + return; + + c1 = random () >> 8; + c2 = random () >> 8; + memset (buf1, c1, bufsize); + memset (buf2, c2, bufsize); + + s1 = buf1 + align1; + s2 = buf2 + align2; + + for (i = 0, j = 1; i < len; i++, j += 23) + s1[i] = (j == c1 ? j + 1 : j); + + BEG_TRANSACTION; + MEMCPY (s2, s1, len); + END_TRANSACTION; + + if (memcmp (s1, s2, len) != 0) + { + printf ("Wrong result: dalign %zd salign %zd len %zd\n", + align2, align1, len); + fail = 1; + return; + } + + for (i = (align2 > 64 ? align2 - 64 : 0); i < align2; ++i) + if (buf2[i] != c2) + { + printf ("Garbage before: ofs %zd\n", i); + fail = 1; + break; + } + for (i = align2 + len, j = i+64 < bufsize ? i+64 : bufsize; i < j; ++i) + if (buf2[i] != c2) + { + printf ("Garbage after: ofs %zd\n", i); + fail = 1; + break; + } +} + +#ifndef MAP_ANONYMOUS +# ifdef MAP_ANON +# define MAP_ANONYMOUS MAP_ANON +# endif +#endif + +int main() +{ + size_t i, j; + + page_size = getpagesize (); + bufsize = 2 * page_size; + + buf1 = mmap (NULL, bufsize + 2*page_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (buf1 == MAP_FAILED) + return 1; + buf2 = mmap (NULL, bufsize + 2*page_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (buf2 == MAP_FAILED) + return 1; + + if (mprotect (buf1, page_size, PROT_NONE)) + return 1; + buf1 += page_size; + if (mprotect (buf1 + bufsize, page_size, PROT_NONE)) + return 1; + + if (mprotect (buf2, page_size, PROT_NONE)) + return 1; + buf2 += page_size; + if (mprotect (buf2 + bufsize, page_size, PROT_NONE)) + return 1; + + for (i = 0; i < 18; ++i) + { + size_t len = 1 << i; + + do_test (0, 0, len); + do_test (i, 0, len); + do_test (0, i, len); + do_test (i, i, len); + + do_test (0, bufsize - len, len); + do_test (bufsize - len, 0, len); + do_test (i, bufsize - len, len); + do_test (bufsize - len, i, len); + } + + for (i = 0; i < 32; ++i) + { + do_test (i, 0, i); + do_test (0, i, i); + do_test (i, i, i); + + for (j = 0; j < 32; ++j) + { + do_test (i, bufsize - i - j, i); + do_test (bufsize - i - j, i, i); + } + } + + for (i = 3; i < 32; ++i) + { + if ((i & (i - 1)) == 0) + continue; + do_test (0, 0, 16 * i); + do_test (i, 0, 16 * i); + do_test (0, i, 16 * i); + do_test (i, i, 16 * i); + } + + return fail; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/memset-1.c b/gcc-4.7/libitm/testsuite/libitm.c/memset-1.c new file mode 100644 index 000000000..11aea458c --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/memset-1.c @@ -0,0 +1,123 @@ +/* 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 2 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 this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Verify memcpy operation. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/mman.h> +#include <libitm.h> + +#define BEG_TRANSACTION \ + _ITM_beginTransaction (pr_instrumentedCode | pr_hasNoAbort \ + | pr_hasNoIrrevocable) +#define END_TRANSACTION \ + _ITM_commitTransaction () + +#define MEMSET _ITM_memsetW + +static unsigned char *buf; +static size_t bufsize, page_size; +static int fail; + +#ifndef MAP_ANONYMOUS +# ifdef MAP_ANON +# define MAP_ANONYMOUS MAP_ANON +# endif +#endif + +static void +do_test (size_t align, size_t len) +{ + size_t i, j; + unsigned char c1, c2; + + if (align + len >= bufsize) + return; + + c1 = random () >> 8; + c2 = random () >> 8; + if (c1 == c2) + c1++; + memset (buf, c1, bufsize); + + BEG_TRANSACTION; + MEMSET (buf + align, c2, len); + END_TRANSACTION; + + i = (align > 64 ? align - 64 : 0); + for (; i < align; ++i) + if (buf[i] != c1) + { + printf ("Garbage before: ofs %zd\n", i); + fail = 1; + break; + } + for (; i < align + len; ++i) + if (buf[i] != c2) + { + printf ("Wrong result: ofs %zd\n", i); + fail = 1; + break; + } + for (j = i + 64 < bufsize ? i + 64 : bufsize; i < j; ++i) + if (buf[i] != c1) + { + printf ("Garbage after: ofs %zd\n", i); + fail = 1; + break; + } +} + +int main() +{ + size_t i, j; + + page_size = getpagesize (); + bufsize = 2 * page_size; + + buf = mmap (NULL, bufsize + 2*page_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (buf == MAP_FAILED) + return 1; + + if (mprotect (buf, page_size, PROT_NONE)) + return 1; + buf += page_size; + if (mprotect (buf + bufsize, page_size, PROT_NONE)) + return 1; + + for (i = 0; i < 18; ++i) + { + size_t len = 1 << i; + do_test (0, len); + do_test (bufsize - len, len); + } + + for (i = 0; i < 32; ++i) + for (j = 0; j < 32; ++j) + do_test (j, i); + + for (i = 3; i < 32; ++i) + { + if ((i & (i - 1)) == 0) + continue; + do_test (0, 16 * i); + do_test (i, 16 * i); + } + + return fail; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/notx.c b/gcc-4.7/libitm/testsuite/libitm.c/notx.c new file mode 100644 index 000000000..7ca658045 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/notx.c @@ -0,0 +1,36 @@ +/* These tests all check whether initialization happens properly even if no + transaction has been used in the current thread yet. */ + +/* { dg-options "-pthread" } */ + +#include <stdlib.h> +#include <pthread.h> +#include <libitm.h> + +static void *test1 (void *dummy __attribute__((unused))) +{ + if (_ITM_inTransaction() != outsideTransaction) + abort(); + return NULL; +} + +static void *test2 (void *dummy __attribute__((unused))) +{ + if (_ITM_getTransactionId() != _ITM_noTransactionId) + abort(); + return NULL; +} + + +int main() +{ + pthread_t thread; + + pthread_create(&thread, NULL, test1, NULL); + pthread_join(thread, NULL); + + pthread_create(&thread, NULL, test2, NULL); + pthread_join(thread, NULL); + + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/reentrant.c b/gcc-4.7/libitm/testsuite/libitm.c/reentrant.c new file mode 100644 index 000000000..e8f49ba3e --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/reentrant.c @@ -0,0 +1,67 @@ +/* { dg-do run } */ +/* { dg-options "-pthread" } */ + +/* Tests that new transactions can be started from both transaction_pure and + transaction_unsafe code. This also requires proper handling of reentrant + nesting in the serial_lock implementation. */ + +#include <stdlib.h> +#include <pthread.h> +#include <libitm.h> + +int x = 0; + +int __attribute__((transaction_pure)) pure(int i) +{ + __transaction_atomic { + x++; + } + if (_ITM_inTransaction() == outsideTransaction) + abort(); + return i+1; +} + +int __attribute__((transaction_unsafe)) unsafe(int i) +{ + if (_ITM_inTransaction() != inIrrevocableTransaction) + abort(); + __transaction_atomic { + x++; + } + if (_ITM_inTransaction() != inIrrevocableTransaction) + abort(); + return i+1; +} + +static void *thread (void *dummy __attribute__((unused))) +{ + __transaction_atomic { + pure(x); + } + __transaction_relaxed { + unsafe(1); + } + return 0; +} + +int main() +{ + pthread_t pt; + int r = 0; + + __transaction_atomic { + r += pure(1) + x; + } + __transaction_relaxed { + r += unsafe(1) + x; + } + if (r != 7) + abort(); + + // Spawn a new thread to check that the serial lock is not held. + pthread_create(&pt, NULL, thread, NULL); + pthread_join(pt, NULL); + if (x != 4) + abort(); + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/simple-1.c b/gcc-4.7/libitm/testsuite/libitm.c/simple-1.c new file mode 100644 index 000000000..de41740d4 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/simple-1.c @@ -0,0 +1,24 @@ +/* Verify that two sequential runs of a transaction will complete and + produce correct results. An early test of the library did in fact + leave things in an inconsistent state following the commit of the + first transaction. */ + +#include <stdlib.h> + +static int x; + +static void start (void) +{ + __transaction_atomic { x++; } +} + +int main() +{ + start (); + start (); + + if (x != 2) + abort (); + + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/simple-2.c b/gcc-4.7/libitm/testsuite/libitm.c/simple-2.c new file mode 100644 index 000000000..c77d75dcf --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/simple-2.c @@ -0,0 +1,31 @@ +/* Simplest test involving real threads. Verify we get the correct answer. */ + +/* { dg-options "-pthread" } */ + +#include <stdlib.h> +#include <pthread.h> + +static int x; + +static void *start (void *dummy __attribute__((unused))) +{ + __transaction_atomic { x++; } + return NULL; +} + +int main() +{ + pthread_t p[10]; + int i; + + for (i = 0; i < 10; ++i) + pthread_create (p+i, NULL, start, NULL); + + for (i = 0; i < 10; ++i) + pthread_join (p[i], NULL); + + if (x != 10) + abort (); + + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/stackundo.c b/gcc-4.7/libitm/testsuite/libitm.c/stackundo.c new file mode 100644 index 000000000..02759d770 --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/stackundo.c @@ -0,0 +1,23 @@ +int __attribute__((noinline)) test2(int x[1000]) +{ + int i; + return x[12]; +} + +int __attribute__((noinline)) test1() +{ + int x[1000], i; + + for (i = 0; i < 1000; i++) + x[i] = i; + return test2(x); +} + +int main() +{ + __transaction_atomic { + if (test1() !=0) + __transaction_cancel; + } + return 0; +} diff --git a/gcc-4.7/libitm/testsuite/libitm.c/txrelease.c b/gcc-4.7/libitm/testsuite/libitm.c/txrelease.c new file mode 100644 index 000000000..37d6b2c9d --- /dev/null +++ b/gcc-4.7/libitm/testsuite/libitm.c/txrelease.c @@ -0,0 +1,49 @@ +/* This test triggers execution of the code that releases per-thread + transaction data when a thread exists, potentially repeatedly. However, + we currently cannot check whether the data has indeed been released. */ + +/* { dg-options "-pthread" } */ + +#include <stddef.h> +#include <stdlib.h> +#include <pthread.h> + +static int round = 0; +static pthread_key_t key; + +static void +thread_exit_handler(void *dummy __attribute__((unused))) +{ + if (round == 0) + abort(); + if (round == 1) + { + // ??? It would be good if we could check here that the transaction has + // indeed been released. + __transaction_atomic { round++; } + if (pthread_setspecific(key, &round)) + abort(); + } + // ??? It would be good if we could check here that the transaction has + // indeed been released (again). +} + +static void *thread (void *dummy __attribute__((unused))) +{ + if (pthread_key_create(&key, thread_exit_handler)) + abort(); + if (pthread_setspecific(key, &round)) + abort(); + __transaction_atomic { round++; } + return NULL; +} + +int main() +{ + pthread_t pt; + pthread_create(&pt, NULL, thread, NULL); + pthread_join(pt, NULL); + if (round != 2) + abort(); + return 0; +} |