diff options
author | Iain Buclaw <ibuclaw@gcc.gnu.org> | 2018-10-28 19:51:47 +0000 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gcc.gnu.org> | 2018-10-28 19:51:47 +0000 |
commit | b4c522fabd0df7be08882d2207df8b2765026110 (patch) | |
tree | b5ffc312b0a441c1ba24323152aec463fdbe5e9f /libphobos/testsuite | |
parent | 01ce9e31a02c8039d88e90f983735104417bf034 (diff) | |
download | gcc-b4c522fabd0df7be08882d2207df8b2765026110.zip gcc-b4c522fabd0df7be08882d2207df8b2765026110.tar.gz gcc-b4c522fabd0df7be08882d2207df8b2765026110.tar.bz2 |
Add D front-end, libphobos library, and D2 testsuite.
ChangeLog:
* Makefile.def (target_modules): Add libphobos.
(flags_to_pass): Add GDC, GDCFLAGS, GDC_FOR_TARGET and
GDCFLAGS_FOR_TARGET.
(dependencies): Make libphobos depend on libatomic, libbacktrace
configure, and zlib configure.
(language): Add language d.
* Makefile.in: Rebuild.
* Makefile.tpl (BUILD_EXPORTS): Add GDC and GDCFLAGS.
(HOST_EXPORTS): Add GDC.
(POSTSTAGE1_HOST_EXPORTS): Add GDC and GDC_FOR_BUILD.
(BASE_TARGET_EXPORTS): Add GDC.
(GDC_FOR_BUILD, GDC, GDCFLAGS): New variables.
(GDC_FOR_TARGET, GDC_FLAGS_FOR_TARGET): New variables.
(EXTRA_HOST_FLAGS): Add GDC.
(STAGE1_FLAGS_TO_PASS): Add GDC.
(EXTRA_TARGET_FLAGS): Add GDC and GDCFLAGS.
* config-ml.in: Treat GDC and GDCFLAGS like other compiler/flag
environment variables.
* configure: Rebuild.
* configure.ac: Add target-libphobos to target_libraries. Set and
substitute GDC_FOR_BUILD and GDC_FOR_TARGET.
config/ChangeLog:
* multi.m4: Set GDC.
gcc/ChangeLog:
* Makefile.in (tm_d_file_list, tm_d_include_list): New variables.
(TM_D_H, D_TARGET_DEF, D_TARGET_H, D_TARGET_OBJS): New variables.
(tm_d.h, cs-tm_d.h, default-d.o): New rules.
(d/d-target-hooks-def.h, s-d-target-hooks-def-h): New rules.
(s-tm-texi): Also check timestamp on d-target.def.
(generated_files): Add TM_D_H and d-target-hooks-def.h.
(build/genhooks.o): Also depend on D_TARGET_DEF.
* config.gcc (tm_d_file, d_target_objs, target_has_targetdm): New
variables.
* config/aarch64/aarch64-d.c: New file.
* config/aarch64/aarch64-linux.h (GNU_USER_TARGET_D_CRITSEC_SIZE):
Define.
* config/aarch64/aarch64-protos.h (aarch64_d_target_versions): New
prototype.
* config/aarch64/aarch64.h (TARGET_D_CPU_VERSIONS): Define.
* config/aarch64/t-aarch64 (aarch64-d.o): New rule.
* config/arm/arm-d.c: New file.
* config/arm/arm-protos.h (arm_d_target_versions): New prototype.
* config/arm/arm.h (TARGET_D_CPU_VERSIONS): Define.
* config/arm/linux-eabi.h (EXTRA_TARGET_D_OS_VERSIONS): Define.
* config/arm/t-arm (arm-d.o): New rule.
* config/default-d.c: New file.
* config/glibc-d.c: New file.
* config/gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/i386/i386-d.c: New file.
* config/i386/i386-protos.h (ix86_d_target_versions): New prototype.
* config/i386/i386.h (TARGET_D_CPU_VERSIONS): Define.
* config/i386/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Define.
(GNU_USER_TARGET_D_CRITSEC_SIZE): Define.
* config/i386/t-i386 (i386-d.o): New rule.
* config/kfreebsd-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/kopensolaris-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/linux-android.h (ANDROID_TARGET_D_OS_VERSIONS): Define.
* config/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/mips/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Define.
* config/mips/mips-d.c: New file.
* config/mips/mips-protos.h (mips_d_target_versions): New prototype.
* config/mips/mips.h (TARGET_D_CPU_VERSIONS): Define.
* config/mips/t-mips (mips-d.o): New rule.
* config/powerpcspe/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/powerpcspe/linux64.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/powerpcspe/powerpcspe-d.c: New file.
* config/powerpcspe/powerpcspe-protos.h (rs6000_d_target_versions):
New prototype.
* config/powerpcspe/powerpcspe.c (rs6000_output_function_epilogue):
Support GNU D by using 0 as the language type.
* config/powerpcspe/powerpcspe.h (TARGET_D_CPU_VERSIONS): Define.
* config/powerpcspe/t-powerpcspe (powerpcspe-d.o): New rule.
* config/riscv/riscv-d.c: New file.
* config/riscv/riscv-protos.h (riscv_d_target_versions): New
prototype.
* config/riscv/riscv.h (TARGET_D_CPU_VERSIONS): Define.
* config/riscv/t-riscv (riscv-d.o): New rule.
* config/rs6000/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/rs6000/linux64.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/rs6000/rs6000-d.c: New file.
* config/rs6000/rs6000-protos.h (rs6000_d_target_versions): New
prototype.
* config/rs6000/rs6000.c (rs6000_output_function_epilogue):
Support GNU D by using 0 as the language type.
* config/rs6000/rs6000.h (TARGET_D_CPU_VERSIONS): Define.
* config/rs6000/t-rs6000 (rs6000-d.o): New rule.
* config/s390/s390-d.c: New file.
* config/s390/s390-protos.h (s390_d_target_versions): New prototype.
* config/s390/s390.h (TARGET_D_CPU_VERSIONS): Define.
* config/s390/t-s390 (s390-d.o): New rule.
* config/sparc/sparc-d.c: New file.
* config/sparc/sparc-protos.h (sparc_d_target_versions): New
prototype.
* config/sparc/sparc.h (TARGET_D_CPU_VERSIONS): Define.
* config/sparc/t-sparc (sparc-d.o): New rule.
* config/t-glibc (glibc-d.o): New rule.
* configure: Regenerated.
* configure.ac (tm_d_file): New variable.
(tm_d_file_list, tm_d_include_list, d_target_objs): Add substitutes.
* doc/contrib.texi (Contributors): Add self for the D frontend.
* doc/frontends.texi (G++ and GCC): Mention D as a supported language.
* doc/install.texi (Configuration): Mention libphobos as an option for
--enable-shared. Mention d as an option for --enable-languages.
(Testing): Mention check-d as a target.
* doc/invoke.texi (Overall Options): Mention .d, .dd, and .di as file
name suffixes. Mention d as a -x option.
* doc/sourcebuild.texi (Top Level): Mention libphobos.
* doc/standards.texi (Standards): Add section on D language.
* doc/tm.texi: Regenerated.
* doc/tm.texi.in: Add @node for D language and ABI, and @hook for
TARGET_CPU_VERSIONS, TARGET_D_OS_VERSIONS, and TARGET_D_CRITSEC_SIZE.
* dwarf2out.c (is_dlang): New function.
(gen_compile_unit_die): Use DW_LANG_D for D.
(declare_in_namespace): Return module die for D, instead of adding
extra declarations into the namespace.
(gen_namespace_die): Generate DW_TAG_module for D.
(gen_decl_die): Handle CONST_DECLSs for D.
(dwarf2out_decl): Likewise.
(prune_unused_types_walk_local_classes): Handle DW_tag_interface_type.
(prune_unused_types_walk): Handle DW_tag_interface_type same as other
kinds of aggregates.
* gcc.c (default_compilers): Add entries for .d, .dd and .di.
* genhooks.c: Include d/d-target.def.
gcc/po/ChangeLog:
* EXCLUDES: Add sources from d/dmd.
gcc/testsuite/ChangeLog:
* gcc.misc-tests/help.exp: Add D to option descriptions check.
* gdc.dg/asan/asan.exp: New file.
* gdc.dg/asan/gdc272.d: New test.
* gdc.dg/compilable.d: New test.
* gdc.dg/dg.exp: New file.
* gdc.dg/gdc254.d: New test.
* gdc.dg/gdc260.d: New test.
* gdc.dg/gdc270a.d: New test.
* gdc.dg/gdc270b.d: New test.
* gdc.dg/gdc282.d: New test.
* gdc.dg/gdc283.d: New test.
* gdc.dg/imports/gdc170.d: New test.
* gdc.dg/imports/gdc231.d: New test.
* gdc.dg/imports/gdc239.d: New test.
* gdc.dg/imports/gdc241a.d: New test.
* gdc.dg/imports/gdc241b.d: New test.
* gdc.dg/imports/gdc251a.d: New test.
* gdc.dg/imports/gdc251b.d: New test.
* gdc.dg/imports/gdc253.d: New test.
* gdc.dg/imports/gdc254a.d: New test.
* gdc.dg/imports/gdc256.d: New test.
* gdc.dg/imports/gdc27.d: New test.
* gdc.dg/imports/gdcpkg256/package.d: New test.
* gdc.dg/imports/runnable.d: New test.
* gdc.dg/link.d: New test.
* gdc.dg/lto/lto.exp: New file.
* gdc.dg/lto/ltotests_0.d: New test.
* gdc.dg/lto/ltotests_1.d: New test.
* gdc.dg/runnable.d: New test.
* gdc.dg/simd.d: New test.
* gdc.test/gdc-test.exp: New file.
* lib/gdc-dg.exp: New file.
* lib/gdc.exp: New file.
libphobos/ChangeLog:
* Makefile.am: New file.
* Makefile.in: New file.
* acinclude.m4: New file.
* aclocal.m4: New file.
* config.h.in: New file.
* configure: New file.
* configure.ac: New file.
* d_rules.am: New file.
* libdruntime/Makefile.am: New file.
* libdruntime/Makefile.in: New file.
* libdruntime/__entrypoint.di: New file.
* libdruntime/__main.di: New file.
* libdruntime/gcc/attribute.d: New file.
* libdruntime/gcc/backtrace.d: New file.
* libdruntime/gcc/builtins.d: New file.
* libdruntime/gcc/config.d.in: New file.
* libdruntime/gcc/deh.d: New file.
* libdruntime/gcc/libbacktrace.d.in: New file.
* libdruntime/gcc/unwind/arm.d: New file.
* libdruntime/gcc/unwind/arm_common.d: New file.
* libdruntime/gcc/unwind/c6x.d: New file.
* libdruntime/gcc/unwind/generic.d: New file.
* libdruntime/gcc/unwind/package.d: New file.
* libdruntime/gcc/unwind/pe.d: New file.
* m4/autoconf.m4: New file.
* m4/druntime.m4: New file.
* m4/druntime/cpu.m4: New file.
* m4/druntime/libraries.m4: New file.
* m4/druntime/os.m4: New file.
* m4/gcc_support.m4: New file.
* m4/gdc.m4: New file.
* m4/libtool.m4: New file.
* src/Makefile.am: New file.
* src/Makefile.in: New file.
* src/libgphobos.spec.in: New file.
* testsuite/Makefile.am: New file.
* testsuite/Makefile.in: New file.
* testsuite/config/default.exp: New file.
* testsuite/lib/libphobos-dg.exp: New file.
* testsuite/lib/libphobos.exp: New file.
* testsuite/testsuite_flags.in: New file.
From-SVN: r265573
Diffstat (limited to 'libphobos/testsuite')
50 files changed, 2348 insertions, 0 deletions
diff --git a/libphobos/testsuite/Makefile.am b/libphobos/testsuite/Makefile.am new file mode 100644 index 0000000..d640c0b --- /dev/null +++ b/libphobos/testsuite/Makefile.am @@ -0,0 +1,32 @@ +## Makefile for the testsuite subdirectory of the D Standard library. +## Copyright (C) 2016-2018 Free Software Foundation, Inc. +## +## GCC 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, or (at your option) +## any later version. +## +## GCC 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/>. + +# Process this file with automake to produce Makefile.in. + +AUTOMAKE_OPTIONS = foreign dejagnu + +# Setup the testing framework, if you have one +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)" + +AM_MAKEFLAGS = "EXEEXT=$(EXEEXT)" + +CLEANFILES = *.log *.sum diff --git a/libphobos/testsuite/Makefile.in b/libphobos/testsuite/Makefile.in new file mode 100644 index 0000000..ab18deb --- /dev/null +++ b/libphobos/testsuite/Makefile.in @@ -0,0 +1,454 @@ +# Makefile.in generated by automake 1.11.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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@ + +# Process this file with automake to produce Makefile.in. +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +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.in $(srcdir)/Makefile.am \ + $(srcdir)/testsuite_flags.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/override.m4 \ + $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ + $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ + $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/m4/gcc_support.m4 $(top_srcdir)/m4/autoconf.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/gdc.m4 \ + $(top_srcdir)/m4/druntime.m4 $(top_srcdir)/m4/druntime/cpu.m4 \ + $(top_srcdir)/m4/druntime/os.m4 \ + $(top_srcdir)/m4/druntime/libraries.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 = testsuite_flags +CONFIG_CLEAN_VPATH_FILES = +depcomp = +am__depfiles_maybe = +SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +DEJATOOL = $(PACKAGE) +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BACKTRACE_SUPPORTED = @BACKTRACE_SUPPORTED@ +BACKTRACE_SUPPORTS_THREADS = @BACKTRACE_SUPPORTS_THREADS@ +BACKTRACE_USES_MALLOC = @BACKTRACE_USES_MALLOC@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CFLAGS = @CFLAGS@ +CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DCFG_ARM_EABI_UNWINDER = @DCFG_ARM_EABI_UNWINDER@ +DCFG_HAVE_64BIT_ATOMICS = @DCFG_HAVE_64BIT_ATOMICS@ +DCFG_HAVE_ATOMIC_BUILTINS = @DCFG_HAVE_ATOMIC_BUILTINS@ +DCFG_HAVE_LIBATOMIC = @DCFG_HAVE_LIBATOMIC@ +DCFG_MINFO_BRACKETING = @DCFG_MINFO_BRACKETING@ +DCFG_THREAD_MODEL = @DCFG_THREAD_MODEL@ +DEFS = @DEFS@ +DRUNTIME_SOVERSION = @DRUNTIME_SOVERSION@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDC = @GDC@ +GDCFLAGS = @GDCFLAGS@ +GDCFLAGSX = @GDCFLAGSX@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBATOMIC = @LIBATOMIC@ +LIBBACKTRACE = @LIBBACKTRACE@ +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@ +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@ +PHOBOS_SOVERSION = @PHOBOS_SOVERSION@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SPEC_PHOBOS_DEPS = @SPEC_PHOBOS_DEPS@ +STRIP = @STRIP@ +VERSION = @VERSION@ +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_DUMPBIN = @ac_ct_DUMPBIN@ +am__leading_dot = @am__leading_dot@ +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@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gcc_version = @gcc_version@ +gdc_include_dir = @gdc_include_dir@ +get_gcc_base_ver = @get_gcc_base_ver@ +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@ +libphobos_builddir = @libphobos_builddir@ +libphobos_srcdir = @libphobos_srcdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +multi_basedir = @multi_basedir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +phobos_compiler_pic_flag = @phobos_compiler_pic_flag@ +phobos_compiler_shared_flag = @phobos_compiler_shared_flag@ +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 + +# Setup the testing framework, if you have one +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)" +AM_MAKEFLAGS = "EXEEXT=$(EXEEXT)" +CLEANFILES = *.log *.sum +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 --ignore-deps testsuite/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign --ignore-deps 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): +testsuite_flags: $(top_builddir)/config.status $(srcdir)/testsuite_flags.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +check-DEJAGNU: site.exp + srcdir='$(srcdir)'; 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 $(EXTRA_DEJAGNU_SITE_CONFIG) + @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 + @list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \ + echo "## Begin content included from file $$f. Do not modify. ##" \ + && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \ + && echo "## End content included from file $$f. ##" \ + || exit 1; \ + done >> site.tmp + @echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp + @if test -f site.exp; then \ + sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \ + fi + @-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 +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: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +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 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/libphobos/testsuite/config/default.exp b/libphobos/testsuite/config/default.exp new file mode 100644 index 0000000..10dc931 --- /dev/null +++ b/libphobos/testsuite/config/default.exp @@ -0,0 +1,17 @@ +# Copyright (C) 2017-2018 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/>. + +load_lib "standard.exp" diff --git a/libphobos/testsuite/lib/libphobos-dg.exp b/libphobos/testsuite/lib/libphobos-dg.exp new file mode 100644 index 0000000..ffb2ba3 --- /dev/null +++ b/libphobos/testsuite/lib/libphobos-dg.exp @@ -0,0 +1,52 @@ +# Copyright (C) 2017-2018 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/>. + +load_gcc_lib multiline.exp +load_gcc_lib prune.exp +load_gcc_lib scandump.exp +load_gcc_lib scanltranstree.exp +load_gcc_lib scanwpaipa.exp +load_gcc_lib file-format.exp +load_gcc_lib scanasm.exp +load_gcc_lib scanlang.exp +load_gcc_lib scanrtl.exp +load_gcc_lib scantree.exp +load_gcc_lib scanipa.exp +load_gcc_lib torture-options.exp +load_gcc_lib timeout-dg.exp +load_gcc_lib fortran-modules.exp +load_gcc_lib gcc-dg.exp + +# Utility routines. + +# +# libphobos_load -- wrapper around default libphobos_load to handle tests that +# require program arguments passed to them. +# + +if { [info procs libphobos_load] != [list] \ + && [info procs prev_libphobos_load] == [list] } { + rename libphobos_load prev_libphobos_load + + proc libphobos_load { program args } { + global libphobos_run_args + if { $libphobos_run_args != "" } { + set args [concat "{$libphobos_run_args}"] + } + set result [eval [list prev_libphobos_load $program] $args ] + return $result + } +} diff --git a/libphobos/testsuite/lib/libphobos.exp b/libphobos/testsuite/lib/libphobos.exp new file mode 100644 index 0000000..7dbf667 --- /dev/null +++ b/libphobos/testsuite/lib/libphobos.exp @@ -0,0 +1,193 @@ +# Copyright (C) 2017-2018 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/>. + +# +# DejaGnu does not have proper library search paths for load_lib. +# We have to explicitly load everything that gdc.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_lib libgloss.exp + +load_gcc_lib target-supports.exp +load_gcc_lib target-supports-dg.exp +load_gcc_lib dg-options.exp +load_gcc_lib target-libpath.exp +load_gcc_lib timeout.exp +load_gcc_lib wrapper.exp +load_gcc_lib target-utils.exp +load_gcc_lib gcc-defs.exp + +set TESTING_IN_BUILD_TREE 1 + +# Define libphobos callbacks for dg.exp. + +proc libphobos-dg-test { prog do_what extra_tool_flags } { + set compile_type "" + set output_file "" + + # Set up the compiler flags, based on what we're going to do. + switch $do_what { + "run" { + set compile_type "executable" + # FIXME: "./" is to cope with "." not being in $PATH. + # Should this be handled elsewhere? + # YES. + set output_file "./[file rootname [file tail $prog]].exe" + # This is the only place where we care if an executable was + # created or not. If it was, dg.exp will try to run it. + catch { remote_file build delete $output_file } + } + "link" { + set compile_type "executable" + set output_file "./[file rootname [file tail $prog]].exe" + } + default { + perror "$do_what: not a valid dg-do keyword" + return "" + } + } + + set select_compile "libphobos_target_compile" + set options "" + if { $extra_tool_flags != "" } { + lappend options "additional_flags=$extra_tool_flags" + } + + set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options] + + return [list $comp_output $output_file] +} + +# +# libphobos_init +# + +proc libphobos_init { args } { + global env + global srcdir blddir objdir tool_root_dir + global exeext + global gdc gdcflags + global gdcpaths gdcldflags + global gluefile wrap_flags + global ld_library_path + global DEFAULT_DFLAGS + + # If a testcase doesn't have special options, use these. + if ![info exists DEFAULT_DFLAGS] then { + set DEFAULT_DFLAGS "" + } + + # By default, we assume we want to run program images. + global dg-do-what-default + if [isnative] { + set dg-do-what-default "run" + } else { + set dg-do-what-default "link" + } + + # What arguments to pass to run program images. + global libphobos_run_args + set libphobos_run_args "" + + # Default settings. + set blddir [lookfor_file [get_multilibs] libphobos] + set flags_file "${blddir}/testsuite/testsuite_flags" + set shlib_ext [get_shlib_extension] + + set gdc [transform "gdc"] + set gdcflags "-fmessage-length=0" + set gdcpaths "-I${srcdir}" + set gdcldflags "" + + if { [file exists $flags_file] } { + set gdc [exec sh $flags_file --gdc] + set gdcflags [exec sh $flags_file --gdcflags] + set gdcpaths [exec sh $flags_file --gdcpaths] + set gdcldflags [exec sh $flags_file --gdcldflags] + } + + set exeext "" + if [info exists env(EXEEXT)] { + set exeext $env(EXEEXT) + } + + # Compute what needs to be added to the existing LD_LIBRARY_PATH. + set ld_library_path "" + + set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] + if {$gccdir != ""} { + set gccdir [file dirname $gccdir] + append ld_library_path ":${gccdir}" + } + + if { [file exists "${blddir}/libdruntime/.libs/libgdruntime.${shlib_ext}"] } { + append ld_library_path ":${blddir}/libdruntime/.libs" + } + + if { [file exists "${blddir}/src/.libs/libgphobos.${shlib_ext}"] } { + append ld_library_path ":${blddir}/src/.libs" + } + + set_ld_library_path_env_vars + + libphobos_maybe_build_wrapper "${objdir}/testglue.o" +} + +# +# libphobos_target_compile -- compile a source file. +# + +proc libphobos_target_compile { source dest type options } { + global gdc gdcflags + global gdcpaths gdcldflags + global gluefile wrap_flags + + lappend options "additional_flags=-fno-diagnostics-show-caret -fdiagnostics-color=never" + + if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { + lappend options "libs=${gluefile}" + lappend options "ldflags=${wrap_flags}" + } + + # Flag setting based on type argument. + if { $type == "executable" } { + # Link the support objects into executables. + lappend options "additional_flags=$gdcldflags" + } + + # Set the compiler, only add D flags and paths if building D sources. + set gdc_final $gdc + if [regexp ".*\.d\$" $source] { + set gdc_final [concat $gdc_final $gdcflags] + set gdc_final [concat $gdc_final $gdcpaths] + } + + lappend options "compiler=$gdc_final" + lappend options "timeout=[timeout_value]" + + set options [dg-additional-files-options $options $source] + set comp_output [target_compile $source $dest $type $options] + + return $comp_output +} diff --git a/libphobos/testsuite/libphobos.allocations/allocations.exp b/libphobos/testsuite/libphobos.allocations/allocations.exp new file mode 100644 index 0000000..d744b74 --- /dev/null +++ b/libphobos/testsuite/libphobos.allocations/allocations.exp @@ -0,0 +1,29 @@ +# Copyright (C) 2017-2018 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/>. + +load_lib libphobos-dg.exp + +# Initialize dg. +dg-init + +# Gather a list of all tests. +set tests [lsort [find $srcdir/$subdir *.d]] + +# Main loop. +dg-runtest $tests "" $DEFAULT_DFLAGS + +# All done. +dg-finish diff --git a/libphobos/testsuite/libphobos.allocations/overflow_from_existing.d b/libphobos/testsuite/libphobos.allocations/overflow_from_existing.d new file mode 100644 index 0000000..c41b29f --- /dev/null +++ b/libphobos/testsuite/libphobos.allocations/overflow_from_existing.d @@ -0,0 +1,8 @@ +// { dg-shouldfail "Memory allocation failed" } +// { dg-output "core.exception.OutOfMemoryError@.*: Memory allocation failed" } +void main() +{ + void[] buffer; + buffer.length = 1; + buffer.length = size_t.max; +} diff --git a/libphobos/testsuite/libphobos.allocations/overflow_from_zero.d b/libphobos/testsuite/libphobos.allocations/overflow_from_zero.d new file mode 100644 index 0000000..de48773 --- /dev/null +++ b/libphobos/testsuite/libphobos.allocations/overflow_from_zero.d @@ -0,0 +1,8 @@ +// { dg-shouldfail "Memory allocation failed" } +// { dg-output "core.exception.OutOfMemoryError@.*: Memory allocation failed" } +void main() +{ + void[] buffer; + buffer.length = 0; + buffer.length = size_t.max; +} diff --git a/libphobos/testsuite/libphobos.cycles/cycles.exp b/libphobos/testsuite/libphobos.cycles/cycles.exp new file mode 100644 index 0000000..21529e4 --- /dev/null +++ b/libphobos/testsuite/libphobos.cycles/cycles.exp @@ -0,0 +1,53 @@ +# Copyright (C) 2017-2018 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/>. + +load_lib libphobos-dg.exp + +set dg-output-text [list] + +# Arguments to pass to the test program, expected output, and return code. +set cycle_test_list [list \ + { ignore "" 0 } \ + { abort "object.Error@.*: Cyclic dependency between module mod. and mod." 1 } \ + { print "Cyclic dependency between module mod. and mod." 0 } \ + { deprecate "Deprecation 16211 warning:" 0 } \ +] + +# Initialize dg. +dg-init + +# Gather a list of all tests. +set tests [lsort [find $srcdir/$subdir *.d]] + +# Main loop. +foreach cycle_test $cycle_test_list { + # The set the argument to pass to the program. + set libphobos_run_args "--DRT-oncycle=[lindex $cycle_test 0]" + + # Whether the program is expected to fail. + set expected_fail [lindex $cycle_test 2] + + foreach test $tests { + set shouldfail $expected_fail + dg-test $test "" $DEFAULT_DFLAGS + } + + set shouldfail 0 + set libphobos_run_args "" +} + +# All done. +dg-finish diff --git a/libphobos/testsuite/libphobos.cycles/mod1.d b/libphobos/testsuite/libphobos.cycles/mod1.d new file mode 100644 index 0000000..22fd9ec --- /dev/null +++ b/libphobos/testsuite/libphobos.cycles/mod1.d @@ -0,0 +1,9 @@ +// { dg-additional-sources "mod2.d mod3.d" } +module mod1; +import mod2; + +shared int x; +shared static this() +{ + x = 1; +} diff --git a/libphobos/testsuite/libphobos.cycles/mod2.d b/libphobos/testsuite/libphobos.cycles/mod2.d new file mode 100644 index 0000000..66ba819 --- /dev/null +++ b/libphobos/testsuite/libphobos.cycles/mod2.d @@ -0,0 +1,9 @@ +// { dg-additional-sources "mod1.d mod3.d" } +module mod2; +import mod1; +import mod3; + +void main() +{ + // do nothing +} diff --git a/libphobos/testsuite/libphobos.cycles/mod3.d b/libphobos/testsuite/libphobos.cycles/mod3.d new file mode 100644 index 0000000..3eff4a9 --- /dev/null +++ b/libphobos/testsuite/libphobos.cycles/mod3.d @@ -0,0 +1,9 @@ +// { dg-additional-sources "mod1.d mod2.d" } +module mod3; +import mod2; + +shared int x; +shared static this() +{ + x = 3; +} diff --git a/libphobos/testsuite/libphobos.exceptions/chain.d b/libphobos/testsuite/libphobos.exceptions/chain.d new file mode 100644 index 0000000..462ba24 --- /dev/null +++ b/libphobos/testsuite/libphobos.exceptions/chain.d @@ -0,0 +1,79 @@ +// Author: Ali Çehreli +// See https://forum.dlang.org/post/o2n7f8$2p1t$1@digitalmars.com + +import core.stdc.stdio; + +class TestException : Exception +{ + this(string msg) + { + super(typeof(this).stringof~": "~msg); + } +} + +class TestError : Error +{ + this(string msg) + { + super(typeof(this).stringof~": "~msg); + } +} + +// Causes an exception chain where the node at index errorIndex is an +// Error (others are all Exceptions). +void causeExceptionChain(size_t chainLength, size_t errorIndex) +{ + void throws(size_t n) + { + scope (exit) + { + string msg = [ cast(char)('a'+n) ].idup; + if (n == errorIndex) + { + throw new TestError(msg); + } + else + { + throw new TestException(msg); + } + } + + if (n != 0) + { + // Redundant 'return' keyword due to + // https://issues.dlang.org/show_bug.cgi?id=16960 + return throws(n - 1); + } + } + + throws(chainLength - 1); +} + +void main() +{ + try + { + // -1 would mean "no Error in the chain". Change this to a + // number between 0 and 4 (inclusive) then you will realize + // that the Exception below will not be caught. + size_t errorIndex = 3; + causeExceptionChain(5, errorIndex); + } + catch (Error original) + { + printf("Caught\n"); + string prefix = ""; + for ({ size_t i; Throwable ex = original; } ex; ex = ex.next, ++i) + { + printf("%.*s%.*s\n", prefix.length, prefix.ptr, ex.msg.length, ex.msg.ptr); + prefix = prefix~" "; + } + printf("Bypassed chain was:\n"); + prefix = ""; + for ({ size_t i; Throwable ex = original.bypassedException; } ex; ex = ex.next, ++i) + { + printf("%.*s%.*s\n", prefix.length, prefix.ptr, ex.msg.length, ex.msg.ptr); + prefix = prefix~" "; + } + } +} diff --git a/libphobos/testsuite/libphobos.exceptions/exceptions.exp b/libphobos/testsuite/libphobos.exceptions/exceptions.exp new file mode 100644 index 0000000..d744b74 --- /dev/null +++ b/libphobos/testsuite/libphobos.exceptions/exceptions.exp @@ -0,0 +1,29 @@ +# Copyright (C) 2017-2018 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/>. + +load_lib libphobos-dg.exp + +# Initialize dg. +dg-init + +# Gather a list of all tests. +set tests [lsort [find $srcdir/$subdir *.d]] + +# Main loop. +dg-runtest $tests "" $DEFAULT_DFLAGS + +# All done. +dg-finish diff --git a/libphobos/testsuite/libphobos.exceptions/invalid_memory_operation.d b/libphobos/testsuite/libphobos.exceptions/invalid_memory_operation.d new file mode 100644 index 0000000..79660e9 --- /dev/null +++ b/libphobos/testsuite/libphobos.exceptions/invalid_memory_operation.d @@ -0,0 +1,14 @@ +// { dg-shouldfail "Invalid memory operation" } +// { dg-output "core.exception.InvalidMemoryOperationError@.*: Invalid memory operation" } +struct S +{ + ~this() + { + new int; + } +} + +void main() +{ + new S; +} diff --git a/libphobos/testsuite/libphobos.exceptions/line_trace.d b/libphobos/testsuite/libphobos.exceptions/line_trace.d new file mode 100644 index 0000000..7b75d3a --- /dev/null +++ b/libphobos/testsuite/libphobos.exceptions/line_trace.d @@ -0,0 +1,19 @@ +// { dg-output "object.Exception@.*: exception" } +void main() +{ + try + { + f1(); + } + catch (Exception e) + { + import core.stdc.stdio; + auto str = e.toString(); + printf("%.*s\n", str.length, str.ptr); + } +} + +void f1() +{ + throw new Exception("exception"); +} diff --git a/libphobos/testsuite/libphobos.exceptions/static_dtor.d b/libphobos/testsuite/libphobos.exceptions/static_dtor.d new file mode 100644 index 0000000..37a49b4 --- /dev/null +++ b/libphobos/testsuite/libphobos.exceptions/static_dtor.d @@ -0,0 +1,16 @@ +// { dg-shouldfail "static_dtor_exception" } +// { dg-output "object.Exception@.*: static_dtor_exception" } +// https://issues.dlang.org/show_bug.cgi?id=16594 +import core.stdc.stdio; + +shared static ~this() +{ + __gshared int count; + + if (count++) fprintf(stderr, "dtor_called_more_than_once"); + else throw new Exception("static_dtor_exception"); +} + +void main() +{ +} diff --git a/libphobos/testsuite/libphobos.exceptions/stderr_msg.d b/libphobos/testsuite/libphobos.exceptions/stderr_msg.d new file mode 100644 index 0000000..bd14cea --- /dev/null +++ b/libphobos/testsuite/libphobos.exceptions/stderr_msg.d @@ -0,0 +1,6 @@ +// { dg-shouldfail "stderr_msg msg" } +// { dg-output "object.Exception@.*: stderr_msg msg" } +void main() +{ + throw new Exception("stderr_msg msg"); +} diff --git a/libphobos/testsuite/libphobos.exceptions/unittest_assert.d b/libphobos/testsuite/libphobos.exceptions/unittest_assert.d new file mode 100644 index 0000000..bb4f2c2 --- /dev/null +++ b/libphobos/testsuite/libphobos.exceptions/unittest_assert.d @@ -0,0 +1,11 @@ +// { dg-options "-funittest" } +// { dg-shouldfail "unittest_assert msg" } +// { dg-output "core.exception.AssertError@.*: unittest_assert msg" } +unittest +{ + assert(0, "unittest_assert msg"); +} + +void main() +{ +} diff --git a/libphobos/testsuite/libphobos.exceptions/unknown_gc.d b/libphobos/testsuite/libphobos.exceptions/unknown_gc.d new file mode 100644 index 0000000..eb95aee --- /dev/null +++ b/libphobos/testsuite/libphobos.exceptions/unknown_gc.d @@ -0,0 +1,9 @@ +// { dg-require-effective-target shared } +// { dg-options "-shared-libphobos" } +// { dg-shouldfail "unknowngc" } +// { dg-output "No GC was initialized, please recheck the name of the selected GC \\('unknowngc'\\)." } +extern(C) __gshared string[] rt_options = [ "gcopt=gc:unknowngc" ]; + +void main() +{ +} diff --git a/libphobos/testsuite/libphobos.init_fini/init_fini.exp b/libphobos/testsuite/libphobos.init_fini/init_fini.exp new file mode 100644 index 0000000..d744b74 --- /dev/null +++ b/libphobos/testsuite/libphobos.init_fini/init_fini.exp @@ -0,0 +1,29 @@ +# Copyright (C) 2017-2018 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/>. + +load_lib libphobos-dg.exp + +# Initialize dg. +dg-init + +# Gather a list of all tests. +set tests [lsort [find $srcdir/$subdir *.d]] + +# Main loop. +dg-runtest $tests "" $DEFAULT_DFLAGS + +# All done. +dg-finish diff --git a/libphobos/testsuite/libphobos.init_fini/runtime_args.d b/libphobos/testsuite/libphobos.init_fini/runtime_args.d new file mode 100644 index 0000000..07ebae2 --- /dev/null +++ b/libphobos/testsuite/libphobos.init_fini/runtime_args.d @@ -0,0 +1,13 @@ +// Bugzilla 11149 - Runtime.args no longer available in static constructors +import core.runtime; + +shared static this() +{ + assert(Runtime.cArgs.argc > 0); + assert(Runtime.cArgs.argv !is null); + assert(Runtime.args.length > 0); +} + +void main() +{ +} diff --git a/libphobos/testsuite/libphobos.init_fini/thread_join.d b/libphobos/testsuite/libphobos.init_fini/thread_join.d new file mode 100644 index 0000000..a40cd5e --- /dev/null +++ b/libphobos/testsuite/libphobos.init_fini/thread_join.d @@ -0,0 +1,18 @@ +// Bugzilla 11309 - std.concurrency: OwnerTerminated message doesn't work +// We need to assure that the thread dtors of parent threads run before the thread dtors of the child threads. +import core.thread, core.sync.semaphore; +import core.stdc.stdio; + +__gshared Semaphore sem; + +static ~this() +{ + if (sem !is null) sem.notify(); +} + +void main() +{ + sem = new Semaphore; + auto thr = new Thread({assert(sem.wait(1.seconds));}); + thr.start(); +} diff --git a/libphobos/testsuite/libphobos.shared/finalize.d b/libphobos/testsuite/libphobos.shared/finalize.d new file mode 100644 index 0000000..f31b818 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/finalize.d @@ -0,0 +1,63 @@ +import core.runtime; +import core.stdc.stdio; +import core.stdc.string; +import core.thread; +import core.sys.posix.dlfcn; + +void runTest() +{ + Object obj; + obj = Object.factory("lib.MyFinalizer"); + assert(obj.toString() == "lib.MyFinalizer"); + obj = Object.factory("lib.MyFinalizerBig"); + assert(obj.toString() == "lib.MyFinalizerBig"); +} + +class NoFinalize +{ + size_t _finalizeCounter; + + ~this() + { + ++_finalizeCounter; + } +} + +class NoFinalizeBig : NoFinalize +{ + ubyte[4096] _big = void; +} + +extern (C) alias SetFinalizeCounter = void function(shared(size_t*)); + +void main(string[] args) +{ + auto name = args[0] ~ '\0'; + const pathlen = strrchr(name.ptr, '/') - name.ptr + 1; + name = name[0 .. pathlen] ~ "lib.so"; + + auto h = Runtime.loadLibrary(name); + assert(h !is null); + + auto nf1 = new NoFinalize; + auto nf2 = new NoFinalizeBig; + + shared size_t finalizeCounter; + auto setFinalizeCounter = cast(SetFinalizeCounter)dlsym(h, "setFinalizeCounter"); + setFinalizeCounter(&finalizeCounter); + + runTest(); + auto thr = new Thread(&runTest); + thr.start(); + thr.join(); + + auto r = Runtime.unloadLibrary(h); + if (!r) + assert(0); + if (finalizeCounter != 4) + assert(0); + if (nf1._finalizeCounter) + assert(0); + if (nf2._finalizeCounter) + assert(0); +} diff --git a/libphobos/testsuite/libphobos.shared/host.c b/libphobos/testsuite/libphobos.shared/host.c new file mode 100644 index 0000000..81e896a --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/host.c @@ -0,0 +1,60 @@ +#include <stdlib.h> +#include <string.h> +#include <dlfcn.h> +#include <assert.h> + +int main(int argc, char* argv[]) +{ +#if defined(__FreeBSD__) + // workaround for Bugzilla 14824 + void *druntime = dlopen(argv[1], RTLD_LAZY); // load druntime + assert(druntime); +#endif + + const size_t pathlen = strrchr(argv[0], '/') - argv[0] + 1; + char *name = malloc(pathlen + sizeof("plugin1.so")); + memcpy(name, argv[0], pathlen); + memcpy(name+pathlen, "plugin1.so", sizeof("plugin1.so")); + + void* plugin1 = dlopen(name, RTLD_LAZY); + name[pathlen + sizeof("plugin1.so") - 5] = '2'; + void* plugin2 = dlopen(name, RTLD_LAZY); + + int (*plugin1_init)() = dlsym(plugin1, "plugin_init"); + int (*plugin1_term)() = dlsym(plugin1, "plugin_term"); + int (*runTests1)() = dlsym(plugin1, "runTests"); + int (*plugin2_init)() = dlsym(plugin2, "plugin_init"); + int (*plugin2_term)() = dlsym(plugin2, "plugin_term"); + int (*runTests2)() = dlsym(plugin2, "runTests"); + assert(plugin1_init()); + assert(runTests1()); + assert(plugin2_init()); + assert(runTests2()); + + assert(plugin1_term()); + assert(dlclose(plugin1) == 0); + assert(runTests2()); + + name[pathlen + sizeof("plugin1.so") - 5] = '1'; + plugin1 = dlopen(name, RTLD_LAZY); + plugin1_init = dlsym(plugin1, "plugin_init"); + plugin1_term = dlsym(plugin1, "plugin_term"); + runTests1 = dlsym(plugin1, "runTests"); + assert(plugin1_init()); + assert(runTests1()); + assert(runTests2()); + + assert(plugin2_term()); + assert(dlclose(plugin2) == 0); + assert(runTests1()); + + assert(plugin1_term()); + assert(dlclose(plugin1) == 0); + + free(name); + +#if defined(__FreeBSD__) + dlclose(druntime); +#endif + return EXIT_SUCCESS; +} diff --git a/libphobos/testsuite/libphobos.shared/lib.d b/libphobos/testsuite/libphobos.shared/lib.d new file mode 100644 index 0000000..0e4eb44 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/lib.d @@ -0,0 +1,133 @@ +module lib; + +// test EH +void throwException() +{ + throw new Exception(null); +} + +Exception collectException(void delegate() dg) +{ + try + dg(); + catch (Exception e) + return e; + return null; +} + +// test GC +__gshared Object root; +void alloc() { root = new Object(); } +void access() { assert(root.toString() !is null); } // vtbl call will fail if finalized +void free() { root = null; } + +Object tls_root; +void tls_alloc() { tls_root = new Object(); } +void tls_access() { assert(tls_root.toString() !is null); } // vtbl call will fail if finalized +void tls_free() { tls_root = null; } + +void stack(alias func)() +{ + // allocate some extra stack space to not keep references to GC memory on the scanned stack + ubyte[1024] buf = void; + func(); +} + +void testGC() +{ + import core.memory; + + stack!alloc(); + stack!tls_alloc(); + stack!access(); + stack!tls_access(); + GC.collect(); + stack!tls_access(); + stack!access(); + stack!tls_free(); + stack!free(); +} + +// test Init +import core.atomic : atomicOp; +shared uint shared_static_ctor, shared_static_dtor, static_ctor, static_dtor; +shared static this() { if (atomicOp!"+="(shared_static_ctor, 1) != 1) assert(0); } +shared static ~this() { if (atomicOp!"+="(shared_static_dtor, 1) != 1) assert(0); } +static this() { atomicOp!"+="(static_ctor, 1); } +static ~this() { atomicOp!"+="(static_dtor, 1); } + +extern(C) int runTests() +{ + try + runTestsImpl(); + catch (Throwable) + return 0; + return 1; +} + +void runTestsImpl() +{ + import core.thread; + + bool passed; + try + throwException(); + catch (Exception e) + passed = true; + assert(passed); + assert(collectException({throwException();}) !is null); + + testGC(); + + assert(shared_static_ctor == 1); + assert(static_ctor == 1); + static void run() + { + assert(static_ctor == 2); + assert(shared_static_ctor == 1); + testGC(); + } + auto thr = new Thread(&run); + thr.start(); + thr.join(); + assert(static_dtor == 1); + + passed = false; + foreach (m; ModuleInfo) + if (m.name == "lib") passed = true; + assert(passed); +} + +// Provide a way to initialize D from C programs that are D agnostic. +import core.runtime : rt_init, rt_term; + +extern(C) int lib_init() +{ + return rt_init(); +} + +extern(C) int lib_term() +{ + return rt_term(); +} + +shared size_t* _finalizeCounter; + +class MyFinalizer +{ + ~this() + { + import core.atomic; + atomicOp!"+="(*_finalizeCounter, 1); + } +} + +class MyFinalizerBig : MyFinalizer +{ + ubyte[4096] _big = void; +} + +extern(C) void setFinalizeCounter(shared(size_t)* p) +{ + _finalizeCounter = p; +} diff --git a/libphobos/testsuite/libphobos.shared/lib_13414.d b/libphobos/testsuite/libphobos.shared/lib_13414.d new file mode 100644 index 0000000..2859438 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/lib_13414.d @@ -0,0 +1,4 @@ +shared void function() sharedStaticDtorHook; +shared void function() staticDtorHook; +shared static ~this() { sharedStaticDtorHook(); } +static ~this() { staticDtorHook(); } diff --git a/libphobos/testsuite/libphobos.shared/liblinkdep.d b/libphobos/testsuite/libphobos.shared/liblinkdep.d new file mode 100644 index 0000000..c2d2cc6 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/liblinkdep.d @@ -0,0 +1,6 @@ +import lib; + +extern(C) int runDepTests() +{ + return runTests(); +} diff --git a/libphobos/testsuite/libphobos.shared/libloaddep.d b/libphobos/testsuite/libphobos.shared/libloaddep.d new file mode 100644 index 0000000..93a2dab --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/libloaddep.d @@ -0,0 +1,13 @@ +import core.runtime, core.sys.posix.dlfcn; + +extern(C) alias RunTests = int function(); + +extern(C) int runDepTests(const char* name) +{ + auto h = rt_loadLibrary(name); + if (h is null) return false; + auto runTests = cast(RunTests).dlsym(h, "runTests"); + assert(runTests !is null); + if (!runTests()) return false; + return rt_unloadLibrary(h); +} diff --git a/libphobos/testsuite/libphobos.shared/link.d b/libphobos/testsuite/libphobos.shared/link.d new file mode 100644 index 0000000..433da66 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/link.d @@ -0,0 +1,64 @@ +import lib; + +void testEH() +{ + bool passed; + try + lib.throwException(); + catch (Exception e) + passed = true; + assert(passed); passed = false; + + assert(lib.collectException({throw new Exception(null);}) !is null); + assert(lib.collectException({lib.throwException();}) !is null); +} + +void testGC() +{ + import core.memory; + lib.alloc(); + lib.tls_alloc(); + lib.access(); + lib.tls_access(); + GC.collect(); + lib.tls_access(); + lib.access(); + lib.tls_free(); + lib.free(); +} + +import core.atomic : atomicOp; +shared static this() { assert(lib.shared_static_ctor == 1); } +shared static ~this() { assert(lib.shared_static_dtor == 0); } +shared uint static_ctor, static_dtor; +static this() { assert(lib.static_ctor == atomicOp!"+="(static_ctor, 1)); } +static ~this() { assert(lib.static_dtor + 1 == atomicOp!"+="(static_dtor, 1)); } + +void testInit() +{ + import core.thread; + + assert(lib.static_ctor == 1); + assert(lib.static_dtor == 0); + static void foo() + { + assert(lib.shared_static_ctor == 1); + assert(lib.shared_static_dtor == 0); + assert(lib.static_ctor == 2); + assert(lib.static_dtor == 0); + } + auto thr = new Thread(&foo); + thr.start(); + assert(thr.join() is null); + assert(lib.shared_static_ctor == 1); + assert(lib.shared_static_dtor == 0); + assert(lib.static_ctor == 2); + assert(lib.static_dtor == 1); +} + +void main() +{ + testEH(); + testGC(); + testInit(); +} diff --git a/libphobos/testsuite/libphobos.shared/linkD.c b/libphobos/testsuite/libphobos.shared/linkD.c new file mode 100644 index 0000000..657c9e8 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/linkD.c @@ -0,0 +1,14 @@ +#include <stdlib.h> +#include <assert.h> + +extern int runTests(void); +extern int lib_init(void); +extern int lib_term(void); + +int main(int argc, char* argv[]) +{ + if (!lib_init()) return EXIT_SUCCESS; + const int res = runTests() ? EXIT_SUCCESS : EXIT_FAILURE; + if (!lib_term()) return EXIT_FAILURE; + return res; +} diff --git a/libphobos/testsuite/libphobos.shared/linkDR.c b/libphobos/testsuite/libphobos.shared/linkDR.c new file mode 100644 index 0000000..924709c --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/linkDR.c @@ -0,0 +1,28 @@ +#include <stdlib.h> +#include <string.h> +#include <dlfcn.h> +#include <assert.h> + +extern void* rt_loadLibrary(const char*); +extern int rt_unloadLibrary(void*); +extern int rt_init(void); +extern int rt_term(void); + +int main(int argc, char* argv[]) +{ + if (!rt_init()) return EXIT_FAILURE; + const size_t pathlen = strrchr(argv[0], '/') - argv[0] + 1; + char *name = malloc(pathlen + sizeof("lib.so")); + memcpy(name, argv[0], pathlen); + memcpy(name+pathlen, "lib.so", sizeof("lib.so")); + + void *dlib = rt_loadLibrary(name); + free(name); + assert(dlib); + + int (*runTests)(void) = dlsym(dlib, "runTests"); + assert(runTests()); + assert(rt_unloadLibrary(dlib)); + if (!rt_term()) return EXIT_FAILURE; + return EXIT_SUCCESS; +} diff --git a/libphobos/testsuite/libphobos.shared/link_linkdep.d b/libphobos/testsuite/libphobos.shared/link_linkdep.d new file mode 100644 index 0000000..ca72e7e --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/link_linkdep.d @@ -0,0 +1,6 @@ +import liblinkdep; + +void main() +{ + runDepTests(); +} diff --git a/libphobos/testsuite/libphobos.shared/link_loaddep.d b/libphobos/testsuite/libphobos.shared/link_loaddep.d new file mode 100644 index 0000000..8e0c58e --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/link_loaddep.d @@ -0,0 +1,7 @@ +import libloaddep; + +void main(string[] args) +{ + auto libname = args[0][0..$-"link_loaddep".length] ~ "lib.so\0"; + runDepTests(libname.ptr); +} diff --git a/libphobos/testsuite/libphobos.shared/link_mod_collision.d b/libphobos/testsuite/libphobos.shared/link_mod_collision.d new file mode 100644 index 0000000..9c3d1c7 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/link_mod_collision.d @@ -0,0 +1,5 @@ +module lib; // module collides with lib.so + +void main() +{ +} diff --git a/libphobos/testsuite/libphobos.shared/load.d b/libphobos/testsuite/libphobos.shared/load.d new file mode 100644 index 0000000..8c13f51 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/load.d @@ -0,0 +1,147 @@ +import core.runtime; +import core.stdc.stdio; +import core.stdc.string; +import core.thread; + +version (linux) import core.sys.linux.dlfcn; +else version (FreeBSD) import core.sys.freebsd.dlfcn; +else version (NetBSD) import core.sys.netbsd.dlfcn; +else static assert(0, "unimplemented"); + +void loadSym(T)(void* handle, ref T val, const char* mangle) +{ + val = cast(T).dlsym(handle, mangle); +} + +void* openLib(string s) +{ + auto h = Runtime.loadLibrary(s); + assert(h !is null); + + loadSym(h, libThrowException, "_D3lib14throwExceptionFZv"); + loadSym(h, libCollectException, "_D3lib16collectExceptionFDFZvZC9Exception"); + + loadSym(h, libAlloc, "_D3lib5allocFZv"); + loadSym(h, libTlsAlloc, "_D3lib9tls_allocFZv"); + loadSym(h, libAccess, "_D3lib6accessFZv"); + loadSym(h, libTlsAccess, "_D3lib10tls_accessFZv"); + loadSym(h, libFree, "_D3lib4freeFZv"); + loadSym(h, libTlsFree, "_D3lib8tls_freeFZv"); + + loadSym(h, libSharedStaticCtor, "_D3lib18shared_static_ctorOk"); + loadSym(h, libSharedStaticDtor, "_D3lib18shared_static_dtorOk"); + loadSym(h, libStaticCtor, "_D3lib11static_ctorOk"); + loadSym(h, libStaticDtor, "_D3lib11static_dtorOk"); + + return h; +} + +void closeLib(void* h) +{ + Runtime.unloadLibrary(h); +} + +__gshared +{ + void function() libThrowException; + Exception function(void delegate()) libCollectException; + + void function() libAlloc; + void function() libTlsAlloc; + void function() libAccess; + void function() libTlsAccess; + void function() libFree; + void function() libTlsFree; + + shared uint* libSharedStaticCtor; + shared uint* libSharedStaticDtor; + shared uint* libStaticCtor; + shared uint* libStaticDtor; +} + +void testEH() +{ + bool passed; + try + libThrowException(); + catch (Exception e) + passed = true; + assert(passed); passed = false; + + assert(libCollectException({throw new Exception(null);}) !is null); + assert(libCollectException({libThrowException();}) !is null); +} + +void testGC() +{ + import core.memory; + libAlloc(); + libTlsAlloc(); + libAccess(); + libTlsAccess(); + GC.collect(); + libTlsAccess(); + libAccess(); + libTlsFree(); + libFree(); +} + +void testInit() +{ + + assert(*libStaticCtor == 1); + assert(*libStaticDtor == 0); + static void run() + { + assert(*libSharedStaticCtor == 1); + assert(*libSharedStaticDtor == 0); + assert(*libStaticCtor == 2); + assert(*libStaticDtor == 0); + } + auto thr = new Thread(&run); + thr.start(); + thr.join(); + assert(*libSharedStaticCtor == 1); + assert(*libSharedStaticDtor == 0); + assert(*libStaticCtor == 2); + assert(*libStaticDtor == 1); +} + +const(ModuleInfo)* findModuleInfo(string name) +{ + foreach (m; ModuleInfo) + if (m.name == name) return m; + return null; +} + +void runTests(string libName) +{ + assert(findModuleInfo("lib") is null); + auto handle = openLib(libName); + assert(findModuleInfo("lib") !is null); + + testEH(); + testGC(); + testInit(); + + closeLib(handle); + assert(findModuleInfo("lib") is null); +} + +void main(string[] args) +{ + auto name = args[0] ~ '\0'; + const pathlen = strrchr(name.ptr, '/') - name.ptr + 1; + name = name[0 .. pathlen] ~ "lib.so"; + + runTests(name); + + // lib is no longer resident + name ~= '\0'; + assert(.dlopen(name.ptr, RTLD_LAZY | RTLD_NOLOAD) is null); + name = name[0 .. $-1]; + + auto thr = new Thread({runTests(name);}); + thr.start(); + thr.join(); +} diff --git a/libphobos/testsuite/libphobos.shared/loadDR.c b/libphobos/testsuite/libphobos.shared/loadDR.c new file mode 100644 index 0000000..08508cbc --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/loadDR.c @@ -0,0 +1,39 @@ +#include <stdlib.h> +#include <string.h> +#include <dlfcn.h> +#include <assert.h> + +int main(int argc, char* argv[]) +{ + if (argc != 2) + return EXIT_FAILURE; + void *h = dlopen(argv[1], RTLD_LAZY); // load druntime + assert(h != NULL); + + int (*rt_init)(void) = dlsym(h, "rt_init"); + int (*rt_term)(void) = dlsym(h, "rt_term"); + void* (*rt_loadLibrary)(const char*) = dlsym(h, "rt_loadLibrary"); + int (*rt_unloadLibrary)(void*) = dlsym(h, "rt_unloadLibrary"); + + int res = EXIT_FAILURE; + if (!rt_init()) goto Lexit; + + const size_t pathlen = strrchr(argv[0], '/') - argv[0] + 1; + char *name = malloc(pathlen + sizeof("lib.so")); + memcpy(name, argv[0], pathlen); + memcpy(name+pathlen, "lib.so", sizeof("lib.so")); + + void *dlib = rt_loadLibrary(name); + free(name); + assert(dlib); + + int (*runTests)(void) = dlsym(dlib, "runTests"); + assert(runTests()); + assert(rt_unloadLibrary(dlib)); + + if (rt_term()) res = EXIT_SUCCESS; + +Lexit: + assert(dlclose(h) == 0); + return res; +} diff --git a/libphobos/testsuite/libphobos.shared/load_13414.d b/libphobos/testsuite/libphobos.shared/load_13414.d new file mode 100644 index 0000000..f7cbf45 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/load_13414.d @@ -0,0 +1,30 @@ +import core.runtime; +import core.atomic; +import core.stdc.string; +import core.sys.posix.dlfcn; + +shared uint tlsDtor, dtor; +void staticDtorHook() { atomicOp!"+="(tlsDtor, 1); } +void sharedStaticDtorHook() { atomicOp!"+="(dtor, 1); } + +void runTest(string name) +{ + auto h = Runtime.loadLibrary(name); + assert(h !is null); + + *cast(void function()*).dlsym(h, "_D9lib_1341414staticDtorHookOPFZv") = &staticDtorHook; + *cast(void function()*).dlsym(h, "_D9lib_1341420sharedStaticDtorHookOPFZv") = &sharedStaticDtorHook; + + Runtime.unloadLibrary(h); + assert(tlsDtor == 1); + assert(dtor == 1); +} + +void main(string[] args) +{ + auto name = args[0] ~ '\0'; + const pathlen = strrchr(name.ptr, '/') - name.ptr + 1; + name = name[0 .. pathlen] ~ "lib_13414.so"; + + runTest(name); +} diff --git a/libphobos/testsuite/libphobos.shared/load_linkdep.d b/libphobos/testsuite/libphobos.shared/load_linkdep.d new file mode 100644 index 0000000..5f5dcf2 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/load_linkdep.d @@ -0,0 +1,18 @@ +import core.runtime; +import core.stdc.string; +import core.sys.posix.dlfcn; + +extern(C) alias RunDepTests = int function(); + +void main(string[] args) +{ + auto name = args[0] ~ '\0'; + const pathlen = strrchr(name.ptr, '/') - name.ptr + 1; + name = name[0 .. pathlen] ~ "liblinkdep.so"; + + auto h = Runtime.loadLibrary(name); + assert(h); + auto runDepTests = cast(RunDepTests)dlsym(h, "runDepTests"); + assert(runDepTests()); + assert(Runtime.unloadLibrary(h)); +} diff --git a/libphobos/testsuite/libphobos.shared/load_loaddep.d b/libphobos/testsuite/libphobos.shared/load_loaddep.d new file mode 100644 index 0000000..c189683e --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/load_loaddep.d @@ -0,0 +1,17 @@ +import core.runtime; +import core.stdc.string; +import core.sys.posix.dlfcn; + +extern(C) alias RunDepTests = int function(const char*); + +void main(string[] args) +{ + auto name = args[0] ~ '\0'; + const pathlen = strrchr(name.ptr, '/') - name.ptr + 1; + auto root = name[0 .. pathlen]; + auto libloaddep = root ~ "libloaddep.so"; + auto h = Runtime.loadLibrary(libloaddep); + auto runDepTests = cast(RunDepTests)dlsym(h, "runDepTests"); + assert(runDepTests((root ~ "lib.so\0").ptr)); + assert(Runtime.unloadLibrary(h)); +} diff --git a/libphobos/testsuite/libphobos.shared/load_mod_collision.d b/libphobos/testsuite/libphobos.shared/load_mod_collision.d new file mode 100644 index 0000000..64243d4 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/load_mod_collision.d @@ -0,0 +1,14 @@ +module lib; // module collides with lib.so + +import core.runtime; +import core.stdc.stdio; +import core.stdc.string; +import core.sys.posix.dlfcn; + +void main(string[] args) +{ + auto name = args[0] ~ '\0'; + const pathlen = strrchr(name.ptr, '/') - name.ptr + 1; + name = name[0 .. pathlen] ~ "lib.so"; + auto lib = Runtime.loadLibrary(name); +} diff --git a/libphobos/testsuite/libphobos.shared/plugin.d b/libphobos/testsuite/libphobos.shared/plugin.d new file mode 100644 index 0000000..74d6601 --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/plugin.d @@ -0,0 +1,73 @@ +import core.thread, core.memory, core.atomic; + +// test init +shared uint gctor, gdtor, tctor, tdtor; +shared static this() { if (atomicOp!"+="(gctor, 1) != 1) assert(0); } +shared static ~this() { if (atomicOp!"+="(gdtor, 1) != 1) assert(0); } +static this() { atomicOp!"+="(tctor, 1); } +static ~this() { atomicOp!"+="(tdtor, 1); } + +// test GC +__gshared Object root; +void alloc() { root = new Object(); } +void access() { assert(root.toString() !is null); } // vtbl call will fail if finalized +void free() { root = null; } + +Object tls_root; +void tls_alloc() { tls_root = new Object(); } +void tls_access() { assert(tls_root.toString() !is null); } // vtbl call will fail if finalized +void tls_free() { tls_root = null; } + +void stack(alias func)() +{ + // allocate some extra stack space to not keep references to GC memory on the scanned stack + ubyte[1024] buf = void; + func(); +} + +void testGC() +{ + import core.memory; + + stack!alloc(); + stack!tls_alloc(); + stack!access(); + stack!tls_access(); + GC.collect(); + stack!tls_access(); + stack!access(); + stack!tls_free(); + stack!free(); +} + +extern(C) int runTests() +{ + try + { + assert(atomicLoad!(MemoryOrder.acq)(gctor) == 1); + assert(atomicLoad!(MemoryOrder.acq)(gdtor) == 0); + assert(atomicLoad!(MemoryOrder.acq)(tctor) >= 1); + assert(atomicLoad!(MemoryOrder.acq)(tdtor) >= 0); + // test some runtime functionality + testGC(); + new Thread(&testGC).start.join; + } + catch (Throwable) + { + return false; + } + return true; +} + +// Provide a way to initialize D from C programs that are D agnostic. +import core.runtime : rt_init, rt_term; + +extern(C) int plugin_init() +{ + return rt_init(); +} + +extern(C) int plugin_term() +{ + return rt_term(); +} diff --git a/libphobos/testsuite/libphobos.shared/shared.exp b/libphobos/testsuite/libphobos.shared/shared.exp new file mode 100644 index 0000000..5555b3b --- /dev/null +++ b/libphobos/testsuite/libphobos.shared/shared.exp @@ -0,0 +1,108 @@ +# Copyright (C) 2017-2018 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/>. + +load_lib libphobos-dg.exp + +# Immediately exit if target doesn't support shared. +if { ![is-effective-target shared] } { + return +} + +# If a testcase doesn't have special options, use these. +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS "-g" +} + +# +# Build all shared libraries, used as dependencies for other tests. +# + +proc shared_library { source destfile options } { + global DEFAULT_DFLAGS + global all_libraries + + # Compiling with -fno-gnu-unique as tests call dlopen/dlclose multiple times on the same library. + lappend options "additional_flags=$DEFAULT_DFLAGS -fno-gnu-unique -fpic -shared -shared-libphobos" + + set comp_output [libphobos_target_compile "$source" "$destfile" "executable" $options] + if ![ string match "" $comp_output ] { + fail "libphobos.shared/[file tail $source]" + verbose -log $comp_output + return 1 + } + + lappend all_libraries $destfile +} + +# lib.so +shared_library "$srcdir/$subdir/lib.d" "lib.so" "" + +# liblinkdep.so +shared_library "$srcdir/$subdir/liblinkdep.d" "liblinkdep.so" \ + [list "additional_flags=-I$srcdir/$subdir lib.so"] + +# libloaddep.so +shared_library "$srcdir/$subdir/libloaddep.d" "libloaddep.so" "" + +# lib_13414.so +shared_library "$srcdir/$subdir/lib_13414.d" "lib_13414.so" "" + +# plugin.so +shared_library "$srcdir/$subdir/plugin.d" "plugin1.so" "" +shared_library "$srcdir/$subdir/plugin.d" "plugin2.so" "" + +# Initialize dg. +dg-init + +# Main loop. +dg-test "$srcdir/$subdir/link.d" "-I$srcdir/$subdir lib.so -shared-libphobos" \ + "$DEFAULT_DFLAGS" + +dg-test "$srcdir/$subdir/link_linkdep.d" \ + "-I$srcdir/$subdir liblinkdep.so lib.so -shared-libphobos" \ + "$DEFAULT_DFLAGS" + +dg-test "$srcdir/$subdir/link_loaddep.d" \ + "-I$srcdir/$subdir libloaddep.so -shared-libphobos" "$DEFAULT_DFLAGS" + +# dlopen() tests. +if [is-effective-target dlopen] { + dg-test "$srcdir/$subdir/load.d" "-shared-libphobos -ldl" "$DEFAULT_DFLAGS" + dg-test "$srcdir/$subdir/load_linkdep.d" "-shared-libphobos -ldl" "$DEFAULT_DFLAGS" + dg-test "$srcdir/$subdir/load_loaddep.d" "-shared-libphobos -ldl" "$DEFAULT_DFLAGS" + dg-test "$srcdir/$subdir/load_13414.d" "-shared-libphobos -ldl" "$DEFAULT_DFLAGS" + dg-test "$srcdir/$subdir/finalize.d" "-shared-libphobos -ldl" "$DEFAULT_DFLAGS" +} + +# C program link tests. +if { [is-effective-target dlopen] && [is-effective-target pthread] } { + dg-test "$srcdir/$subdir/linkD.c" "lib.so -ldl -pthread" "$DEFAULT_CFLAGS" + dg-test "$srcdir/$subdir/linkDR.c" "-shared-libphobos -ldl -pthread" "$DEFAULT_CFLAGS" + dg-test "$srcdir/$subdir/host.c" "-ldl -pthread" "$DEFAULT_CFLAGS" + + # Test requires a command line argument to be passed to the program. + set libphobos_run_args "$objdir/../src/.libs/libgphobos.so" + dg-test "$srcdir/$subdir/loadDR.c" "-ldl -pthread -g" "$DEFAULT_CFLAGS" + set libphobos_run_args "" +} + +# All done. +dg-finish + +# Remove all libraries built before running tests. +foreach lib $all_libraries { + catch "file delete -force -- $lib" +} diff --git a/libphobos/testsuite/libphobos.thread/fiber_guard_page.d b/libphobos/testsuite/libphobos.thread/fiber_guard_page.d new file mode 100644 index 0000000..33a7459 --- /dev/null +++ b/libphobos/testsuite/libphobos.thread/fiber_guard_page.d @@ -0,0 +1,47 @@ +// { dg-shouldfail "segv or bus error" } +import core.thread; +import core.sys.posix.sys.mman; + +// this should be true for most architectures +// (taken from core.thread) +version = StackGrowsDown; + +enum stackSize = 4096; + +// Simple method that causes a stack overflow +void stackMethod() +{ + // Over the stack size, so it overflows the stack + int[stackSize/int.sizeof+100] x; +} + +void main() +{ + auto test_fiber = new Fiber(&stackMethod, stackSize); + + // allocate a page below (above) the fiber's stack to make stack overflows possible (w/o segfaulting) + version (StackGrowsDown) + { + static assert(__traits(identifier, test_fiber.tupleof[8]) == "m_pmem"); + auto stackBottom = test_fiber.tupleof[8]; + auto p = mmap(stackBottom - 8 * stackSize, 8 * stackSize, + PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); + assert(p !is null, "failed to allocate page"); + } + else + { + auto m_sz = test_fiber.tupleof[7]; + auto m_pmem = test_fiber.tupleof[8]; + static assert(__traits(identifier, test_fiber.tupleof[7]) == "m_size"); + static assert(__traits(identifier, test_fiber.tupleof[8]) == "m_pmem"); + + auto stackTop = m_pmem + m_sz; + auto p = mmap(stackTop, 8 * stackSize, + PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); + assert(p !is null, "failed to allocate page"); + } + + // the guard page should prevent a mem corruption by stack + // overflow and cause a segfault instead (or generate SIGBUS on *BSD flavors) + test_fiber.call(); +} diff --git a/libphobos/testsuite/libphobos.thread/thread.exp b/libphobos/testsuite/libphobos.thread/thread.exp new file mode 100644 index 0000000..d744b74 --- /dev/null +++ b/libphobos/testsuite/libphobos.thread/thread.exp @@ -0,0 +1,29 @@ +# Copyright (C) 2017-2018 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/>. + +load_lib libphobos-dg.exp + +# Initialize dg. +dg-init + +# Gather a list of all tests. +set tests [lsort [find $srcdir/$subdir *.d]] + +# Main loop. +dg-runtest $tests "" $DEFAULT_DFLAGS + +# All done. +dg-finish diff --git a/libphobos/testsuite/libphobos.typeinfo/comparison.d b/libphobos/testsuite/libphobos.typeinfo/comparison.d new file mode 100644 index 0000000..a6719ba --- /dev/null +++ b/libphobos/testsuite/libphobos.typeinfo/comparison.d @@ -0,0 +1,78 @@ +// https://github.com/dlang/druntime/pull/1781 + +struct S +{ + int i; + static int comparisons; + int opCmp(const S s) const { comparisons++; return i - s.i; } +} + +void testStructs() +{ + auto s1 = S(1); + auto s2 = S(2); + auto s3 = S(3); + auto s4 = S(4); + + // Test lexicographical order + + assert(s1 < s2 && s2 < s3); + assert([s1, s2, s3] < [s1, s3]); + assert([s1, s2] < [s1, s2, s3]); + + // Test number of comparisons for nested types + + S.comparisons = 0; + assert(s1 < s2); + assert(S.comparisons == 1); + + S.comparisons = 0; + assert([s1, s2] < [s3, s4]); + assert(S.comparisons == 1); + + S.comparisons = 0; + assert([[s1, s2]] < [[s3, s4]]); + assert(S.comparisons == 1); +} + +class C +{ + this(int i) { this.i = i; } + int i; + static int comparisons; + override int opCmp(Object c) const { comparisons++; return i - (cast(C)c).i; } +} + +void testClasses() +{ + auto c1 = new C(1); + auto c2 = new C(2); + auto c3 = new C(3); + auto c4 = new C(4); + + // Test lexicographical order + + assert(c1 < c2 && c2 < c3); + assert([c1, c2, c3] < [c1, c3]); + assert([c1, c2] < [c1, c2, c3]); + + // Test number of comparisons for nested types + + C.comparisons = 0; + assert(c1 < c2); + assert(C.comparisons == 1); + + C.comparisons = 0; + assert([c1, c2] < [c3, c4]); + assert(C.comparisons == 1); + + C.comparisons = 0; + assert([[c1, c2]] < [[c3, c4]]); + assert(C.comparisons == 1); +} + +void main() +{ + testStructs(); + testClasses(); +} diff --git a/libphobos/testsuite/libphobos.typeinfo/typeinfo.exp b/libphobos/testsuite/libphobos.typeinfo/typeinfo.exp new file mode 100644 index 0000000..d744b74 --- /dev/null +++ b/libphobos/testsuite/libphobos.typeinfo/typeinfo.exp @@ -0,0 +1,29 @@ +# Copyright (C) 2017-2018 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/>. + +load_lib libphobos-dg.exp + +# Initialize dg. +dg-init + +# Gather a list of all tests. +set tests [lsort [find $srcdir/$subdir *.d]] + +# Main loop. +dg-runtest $tests "" $DEFAULT_DFLAGS + +# All done. +dg-finish diff --git a/libphobos/testsuite/libphobos.unittests/unittests.exp b/libphobos/testsuite/libphobos.unittests/unittests.exp new file mode 100644 index 0000000..e68e630 --- /dev/null +++ b/libphobos/testsuite/libphobos.unittests/unittests.exp @@ -0,0 +1,53 @@ +# Copyright (C) 2017-2018 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/>. + +# Immediately exit if we can't run target executables. +if { ![isnative] } { + return +} + +proc unittest_list_modules { prog } { + # Running the test runner without arguments prints a list of all + # modules that have unittests compiled in. + set result [libphobos_load "$prog" "" ""] + return [lindex $result 1] +} + +# Runs all unittests for each module compiled into the test program. +proc unittest_run_tests { name prog } { + foreach module [unittest_list_modules $prog] { + set result [libphobos_load "$prog" "$module" ""] + set status [lindex $result 0] + $status "libphobos.unittests/$name/$module" + } +} + +proc unittester { name prog } { + if [file exists $prog] { + unittest_run_tests $name $prog + } +} + +# List of test runners. +if [is-effective-target static] { + unittester "druntime/static" "$objdir/../libdruntime/unittest_static$exeext" + unittester "phobos/static" "$objdir/../src/unittest_static$exeext" +} + +if [is-effective-target shared] { + unittester "druntime/shared" "$objdir/../libdruntime/unittest$exeext" + unittester "phobos/shared" "$objdir/../src/unittest$exeext" +} diff --git a/libphobos/testsuite/test_runner.d b/libphobos/testsuite/test_runner.d new file mode 100644 index 0000000..c9a908a --- /dev/null +++ b/libphobos/testsuite/test_runner.d @@ -0,0 +1,95 @@ +import core.runtime, core.time : MonoTime; +import core.stdc.stdio; + +ModuleInfo* getModuleInfo(string name) +{ + foreach (m; ModuleInfo) + if (m.name == name) return m; + assert(0, "module '"~name~"' not found"); +} + +bool tester() +{ + return Runtime.args.length > 1 ? testModules() : printAll(); +} + +string mode; + + +bool testModules() +{ + bool ret = true; + foreach(name; Runtime.args[1..$]) + { + immutable pkg = ".package"; + immutable pkgLen = pkg.length; + + if (name.length > pkgLen && name[$ - pkgLen .. $] == pkg) + name = name[0 .. $ - pkgLen]; + + doTest(getModuleInfo(name), ret); + } + + return ret; +} + +bool printAll() +{ + foreach (m; ModuleInfo) + { + if (m.unitTest) + { + string name = m.name; + printf("%.*s\n", cast(int)name.length, name.ptr); + } + } + return true; +} + + +void doTest(ModuleInfo* moduleInfo, ref bool ret) +{ + if (auto fp = moduleInfo.unitTest) + { + auto name = moduleInfo.name; + try + { + immutable t0 = MonoTime.currTime; + fp(); + printf("%.3fs PASS %.*s %.*s\n", + (MonoTime.currTime - t0).total!"msecs" / 1000.0, + cast(uint)mode.length, mode.ptr, + cast(uint)name.length, name.ptr); + } + catch (Throwable e) + { + auto msg = e.toString(); + printf("****** FAIL %.*s %.*s\n%.*s\n", + cast(uint)mode.length, mode.ptr, + cast(uint)name.length, name.ptr, + cast(uint)msg.length, msg.ptr); + ret = false; + } + } +} + + +shared static this() +{ + version(D_Coverage) + { + import core.runtime : dmd_coverSetMerge; + dmd_coverSetMerge(true); + } + Runtime.moduleUnitTester = &tester; + + debug mode = "debug"; + else mode = "release"; + static if ((void*).sizeof == 4) mode ~= "32"; + else static if ((void*).sizeof == 8) mode ~= "64"; + else static assert(0, "You must be from the future!"); +} + +void main() +{ +} diff --git a/libphobos/testsuite/testsuite_flags.in b/libphobos/testsuite/testsuite_flags.in new file mode 100755 index 0000000..92cc436 --- /dev/null +++ b/libphobos/testsuite/testsuite_flags.in @@ -0,0 +1,52 @@ +#!/bin/sh + +# +# This script computes the various flags needed to run D Phobos unittests. +# + +# Print a message saying how this script is intended to be invoked +print_usage() { + cat <<EOF +Usage: + testsuite_flags --gdc + --gdcflags + --gdcpaths + --gdcldflags + +EOF +} + +# Establish configure-generated directory structure. +BUILD_DIR=@libphobos_builddir@ +SRC_DIR=@libphobos_srcdir@ +query=$1 + +case ${query} in + --gdc) + GDC="@GDC@" + echo ${GDC} + ;; + --gdcflags) + GDCFLAGS_default="-fmessage-length=0 -fno-show-column" + GDCFLAGS_config="@GDCFLAGSX@" + echo ${GDCFLAGS_default} ${GDCFLAGS_config} + ;; + --gdcpaths) + GDCPATHS_default="-nostdinc" + GDCPATHS_config="-B${BUILD_DIR}/src + -I${BUILD_DIR}/libdruntime + -I${SRC_DIR}/libdruntime" + echo ${GDCPATHS_default} ${GDCPATHS_config} + ;; + --gdcldflags) + GDCLDFLAGS="-B${BUILD_DIR}/src + -L${BUILD_DIR}/libdruntime/.libs + -L${BUILD_DIR}/src/.libs" + echo ${GDCLDFLAGS} + ;; + *) + print_usage + ;; +esac + +exit 0 |