[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r8817 - in /libdfp/trunk: Makefile.gdb Makefile.in tests/test-printf.c



Author: ryanarn
Date: Thu Aug 13 16:12:02 2009
New Revision: 8817

Log:
2009-08-13  Ryan S. Arnold  <rsa@xxxxxxxxxx>

	* Makefile.in: For .out rules send stdout to /dev/null and stderr to
	the .out file.
	* tests/test-printf.c:
	* Makefile.gdb: Squelch echos of .conf and .gdb file creation.

Modified:
    libdfp/trunk/Makefile.gdb
    libdfp/trunk/Makefile.in
    libdfp/trunk/tests/test-printf.c

Modified: libdfp/trunk/Makefile.gdb
==============================================================================
--- libdfp/trunk/Makefile.gdb (original)
+++ libdfp/trunk/Makefile.gdb Thu Aug 13 16:12:02 2009
@@ -2,40 +2,43 @@
 # it's going into it's own Makefile.
 
 $(top_builddir)/debug-test.conf: Makefile
-	echo 'CC="$(CC)"' > $@
-	echo 'DBG=$(dir $(firstword $(CC)))gdb$(cc_msize)' >> $@
-	echo 'OBJDUMP=$(dir $(firstword $(CC)))objdump' >> $@
-	echo 'GLIBC_BUILD=$(glibc_builddir)' >> $@
-	echo 'GLIBC_HEADERS=$(glibc_headers)' >> $@
-	echo 'LIBDFP_BUILD=$(top_builddir)/' >> $@
-	echo 'LIBDFP_HEADERS=$(top_srcdir)/dfp' >> $@
-	echo 'LIBDFP_SRC=$(top_srcdir)' >> $@
+	echo "Generating common debug configuration file $@."
+	@echo 'CC="$(CC)"' > $@
+	@echo 'DBG=$(dir $(firstword $(CC)))gdb$(cc_msize)' >> $@
+	@echo 'OBJDUMP=$(dir $(firstword $(CC)))objdump' >> $@
+	@echo 'GLIBC_BUILD=$(glibc_builddir)' >> $@
+	@echo 'GLIBC_HEADERS=$(glibc_headers)' >> $@
+	@echo 'LIBDFP_BUILD=$(top_builddir)/' >> $@
+	@echo 'LIBDFP_HEADERS=$(top_srcdir)/dfp' >> $@
+	@echo 'LIBDFP_SRC=$(top_srcdir)' >> $@
 	cp $(top_srcdir)/tests/debug-test.sh $(top_builddir)/
 	@echo
 
 $(addsuffix .conf,$(libdfp_tests)):
-	echo 'GDB_SCRIPT="$(patsubst %.conf,%,$@).gdb"' > $@
-	echo 'APP="$(patsubst %.conf,%,$@)"' >> $@
-	echo 'APP_SRC="$(patsubst %.conf,%,$@).c"' >> $@
+	echo "Generating $@ configuration file."
+	@echo 'GDB_SCRIPT="$(patsubst %.conf,%,$@).gdb"' > $@
+	@echo 'APP="$(patsubst %.conf,%,$@)"' >> $@
+	@echo 'APP_SRC="$(patsubst %.conf,%,$@).c"' >> $@
 	@echo
 
 $(addsuffix .gdb,$(libdfp_tests)): $(libdfp_tests)
-	echo 'set environment C -E -x c-header' > $@
-	echo 'break _dl_main_dispatch' >> $@
-	echo 'run --library-path $(LIBRARY_PATH):$(glibc_builddir)/nptl_db:$(top_builddir)/ $(top_builddir)/$(patsubst %.gdb,%,$@)' >> $@
-	echo '' >> $@
-	echo -n 'add-symbol-file $(top_builddir)/$(patsubst %.gdb,%,$@) 0x' >> $@
-	echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(top_builddir)/$(patsubst %.gdb,%,$@) | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
-	echo '' >> $@
-	echo 'set $$libc = 0x' >> $@
-	echo -n 'set $$start = 0x' >> $@
-	echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(glibc_builddir)/libc.so | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
-	echo 'set $$addr = $$libc + $$start' >> $@
-	echo 'add-symbol-file $(glibc_builddir)/libc.so $$addr' >> $@
-	echo '' >> $@
-	echo 'set $$libdfp = 0x' >> $@
-	echo -n 'set $$start = 0x' >> $@
-	echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(top_builddir)/libdfp.so.1 | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
-	echo 'set $$addr = $$libdfp + $$start' >> $@
-	echo 'add-symbol-file $(top_builddir)/libdfp.so.1 $$addr' >> $@
+	echo "Generating GDB script $@"
+	@echo 'set environment C -E -x c-header' > $@
+	@echo 'break _dl_main_dispatch' >> $@
+	@echo 'run --library-path $(LIBRARY_PATH):$(glibc_builddir)/nptl_db:$(top_builddir)/ $(top_builddir)/$(patsubst %.gdb,%,$@)' >> $@
+	@echo '' >> $@
+	@echo -n 'add-symbol-file $(top_builddir)/$(patsubst %.gdb,%,$@) 0x' >> $@
+	@echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(top_builddir)/$(patsubst %.gdb,%,$@) | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
+	@echo '' >> $@
+	@echo 'set $$libc = 0x' >> $@
+	@echo -n 'set $$start = 0x' >> $@
+	@echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(glibc_builddir)/libc.so | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
+	@echo 'set $$addr = $$libc + $$start' >> $@
+	@echo 'add-symbol-file $(glibc_builddir)/libc.so $$addr' >> $@
+	@echo '' >> $@
+	@echo 'set $$libdfp = 0x' >> $@
+	@echo -n 'set $$start = 0x' >> $@
+	@echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(top_builddir)/libdfp.so.1 | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
+	@echo 'set $$addr = $$libdfp + $$start' >> $@
+	@echo 'add-symbol-file $(top_builddir)/libdfp.so.1 $$addr' >> $@
 	@echo

Modified: libdfp/trunk/Makefile.in
==============================================================================
--- libdfp/trunk/Makefile.in (original)
+++ libdfp/trunk/Makefile.in Thu Aug 13 16:12:02 2009
@@ -269,12 +269,13 @@
 
 # Invoke the GLIBC loader and tell it to run the application.  Also make sure
 # the .gdb files are generated before the tests are run so that they get
-# generated even if the tests fail.
+# generated even if the tests fail.  Stderr is piped to the .out file while
+# stdout is dumped to /dev/null.
 $(addsuffix .out,$(libdfp_tests)): $(libdfp_tests) $(addsuffix .gdb,$(libdfp_tests))
 	ulimit -c unlimited; GCONV_PATH=$(glibc_builddir)/iconvdata LC_ALL=C \
 	$(glibc_builddir)/elf/ld.so --library-path \
 	$(LIBRARY_PATH):$(top_builddir) $(top_builddir)/$(patsubst %.out,%,$@) \
-	2>&1> $(top_builddir)/$@
+	2> $(top_builddir)/$@ 1> /dev/null
 	@echo
 
 DISTCLEANFILES = $(top_builddir)/debug-test.conf
@@ -285,7 +286,7 @@
 #	$(addsuffix .gdb,$(libdfp_tests)):
 include $(top_srcdir)/Makefile.gdb
 
-# We use debug-test.conf as an input file for some debuggin utilities.
+# We use debug-test.conf as an input file for some debugging utilities.
 check: $(top_builddir)/debug-test.conf $(addsuffix .conf,$(libdfp_tests)) $(addsuffix .out,$(libdfp_tests)) $(addsuffix .gdb,$(libdfp_tests))
 
 #	@echo Running make check against tests: $(libdfp_tests)

Modified: libdfp/trunk/tests/test-printf.c
==============================================================================
--- libdfp/trunk/tests/test-printf.c (original)
+++ libdfp/trunk/tests/test-printf.c Thu Aug 13 16:12:02 2009
@@ -1,3 +1,27 @@
+/* Test printf_dfp facility.
+
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This file is part of the Decimal Floating Point C Library.
+
+   Author(s): Ryan S. Arnold <rsa@xxxxxxxxxx>
+
+   The Decimal Floating Point C Library is free software; you can
+   redistribute it and/or modify it under the terms of the GNU Lesser
+   General Public License version 2.1.
+
+   The Decimal Floating Point C Library 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 Lesser General Public License version 2.1 for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License version 2.1 along with the Decimal Floating Point C Library;
+   if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+   Suite 330, Boston, MA 02111-1307 USA.
+
+   Please see libdfp/COPYING.txt for more information.  */
+
 #ifndef __STDC_WANT_DEC_FP__
 #define __STDC_WANT_DEC_FP__
 #endif
@@ -7,21 +31,47 @@
 #include <stdio.h>
 #include <wchar.h> /* This should pick up the libdfp wchar in dfp/wchar.h.  */
 
-int main ()
+#include "scaffold.c" /* Pick up the _PC(x,y,...) macro.  */
+
+/* Inspired by GLIBC stdio-common/tfformat.c  */
+typedef struct{
+	  int line;
+	  _Decimal128 d;
+	  const char *expect;
+	  const char *format;
+} d128_type;
+
+d128_type printf_d128s[] =
 {
-	_Decimal32 d32 = 1.11111111111DF;
-	_Decimal128 d128 = 0.000033333DL;
-	_Decimal64 d64 = 2.22222222222DD;
+  {__LINE__, 0.000033333DL, "0.000033333", "%DDf"},
+  /* Three digits of precision right of the decimal place.  */
+  {__LINE__, 231.2315DL, "231.232", "%.3DDf"},
+  /* Four digits of precision right of the decimal place.  */
+  {__LINE__, 231.2315DL, "231.2315", "%.4DDf"},
+  /* Default six digits of precision right of the decimal place.  */
+  {__LINE__, 231.2311116DL, "231.231112", "%DDf"},
+  /* Space padded to 12,  Right justified.  */
+  {__LINE__, 231.2315DL, "12.3", "%12.3DDf"},
+  /* Left justified, Space padded to 12.  */
+  {__LINE__, 231.2315DL, "12.3", "%-12.3DDf"},
 
-	double d = 1.234567;
-	printf("%e.\n",d);
+  {0,0,0,0 }
+};
 
-	register_printf_dfp();
-	printf("%Hf.\n",d32);
-	printf("%Df.\n",d64);
-	printf("%DDf.\n",d128);
+int main (int argc, char ** argv)
+{
+  d128_type *dptr;
 
-	d = 3.1415962;
-	printf("%e.\n",d);
-	return 0;
+  fprintf(stdout, "Testing marker prior to register_printf_dfp() invocation.\n");
+  _PC("1.234567e+00", "%e", (double) 1.234567);
+
+  register_printf_dfp();
+
+  for (dptr = printf_d128s; dptr->line; dptr++)
+    {
+      _PC_P(__FILE__,dptr->line, dptr->expect,dptr->format,dptr->d);
+    }
+
+  _REPORT();
+  return 0;
 }