diff options
author | Ian Lance Taylor <iant@google.com> | 2006-11-30 23:52:50 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2006-11-30 23:52:50 +0000 |
commit | 5a6f7e2db556f93765b75baf2d1ee1509225410d (patch) | |
tree | 6db53a1cd843958dc18135430dbf37bd7b92b17e /gold/testsuite | |
parent | 2621033b5dbe773f00cb90d24604b70a1cead2f1 (diff) | |
download | gdb-5a6f7e2db556f93765b75baf2d1ee1509225410d.zip gdb-5a6f7e2db556f93765b75baf2d1ee1509225410d.tar.gz gdb-5a6f7e2db556f93765b75baf2d1ee1509225410d.tar.bz2 |
Added a testsuite. More support for COPY relocations.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 22 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 521 | ||||
-rw-r--r-- | gold/testsuite/object_unittest.cc | 41 | ||||
-rw-r--r-- | gold/testsuite/test.cc | 78 | ||||
-rw-r--r-- | gold/testsuite/test.h | 121 | ||||
-rw-r--r-- | gold/testsuite/testfile.cc | 261 | ||||
-rw-r--r-- | gold/testsuite/testfile.h | 20 | ||||
-rw-r--r-- | gold/testsuite/testmain.cc | 18 |
8 files changed, 1082 insertions, 0 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am new file mode 100644 index 0000000..122be70 --- /dev/null +++ b/gold/testsuite/Makefile.am @@ -0,0 +1,22 @@ +# Process this file with automake to generate Makefile.in + +AUTOMAKE_OPTIONS = + +AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CXXFLAGS) + +INCLUDES = -D_GNU_SOURCE \ + -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../include \ + -I$(srcdir)/../../elfcpp \ + -DLOCALEDIR="\"$(datadir)/locale\"" \ + @INCINTL@ + +TESTS = object_unittest + +check_LIBRARIES = libgoldtest.a +libgoldtest_a_SOURCES = test.cc testmain.cc testfile.cc + +LDADD = libgoldtest.a ../libgold.a + +check_PROGRAMS = object_unittest + +object_unittest_SOURCES = object_unittest.cc diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in new file mode 100644 index 0000000..4967af6 --- /dev/null +++ b/gold/testsuite/Makefile.in @@ -0,0 +1,521 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 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 generate Makefile.in +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +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@ +check_PROGRAMS = object_unittest$(EXEEXT) +subdir = testsuite +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/progtest.m4 \ + $(top_srcdir)/../config/po.m4 $(top_srcdir)/../config/nls.m4 \ + $(top_srcdir)/../config/gettext-sister.m4 \ + $(top_srcdir)/../bfd/warning.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 = +AR = ar +ARFLAGS = cru +libgoldtest_a_AR = $(AR) $(ARFLAGS) +libgoldtest_a_LIBADD = +am_libgoldtest_a_OBJECTS = test.$(OBJEXT) testmain.$(OBJEXT) \ + testfile.$(OBJEXT) +libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) +am_object_unittest_OBJECTS = object_unittest.$(OBJEXT) +object_unittest_OBJECTS = $(am_object_unittest_OBJECTS) +object_unittest_LDADD = $(LDADD) +object_unittest_DEPENDENCIES = libgoldtest.a ../libgold.a +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/../depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(libgoldtest_a_SOURCES) $(object_unittest_SOURCES) +DIST_SOURCES = $(libgoldtest_a_SOURCES) $(object_unittest_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GENCAT = @GENCAT@ +GMSGFMT = @GMSGFMT@ +INCINTL = @INCINTL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +LDFLAGS = @LDFLAGS@ +LFS_CXXFLAGS = @LFS_CXXFLAGS@ +LIBINTL = @LIBINTL@ +LIBINTL_DEP = @LIBINTL_DEP@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ +MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NO_WERROR = @NO_WERROR@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +WARN_CXXFLAGS = @WARN_CXXFLAGS@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +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@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +AUTOMAKE_OPTIONS = +AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CXXFLAGS) +INCLUDES = -D_GNU_SOURCE \ + -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../include \ + -I$(srcdir)/../../elfcpp \ + -DLOCALEDIR="\"$(datadir)/locale\"" \ + @INCINTL@ + +TESTS = object_unittest +check_LIBRARIES = libgoldtest.a +libgoldtest_a_SOURCES = test.cc testmain.cc testfile.cc +LDADD = libgoldtest.a ../libgold.a +object_unittest_SOURCES = object_unittest.cc +all: all-am + +.SUFFIXES: +.SUFFIXES: .cc .o .obj +$(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 \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \ + 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 + +clean-checkLIBRARIES: + -test -z "$(check_LIBRARIES)" || rm -f $(check_LIBRARIES) +libgoldtest.a: $(libgoldtest_a_OBJECTS) $(libgoldtest_a_DEPENDENCIES) + -rm -f libgoldtest.a + $(libgoldtest_a_AR) libgoldtest.a $(libgoldtest_a_OBJECTS) $(libgoldtest_a_LIBADD) + $(RANLIB) libgoldtest.a + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +object_unittest$(EXEEXT): $(object_unittest_OBJECTS) $(object_unittest_DEPENDENCIES) + @rm -f object_unittest$(EXEEXT) + $(CXXLINK) $(object_unittest_LDFLAGS) $(object_unittest_OBJECTS) $(object_unittest_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object_unittest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testmain.Po@am__quote@ + +.cc.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cc.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$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_LIBRARIES) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +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) + +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-checkLIBRARIES clean-checkPROGRAMS clean-generic \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkLIBRARIES clean-checkPROGRAMS clean-generic ctags \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-info-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/gold/testsuite/object_unittest.cc b/gold/testsuite/object_unittest.cc new file mode 100644 index 0000000..c15237d --- /dev/null +++ b/gold/testsuite/object_unittest.cc @@ -0,0 +1,41 @@ +// object_unittest.cc -- test Object, Relobj, etc. + +#include "gold.h" + +#include "object.h" + +#include "test.h" +#include "testfile.h" + +namespace gold_testsuite +{ + +using namespace gold; + +// Test basic Object functionality. + +bool +Object_test(Test_report*) +{ + Input_file input_file("test.o", test_file_1, test_file_1_size); + Object* object = make_elf_object("test.o", &input_file, 0, + test_file_1, test_file_1_size); + CHECK(object->name() == "test.o"); + CHECK(!object->is_dynamic()); + CHECK(object->target() == target_test_pointer); + CHECK(object->is_locked()); + object->unlock(); + CHECK(!object->is_locked()); + object->lock(); + CHECK(object->shnum() == 5); + CHECK(object->section_name(0).empty()); + CHECK(object->section_name(1) == ".test"); + CHECK(object->section_flags(0) == 0); + CHECK(object->section_flags(1) == elfcpp::SHF_ALLOC); + object->unlock(); + return true; +} + +Register_test object_register("Object", Object_test); + +} // End namespace gold_testsuite. diff --git a/gold/testsuite/test.cc b/gold/testsuite/test.cc new file mode 100644 index 0000000..37a4ada --- /dev/null +++ b/gold/testsuite/test.cc @@ -0,0 +1,78 @@ +// test.cc -- simplistic test framework for gold. + +#include "gold.h" + +#include <cstdio> + +#include "test.h" + +namespace gold_testsuite +{ + +// Test_framework methods. + +// The current test being run. + +Test_report* Test_framework::current_report; + +// Run a test. + +void +Test_framework::run(const char *name, bool (*pfn)(Test_report*)) +{ + this->testname_ = name; + this->current_fail_ = false; + + Test_report tr(this); + Test_framework::current_report = &tr; + + if ((*pfn)(&tr) && !this->current_fail_) + { + printf("PASS: %s\n", name); + ++this->passes_; + } + else + { + printf("FAIL: %s\n", name); + ++this->failures_; + } + + Test_framework::current_report = NULL; + this->testname_ = NULL; +} + +// Let a test report an error. + +void +Test_framework::error(const char* message) +{ + printf("ERROR: %s: %s\n", this->testname_, message); + this->fail(); +} + +// Register_test methods. + +// Linked list of all registered tests. + +Register_test* Register_test::all_tests; + +// Register a test. + +Register_test::Register_test(const char* name, bool (*pfn)(Test_report*)) + : name_(name), pfn_(pfn), next_(Register_test::all_tests) +{ + Register_test::all_tests = this; +} + +// Run all registered tests. + +void +Register_test::run_tests(Test_framework* tf) +{ + for (Register_test* p = Register_test::all_tests; + p != NULL; + p = p->next_) + tf->run(p->name_, p->pfn_); +} + +} // End namespace gold_testsuite. diff --git a/gold/testsuite/test.h b/gold/testsuite/test.h new file mode 100644 index 0000000..e0556e2 --- /dev/null +++ b/gold/testsuite/test.h @@ -0,0 +1,121 @@ +// test.h -- simplistic test framework for gold unittests -*- C++ -*- + +#ifndef GOLD_TESTSUITE_TEST_H +#define GOLD_TESTSUITE_TEST_H + +namespace gold_testsuite +{ + +class Test_report; + +// This class handles basic test framework functionality. + +class Test_framework +{ + public: + Test_framework() + : testname_(NULL), current_fail_(0), passes_(0), failures_(0) + { } + + // Return number of failures. + unsigned int + failures() const + { return this->failures_; } + + // Run a test. + void + run(const char* name, bool (*pfn)(Test_report*)); + + // Get the current Test_report. This is used by the test support + // macros. + static Test_report* + report() + { return Test_framework::current_report; } + + private: + friend class Test_report; + + // Cause the current test to fail. + void + fail() + { ++this->current_fail_ = true; } + + // Report an error from the current test. + void + error(const char* message); + + // Current Test_report. This is a static variable valid while a + // test is being run. + static Test_report* current_report; + + // Current test being run. + const char* testname_; + // Whether the current test is failing. + bool current_fail_; + // Total number of passeed tests. + unsigned int passes_; + // Total number of failed tests. + unsigned int failures_; +}; + +// An instance of this class is passed to each test function. + +class Test_report +{ +public: + Test_report(Test_framework* tf) + : tf_(tf) + { } + + // Mark the test as failing. + void + fail() + { this->tf_->fail(); } + + // Report an error. + void + error(const char* message) + { this->tf_->error(message); } + +private: + Test_framework* tf_; +}; + +// This class registers a test function so that the testsuite runs it. + +class Register_test +{ + public: + Register_test(const char* name, bool (*pfn)(Test_report*)); + + // Run all registered tests. + static void + run_tests(Test_framework*); + + private: + // Linked list of all tests. + static Register_test* all_tests; + + // Test name. + const char* name_; + // Function to call. It should return true if the test passes, + // false if it fails. + bool (*pfn_)(Test_report*); + // Next test in linked list. + Register_test* next_; +}; + +} // End namespace gold_testsuite. + +// These macros are for convenient use in tests. + +// Check that a condition is true. If it is false, report a failure. + +#define CHECK(cond) \ + ((cond) ? 0 : (::gold_testsuite::Test_framework::report()->fail(), 0)) + +// Report an error during a test. + +#define ERROR(msg) (::gold_testsuite::Test_framework::report()->error(msg)) + +#endif // !defined(GOLD_TESTSUITE_TEST_H) diff --git a/gold/testsuite/testfile.cc b/gold/testsuite/testfile.cc new file mode 100644 index 0000000..bfe3c9d --- /dev/null +++ b/gold/testsuite/testfile.cc @@ -0,0 +1,261 @@ +// testfile.cc -- Dummy ELF objects for testing purposes. + +#include "gold.h" + +#include "target.h" +#include "target-select.h" + +#include "test.h" +#include "testfile.h" + +namespace gold_testsuite +{ + +using namespace gold; + +// A Target used for testing purposes. + +class Target_test : public Sized_target<32, false> +{ + public: + Target_test() + : Sized_target<32, false>(&test_target_info) + { } + + void + scan_relocs(const General_options&, Symbol_table*, Layout*, + Sized_relobj<32, false>*, unsigned int, unsigned int, + const unsigned char*, size_t, size_t, const unsigned char*, + Symbol**) + { ERROR("call to Target_test::scan_relocs"); } + + void + relocate_section(const Relocate_info<32, false>*, unsigned int, + const unsigned char*, size_t, unsigned char*, + elfcpp::Elf_types<32>::Elf_Addr, off_t) + { ERROR("call to Target_test::relocate_section"); } + + static const Target::Target_info test_target_info; +}; + +const Target::Target_info Target_test::test_target_info = +{ + 32, // size + false, // is_big_endian + static_cast<elfcpp::EM>(0xffff), // machine_code + false, // has_make_symbol + false, // has_resolve + "/dummy", // dynamic_linker + 0x08000000, // text_segment_address + 0x1000, // abi_pagesize + 0x1000 // common_pagesize +}; + +// The single test target. + +Target_test target_test; + +// A pointer to the test target. This is used in CHECKs. + +Target* target_test_pointer = &target_test; + +// Select the test target. + +class Target_selector_test : public Target_selector +{ + public: + Target_selector_test() + : Target_selector(0xffff, 32, false) + { } + + Target* + recognize(int, int, int) + { return &target_test; } +}; + +// Register the test target selector. + +Target_selector_test target_selector_test; + +// A simple ELF object with one empty section, named ".test" and one +// globally visible symbol named "test". + +const unsigned char test_file_1[] = +{ + // Ehdr + // EI_MAG[0-3] + 0x7f, 'E', 'L', 'F', + // EI_CLASS: 32 bit. + 1, + // EI_DATA: little endian + 1, + // EI_VERSION + 1, + // EI_OSABI + 0, + // EI_ABIVERSION + 0, + // EI_PAD + 0, 0, 0, 0, 0, 0, 0, + // e_type: ET_REL + 1, 0, + // e_machine: a magic value used for testing. + 0xff, 0xff, + // e_version + 1, 0, 0, 0, + // e_entry + 0, 0, 0, 0, + // e_phoff + 0, 0, 0, 0, + // e_shoff: starts right after file header + 52, 0, 0, 0, + // e_flags + 0, 0, 0, 0, + // e_ehsize + 52, 0, + // e_phentsize + 32, 0, + // e_phnum + 0, 0, + // e_shentsize + 40, 0, + // e_shnum: dummy, .test, .symtab, .strtab, .shstrtab + 5, 0, + // e_shstrndx + 4, 0, + + // Offset 52 + // Shdr 0: dummy entry + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + // Offset 92 + // Shdr 1: .test + // sh_name: after initial null + 1, 0, 0, 0, + // sh_type: SHT_PROGBITS + 1, 0, 0, 0, + // sh_flags: SHF_ALLOC + 2, 0, 0, 0, + // sh_addr + 0, 0, 0, 0, + // sh_offset: after file header + 5 section headers + 252, 0, 0, 0, + // sh_size + 0, 0, 0, 0, + // sh_link + 0, 0, 0, 0, + // sh_info + 0, 0, 0, 0, + // sh_addralign + 1, 0, 0, 0, + // sh_entsize + 0, 0, 0, 0, + + // Offset 132 + // Shdr 2: .symtab + // sh_name: 1 null byte + ".test\0" + 7, 0, 0, 0, + // sh_type: SHT_SYMTAB + 2, 0, 0, 0, + // sh_flags + 0, 0, 0, 0, + // sh_addr + 0, 0, 0, 0, + // sh_offset: after file header + 5 section headers + empty section + 252, 0, 0, 0, + // sh_size: two symbols: dummy symbol + test symbol + 32, 0, 0, 0, + // sh_link: to .strtab + 3, 0, 0, 0, + // sh_info: one local symbol, the dummy symbol + 1, 0, 0, 0, + // sh_addralign + 4, 0, 0, 0, + // sh_entsize: size of symbol + 16, 0, 0, 0, + + // Offset 172 + // Shdr 3: .strtab + // sh_name: 1 null byte + ".test\0" + ".symtab\0" + 15, 0, 0, 0, + // sh_type: SHT_STRTAB + 3, 0, 0, 0, + // sh_flags + 0, 0, 0, 0, + // sh_addr + 0, 0, 0, 0, + // sh_offset: after .symtab section. 284 == 0x11c + 0x1c, 0x1, 0, 0, + // sh_size: 1 null byte + "test\0" + 6, 0, 0, 0, + // sh_link + 0, 0, 0, 0, + // sh_info + 0, 0, 0, 0, + // sh_addralign + 1, 0, 0, 0, + // sh_entsize + 0, 0, 0, 0, + + // Offset 212 + // Shdr 4: .shstrtab + // sh_name: 1 null byte + ".test\0" + ".symtab\0" + ".strtab\0" + 23, 0, 0, 0, + // sh_type: SHT_STRTAB + 3, 0, 0, 0, + // sh_flags + 0, 0, 0, 0, + // sh_addr + 0, 0, 0, 0, + // sh_offset: after .strtab section. 290 == 0x122 + 0x22, 0x1, 0, 0, + // sh_size: all section names + 33, 0, 0, 0, + // sh_link + 0, 0, 0, 0, + // sh_info + 0, 0, 0, 0, + // sh_addralign + 1, 0, 0, 0, + // sh_entsize + 0, 0, 0, 0, + + // Offset 252 + // Contents of .symtab section + // Symbol 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + // Offset 268 + // Symbol 1 + // st_name + 1, 0, 0, 0, + // st_value + 0, 0, 0, 0, + // st_size + 0, 0, 0, 0, + // st_info: STT_NOTYPE, STB_GLOBAL + 0x10, + // st_other + 0, + // st_shndx: In .test + 1, 0, + + // Offset 284 + // Contents of .strtab section + '\0', + 't', 'e', 's', 't', '\0', + + // Offset 290 + // Contents of .shstrtab section + '\0', + '.', 't', 'e', 's', 't', '\0', + '.', 's', 'y', 'm', 't', 'a', 'b', '\0', + '.', 's', 't', 'r', 't', 'a', 'b', '\0', + '.', 's', 'h', 's', 't', 'r', 't', 'a', 'b', '\0' +}; + +const unsigned int test_file_1_size = sizeof test_file_1; + +} // End namespace gold_testsuite. diff --git a/gold/testsuite/testfile.h b/gold/testsuite/testfile.h new file mode 100644 index 0000000..c123107 --- /dev/null +++ b/gold/testsuite/testfile.h @@ -0,0 +1,20 @@ +// testfile.h -- test input files -*- C++ -*- + +#ifndef GOLD_TESTSUITE_TESTFILE_H +#define GOLD_TESTSUITE_TESTFILE_H + +namespace gold +{ +class Target; +} + +namespace gold_testsuite +{ + +extern gold::Target* target_test_pointer; +extern const unsigned char test_file_1[]; +extern const unsigned int test_file_1_size; + +}; // End namespace gold_testsuite. + +#endif // !defined(GOLD_TESTSUITE_TESTFILE_H) diff --git a/gold/testsuite/testmain.cc b/gold/testsuite/testmain.cc new file mode 100644 index 0000000..eb46b72 --- /dev/null +++ b/gold/testsuite/testmain.cc @@ -0,0 +1,18 @@ +// testmain.cc -- main function for simplisitic gold test framework. + +#include "gold.h" + +#include "test.h" + +using namespace gold_testsuite; + +int +main(int, char** argv) +{ + gold::program_name = argv[0]; + + Test_framework tf; + Register_test::run_tests(&tf); + + exit(tf.failures()); +} |