From 2a31c6236de308f7109720230e70b96c5d5b966a Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 20 Aug 2014 18:55:54 +0100 Subject: Integrate PR 12649's race detector directly in the testsuite machinery This integrates Jan Kratochvil's nice race reproducer from PR testsuite/12649 into the testsuite infrustructure directly. With this, one only has to do either 'make check-read1' or 'make check READ1="1"' to preload the read1.so library into expect. Currently only enabled for glibc/GNU systems, and if build==host==target. gdb/testsuite/ChangeLog: * Makefile.in (EXTRA_RULES, CC): New variables, get from configure. (EXPECT): Handle READ1 being set. (all): Depend on EXTRA_RULES. (check-read1, expect-read1, read1.so, read1): New rules. * README (Testsuite Parameters): Document the READ1 make variable. (Race detection): New section. * configure: Regenerate. * configure.ac: If build==host==target, and running under a GNU/glibc system, add read1 to the extra Makefile rules. (EXTRA_RULES): AC_SUBST it. * lib/read1.c: New file. gdb/ChangeLog: * Makefile.in (check-read1): New rule. --- gdb/testsuite/Makefile.in | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'gdb/testsuite/Makefile.in') diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in index 0020a0f..1c923cd 100644 --- a/gdb/testsuite/Makefile.in +++ b/gdb/testsuite/Makefile.in @@ -39,9 +39,17 @@ ALL_SUBDIRS = gdb.ada gdb.arch gdb.asm gdb.base gdb.btrace gdb.cell gdb.cp \ gdb.stabs gdb.reverse gdb.threads gdb.trace gdb.xml \ $(SUBDIRS) -EXPECT = `if [ -f $${rootme}/../../expect/expect ] ; then \ - echo $${rootme}/../../expect/expect ; \ - else echo expect ; fi` +EXTRA_RULES = @EXTRA_RULES@ + +CC=@CC@ + +EXPECT = `if [ "$${READ1}" != "" ] ; then \ + echo $${rootme}/expect-read1; \ + elif [ -f $${rootme}/../../expect/expect ] ; then \ + echo $${rootme}/../../expect/expect ; \ + else \ + echo expect ; \ + fi` RUNTEST = $(RUNTEST_FOR_TARGET) @@ -84,7 +92,7 @@ TARGET_FLAGS_TO_PASS = \ "RUNTEST=$(RUNTEST)" \ "RUNTESTFLAGS=$(RUNTESTFLAGS)" -all: +all: $(EXTRA_RULES) @echo "Nothing to be done for all..." .NOEXPORT: @@ -146,6 +154,9 @@ installcheck: check: all $(abs_builddir)/site.exp $(MAKE) $(CHECK_TARGET) +check-read1: + $(MAKE) READ1="1" check + # All the hair to invoke dejagnu. A given invocation can just append # $(RUNTESTFLAGS) DO_RUNTEST = \ @@ -230,6 +241,7 @@ clean mostlyclean: -rm -f core.* *.tf *.cl *.py tracecommandsscript copy1.txt zzz-gdbscript -rm -f *.dwo *.dwp -rm -rf outputs temp cache + -rm -f read1.so expect-read1 if [ x"${ALL_SUBDIRS}" != x ] ; then \ for dir in ${ALL_SUBDIRS}; \ do \ @@ -263,3 +275,27 @@ config.status: configure TAGS: force find $(srcdir) -name '*.exp' -print | \ etags --regex='/proc[ \t]+\([^ \t]+\)/\1/' - + +# Build the expect wrapper script that preloads the read1.so library. +expect-read1: + @echo Making expect-read1 + @rm -f expect-read1-tmp + @touch expect-read1-tmp + @echo "# THIS FILE IS GENERATED -*- buffer-read-only: t -*- \n" >>expect-read1-tmp + @echo "# vi:set ro: */\n\n" >>expect-read1-tmp + @echo "# To regenerate this file, run:\n" >>expect-read1-tmp + @echo "# make clean; make/\n" >>expect-read1-tmp + @echo "export LD_PRELOAD=`pwd`/read1.so" >>expect-read1-tmp + @echo 'exec expect "$$@"' >>expect-read1-tmp + @chmod +x expect-read1-tmp + @mv expect-read1-tmp expect-read1 + +# Build the read1.so preload library. This overrides the `read' +# function, making it read one byte at a time. Running the testsuite +# with this catches racy tests. +read1.so: lib/read1.c + $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC $(CFLAGS) + +# Build the read1 machinery. +.PHONY: read1 +read1: read1.so expect-read1 -- cgit v1.1