This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa mudflap] mudflap testsuite


Just committed:

[ libmudflap/ChangeLog ]

2002-08-14  Graydon Hoare  <graydon@redhat.com>

	* Makefile.am (TESTS): Add testsuite support.
	* Makefile.in: Regenerate.
	* test/mf-driver.c: New file.
	* test/buildtest.sh: New file.
	* test/passNN-frag.c: New testcases.
	* test/failNN-frag.c: New testcases.



Index: libmudflap/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/ChangeLog,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 ChangeLog
--- libmudflap/ChangeLog	14 Aug 2002 15:56:43 -0000	1.1.2.6
+++ libmudflap/ChangeLog	14 Aug 2002 17:33:07 -0000
@@ -1,5 +1,14 @@
 2002-08-14  Graydon Hoare  <graydon@redhat.com>
 
+	* Makefile.am (TESTS): Add testsuite support.
+	* Makefile.in: Regenerate.
+	* test/mf-driver.c: New file.
+	* test/buildtest.sh: New file.
+	* test/passNN-frag.c: New testcases.
+	* test/failNN-frag.c: New testcases.
+
+2002-08-14  Graydon Hoare  <graydon@redhat.com>
+
 	* mf-hooks.c: Change __real_strlen() to __real_strlen()+1 when
 	verifying non-size-limited string extents.
 
Index: libmudflap/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/Makefile.am,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 Makefile.am
--- libmudflap/Makefile.am	12 Aug 2002 21:09:48 -0000	1.1.2.1
+++ libmudflap/Makefile.am	14 Aug 2002 17:33:07 -0000
@@ -7,6 +7,29 @@
 AUTOMAKE_OPTIONS = 1.3 cygnus
 MAINT_CHARSET = latin1
 
+TESTS_ENVIRONMENT = MUDFLAP_OPTIONS='-mode-check -viol-abort'
+
+TESTS = test/fail1.x test/fail10.x test/fail11.x test/fail12.x \
+ test/fail2.x test/fail3.x test/fail4.x test/fail5.x test/fail6.x \
+ test/fail7.x test/fail8.x test/fail9.x test/pass1.x test/pass10.x \
+ test/pass11.x test/pass12.x test/pass2.x test/pass3.x test/pass4.x \
+ test/pass5.x test/pass6.x test/pass7.x test/pass8.x test/pass9.x 
+
+
+test/%.c: test/%-frag.c test/mf-driver.c test/buildtest.sh
+	@mkdir -p test
+	@cat $(srcdir)/test/mf-driver.c > $@
+	@echo 'void test() {' >> $@
+	@cat $< >> $@
+	@echo '}' >> $@
+
+test/fail%.x: test/fail%.c
+	$(CC) -DSHOULD_FAIL -fmudflap -o $@ $<
+
+test/pass%.x: test/pass%.c
+	$(CC) -DSHOULD_PASS -fmudflap -o $@ $<
+
+
 # SUBDIRS = 
 # PWD = $${PWDCMD-pwd}
 
Index: libmudflap/test/mf-driver.c
===================================================================
RCS file: libmudflap/test/mf-driver.c
diff -N libmudflap/test/mf-driver.c
--- libmudflap/test/mf-driver.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/mf-driver.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,64 @@
+#include <signal.h>
+#include <stdio.h>
+
+/* this is a simplistic test driver for memory fault detection using
+   mudflap. you include this file in your mudflapped test case and define a
+   function called "test" which is your testcase. you should be running
+   mudflap with --viol-abort since this driver traps SIGABRT to determine
+   if things went correctly. */
+
+#ifdef SHOULD_FAIL
+static const int should_fail = 1;
+#else 
+#ifdef SHOULD_PASS
+static const int should_fail = 0;
+#else
+#error please define SHOULD_PASS or SHOULD_FAIL
+#endif
+#endif
+
+static void test ();
+
+void
+abort_handler ()
+{
+  if (should_fail)
+    {
+      printf ("PASS \t %s aborted as expected\n", __FILE__);
+      exit (0);
+    }
+  else
+    {
+      printf ("FAIL \t %s aborted unexpectedly (should have completed)\n", __FILE__);
+      exit (1);
+    }
+}
+
+int 
+main ()
+{
+  struct sigaction act;
+  sigset_t set;
+
+  sigemptyset (&set);
+
+  act.sa_handler = &abort_handler;
+  act.sa_mask = set;
+  act.sa_flags = 0; 
+     
+  sigaction (SIGABRT, &act, NULL);
+
+  /* call user-supplied testcase */
+  test ();
+
+  if (should_fail)
+    {
+      printf ("FAIL \t %s completed unexpectedly (should have aborted)\n", __FILE__);
+      exit (1);
+    }
+  else
+    {
+      printf ("PASS \t %s completed as expected\n", __FILE__);
+      exit (0);
+    }
+}
Index: libmudflap/test/buildtest.sh
===================================================================
RCS file: libmudflap/test/buildtest.sh
diff -N libmudflap/test/buildtest.sh
--- libmudflap/test/buildtest.sh	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/buildtest.sh	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+cat mf-driver.c > $2
+echo 'void test() {' >> $2
+cat $1 >> $2
+echo '}' >> $2
Index: libmudflap/test/pass1-frag.c
===================================================================
RCS file: libmudflap/test/pass1-frag.c
diff -N libmudflap/test/pass1-frag.c
--- libmudflap/test/pass1-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass1-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,2 @@
+int foo [10];
+foo[9] = 0;
Index: libmudflap/test/pass2-frag.c
===================================================================
RCS file: libmudflap/test/pass2-frag.c
diff -N libmudflap/test/pass2-frag.c
--- libmudflap/test/pass2-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass2-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,2 @@
+int foo [10][10];
+foo[9][0] = 0;
Index: libmudflap/test/pass3-frag.c
===================================================================
RCS file: libmudflap/test/pass3-frag.c
diff -N libmudflap/test/pass3-frag.c
--- libmudflap/test/pass3-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass3-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,2 @@
+int foo [10][10][10];
+foo[9][9][0] = 0;
Index: libmudflap/test/pass4-frag.c
===================================================================
RCS file: libmudflap/test/pass4-frag.c
diff -N libmudflap/test/pass4-frag.c
--- libmudflap/test/pass4-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass4-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,2 @@
+char foo [10];
+strcpy(foo, "123456789");
Index: libmudflap/test/pass5-frag.c
===================================================================
RCS file: libmudflap/test/pass5-frag.c
diff -N libmudflap/test/pass5-frag.c
--- libmudflap/test/pass5-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass5-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,3 @@
+char foo [10];
+char bar [10];
+memcpy(foo, bar, 10);
Index: libmudflap/test/pass6-frag.c
===================================================================
RCS file: libmudflap/test/pass6-frag.c
diff -N libmudflap/test/pass6-frag.c
--- libmudflap/test/pass6-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass6-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,7 @@
+char *foo;
+char *bar;
+
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+memcpy(foo, bar, 10);
Index: libmudflap/test/pass7-frag.c
===================================================================
RCS file: libmudflap/test/pass7-frag.c
diff -N libmudflap/test/pass7-frag.c
--- libmudflap/test/pass7-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass7-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,6 @@
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+memcpy(foo+1, bar+1, 9);
Index: libmudflap/test/pass8-frag.c
===================================================================
RCS file: libmudflap/test/pass8-frag.c
diff -N libmudflap/test/pass8-frag.c
--- libmudflap/test/pass8-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass8-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,9 @@
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+free(bar);
+bar = (char *)malloc (10);
+
+memcpy(foo, bar, 10);
Index: libmudflap/test/pass9-frag.c
===================================================================
RCS file: libmudflap/test/pass9-frag.c
diff -N libmudflap/test/pass9-frag.c
--- libmudflap/test/pass9-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass9-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,9 @@
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+free(foo);
+foo = (char *)malloc (10);
+
+memcpy(foo, bar, 10);
Index: libmudflap/test/pass10-frag.c
===================================================================
RCS file: libmudflap/test/pass10-frag.c
diff -N libmudflap/test/pass10-frag.c
--- libmudflap/test/pass10-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass10-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,5 @@
+int foo[10];
+int sz = sizeof (int);
+
+char *bar = (char *)foo;
+bar [sz * 9] = 0;
Index: libmudflap/test/pass11-frag.c
===================================================================
RCS file: libmudflap/test/pass11-frag.c
diff -N libmudflap/test/pass11-frag.c
--- libmudflap/test/pass11-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass11-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,8 @@
+int i = 10;
+char *x = (void *)malloc(i * sizeof (char));
+
+while (--i)
+{
+  ++x;
+  *x = 0;
+}
Index: libmudflap/test/pass12-frag.c
===================================================================
RCS file: libmudflap/test/pass12-frag.c
diff -N libmudflap/test/pass12-frag.c
--- libmudflap/test/pass12-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/pass12-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,8 @@
+int i = 10;
+int *x = (void *)malloc(i * sizeof (int));
+
+while (--i)
+{
+  ++x;
+  *x = 0;
+}
Index: libmudflap/test/fail1-frag.c
===================================================================
RCS file: libmudflap/test/fail1-frag.c
diff -N libmudflap/test/fail1-frag.c
--- libmudflap/test/fail1-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail1-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,2 @@
+int foo [10];
+foo[10] = 0;
Index: libmudflap/test/fail2-frag.c
===================================================================
RCS file: libmudflap/test/fail2-frag.c
diff -N libmudflap/test/fail2-frag.c
--- libmudflap/test/fail2-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail2-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,2 @@
+int foo [10][10];
+foo[10][0] = 0;
Index: libmudflap/test/fail3-frag.c
===================================================================
RCS file: libmudflap/test/fail3-frag.c
diff -N libmudflap/test/fail3-frag.c
--- libmudflap/test/fail3-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail3-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,2 @@
+int foo [10][10][10];
+foo[9][10][0] = 0;
Index: libmudflap/test/fail4-frag.c
===================================================================
RCS file: libmudflap/test/fail4-frag.c
diff -N libmudflap/test/fail4-frag.c
--- libmudflap/test/fail4-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail4-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,2 @@
+char foo [10];
+strcpy(foo, "1234567890");
Index: libmudflap/test/fail5-frag.c
===================================================================
RCS file: libmudflap/test/fail5-frag.c
diff -N libmudflap/test/fail5-frag.c
--- libmudflap/test/fail5-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail5-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,3 @@
+char foo [10];
+char bar [10];
+memcpy(foo, bar, 11);
Index: libmudflap/test/fail6-frag.c
===================================================================
RCS file: libmudflap/test/fail6-frag.c
diff -N libmudflap/test/fail6-frag.c
--- libmudflap/test/fail6-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail6-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,6 @@
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+memcpy(foo, bar, 11);
Index: libmudflap/test/fail7-frag.c
===================================================================
RCS file: libmudflap/test/fail7-frag.c
diff -N libmudflap/test/fail7-frag.c
--- libmudflap/test/fail7-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail7-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,6 @@
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+memcpy(foo+1, bar+1, 10);
Index: libmudflap/test/fail8-frag.c
===================================================================
RCS file: libmudflap/test/fail8-frag.c
diff -N libmudflap/test/fail8-frag.c
--- libmudflap/test/fail8-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail8-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,8 @@
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+free(bar);
+
+memcpy(foo, bar, 10);
Index: libmudflap/test/fail9-frag.c
===================================================================
RCS file: libmudflap/test/fail9-frag.c
diff -N libmudflap/test/fail9-frag.c
--- libmudflap/test/fail9-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail9-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,8 @@
+char *foo;
+char *bar;
+foo = (char *)malloc (10);
+bar = (char *)malloc (10);
+
+free(foo);
+
+memcpy(foo, bar, 10);
Index: libmudflap/test/fail10-frag.c
===================================================================
RCS file: libmudflap/test/fail10-frag.c
diff -N libmudflap/test/fail10-frag.c
--- libmudflap/test/fail10-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail10-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,5 @@
+int foo[10];
+int sz = sizeof (int);
+
+char *bar = (char *)foo;
+bar [sz * 10] = 0;
Index: libmudflap/test/fail11-frag.c
===================================================================
RCS file: libmudflap/test/fail11-frag.c
diff -N libmudflap/test/fail11-frag.c
--- libmudflap/test/fail11-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail11-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,8 @@
+int i = 10;
+char *x = (void *)malloc(i * sizeof (char));
+
+while (i--)
+{
+  ++x;
+  *x = 0;
+}
Index: libmudflap/test/fail12-frag.c
===================================================================
RCS file: libmudflap/test/fail12-frag.c
diff -N libmudflap/test/fail12-frag.c
--- libmudflap/test/fail12-frag.c	1 Jan 1970 00:00:00 -0000
+++ libmudflap/test/fail12-frag.c	14 Aug 2002 17:33:07 -0000
@@ -0,0 +1,8 @@
+int i = 10;
+int *x = (void *)malloc(i * sizeof (int));
+
+while (i--)
+{
+  ++x;
+  *x = 0;
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]