public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [rfc] Program to check bfd_format vector
@ 2004-06-29 23:28 Andrew Cagney
  2004-07-15 14:43 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cagney @ 2004-06-29 23:28 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 189 bytes --]

Hello,

The attached adds the program selftest.c (built when make check) to the 
binutils/ directory.  I'm guessing that it should be run as part of the 
testsuite, but when/where?

Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 5413 bytes --]

2004-06-29  Andrew Cagney  <cagney@gnu.org>

	* Makefile.am (PROGS, SELFTEST_PROG, check_PROGRAMS, CFILES): Add
	program "selftest".
	* Makefile.in: Re-generate.
	* selftest.c: New file.

Index: Makefile.am
===================================================================
RCS file: /cvs/src/src/binutils/Makefile.am,v
retrieving revision 1.50
diff -p -u -r1.50 Makefile.am
--- Makefile.am	19 Mar 2004 07:03:40 -0000	1.50
+++ Makefile.am	29 Jun 2004 23:25:13 -0000
@@ -52,7 +52,11 @@ DLLWRAP_PROG=dllwrap
 
 SRCONV_PROG=srconv$(EXEEXT) sysdump$(EXEEXT) coffdump$(EXEEXT) 
 
-PROGS = $(SIZE_PROG) $(OBJDUMP_PROG) $(NM_PROG) $(AR_PROG) $(STRINGS_PROG) $(STRIP_PROG) $(RANLIB_PROG) $(DEMANGLER_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ $(ADDR2LINE_PROG) $(READELF_PROG) @BUILD_DLLWRAP@ @BUILD_MISC@
+# Simple program to selfcheck BFD's internals.
+SELFTEST_PROG=selftest
+check_PROGRAMS = $(SELFTEST_PROG)
+
+PROGS = $(SIZE_PROG) $(OBJDUMP_PROG) $(NM_PROG) $(AR_PROG) $(STRINGS_PROG) $(STRIP_PROG) $(RANLIB_PROG) $(DEMANGLER_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ $(ADDR2LINE_PROG) $(READELF_PROG) @BUILD_DLLWRAP@ @BUILD_MISC@ $(SELFTEST_PROG)
 
 bin_PROGRAMS = $(SIZE_PROG) $(OBJDUMP_PROG) $(AR_PROG) $(STRINGS_PROG) $(RANLIB_PROG) $(OBJCOPY_PROG) @BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ $(ADDR2LINE_PROG) $(READELF_PROG) @BUILD_DLLWRAP@ @BUILD_MISC@
 
@@ -94,6 +98,7 @@ CFILES = \
 	objcopy.c objdump.c prdbg.c \
 	rdcoff.c rddbg.c readelf.c rename.c \
 	resbin.c rescoff.c resrc.c resres.c \
+	selftest.c \
 	size.c srconv.c stabs.c strings.c sysdump.c version.c \
 	windres.c winduni.c wrstabs.c
 
@@ -192,6 +197,8 @@ ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) @L
 
 addr2line_SOURCES = addr2line.c budemang.c $(BULIBS)
 
+selftest_SOURCES = selftest.c
+
 # The following is commented out for the conversion to automake.
 # This rule creates a single binary that switches between ar and ranlib
 # by looking at argv[0].  Use this kludge to save some disk space.
Index: selftest.c
===================================================================
RCS file: selftest.c
diff -N selftest.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ selftest.c	29 Jun 2004 23:25:14 -0000
@@ -0,0 +1,71 @@
+/* verify.c -- Verify BFD's internals.
+
+   Copyright 2004 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.  */
+
+#include <stdio.h>
+#include <assert.h>
+#include "bfd.h"
+#include "libbfd.h"
+
+#define CHECK(TARGET,METHOD,FORMAT) \
+check ((*TARGET), (*TARGET)->METHOD[FORMAT], #METHOD, FORMAT)
+
+static void
+check (const struct bfd_target *target, void *method,
+       const char *method_name, enum bfd_format format)
+{
+  if (method == NULL)
+    {
+      const char *format_name;
+      switch (format)
+	{
+#define CASE(F) case F: format_name = #F; break
+	  CASE (bfd_unknown);
+	  CASE (bfd_object);
+	  CASE (bfd_archive);
+	  CASE (bfd_core);
+	  CASE (bfd_runtime);
+	  CASE (bfd_type_end);
+	default: format_name = "<internal-error>"; break;
+	}
+      printf ("%s->%s[%s]\n", target->name, method_name, format_name);
+    }
+}
+
+int
+main ()
+{
+  {
+    struct bfd_target const * const*target;
+    for (target = bfd_target_vector; *target != NULL; target++)
+      {
+	{
+	  enum bfd_format format;
+	  for (format = bfd_unknown; format < bfd_type_end; format++)
+	    {
+	      CHECK (target, _bfd_check_format, format);
+	      CHECK (target, _bfd_set_format, format);
+	      CHECK (target, _bfd_write_contents, format);
+	    }
+	}
+      }
+  }
+  return 0;
+}
Index: doc/Makefile.in
===================================================================
RCS file: /cvs/src/src/binutils/doc/Makefile.in,v
retrieving revision 1.14
diff -p -u -r1.14 Makefile.in
--- doc/Makefile.in	28 Nov 2003 04:58:41 -0000	1.14
+++ doc/Makefile.in	29 Jun 2004 23:25:14 -0000
@@ -1,6 +1,6 @@
-# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999 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.
@@ -264,7 +264,7 @@ uninstall-info:
 	else ii=; fi; \
 	list='$(INFO_DEPS)'; \
 	for file in $$list; do \
-	  test -z "$$ii" \
+	  test -z "$ii" \
 	    || install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \
 	done
 	@$(NORMAL_UNINSTALL)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [rfc] Program to check bfd_format vector
  2004-06-29 23:28 [rfc] Program to check bfd_format vector Andrew Cagney
@ 2004-07-15 14:43 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2004-07-15 14:43 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: binutils

Hi Andrew,

   (Sorry for the long delay in replying to this email)

> The attached adds the program selftest.c (built when make check) to the 
> binutils/ directory.  I'm guessing that it should be run as part of the 
> testsuite, but when/where?

when: Any time the binutils testsuite is run.

      (If this test ever fails then the BFD API is broken and we cannot 
expect other binutils tests to necessarily work correctly).

Where: In the binutils testsuite:  binutils/testsuite/binutils-all.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-07-15 14:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-29 23:28 [rfc] Program to check bfd_format vector Andrew Cagney
2004-07-15 14:43 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).