Fix blkarg.c test to fail even on alpha.
authorNick Clifton <nickc@cygnus.com>
Wed, 3 Feb 1999 10:30:26 +0000 (10:30 +0000)
committerNick Clifton <nickc@gcc.gnu.org>
Wed, 3 Feb 1999 10:30:26 +0000 (10:30 +0000)
Make blkarg.c an expected failure.
Fix driver.c to use exit()/abort().

From-SVN: r25002

gcc/testsuite/gcc.c-torture/ChangeLog
gcc/testsuite/gcc.c-torture/execute/memcheck/blkarg.c
gcc/testsuite/gcc.c-torture/execute/memcheck/blkarg.x [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/memcheck/driver.c

index 3f160c5c416aca50d4d4f2689003288b551d66d8..736b565c1e1e0ac44c723b07183c8ae491e054af 100644 (file)
@@ -1,3 +1,16 @@
+1999-02-03  Nick Clifton  <nickc@cygnus.com>
+
+       * execute/memcheck/blkarg.c (foo): Use 10 leading arguments in
+       order to force structure S onto the stack even on the alpha.
+       (test): Pass 10 leading arguments to function foo as well as the
+       structure S.
+
+       * execute/memcheck/blkarg.x: New file: Expected failure for all
+       targets. 
+
+       * execute/memcheck/driver.c (main): Use exit or abort to terminate
+       program execution.
+
 1999-01-28  Michael Meissner  <meissner@cygnus.com>
 
        * execute/990128-1.c: New test.
index 43c5b39498ac885d130002383e9ad38ebd9176cf..4f448d661d6709feecca9927a6fc4ae82fb476b3 100644 (file)
 int expect_error = 0;
 
 /* Must be BLKmode.  Using only two fields gets TImode on Alpha.  */
-struct S {
+struct S
+{
   unsigned long long ll;
-  long xx, yy;
+  long               xx;
+  long               yy;
 };
 
-unsigned long long x = 0x12345689ULL;
-#define I2     42
-
-/* Leading six arguments force X into stack on both Alpha and MIPS.  */
+unsigned long long   x = 0x12345689ULL;
+#define I2          42
 
 static int first_time = 1;
-int foo (int a1, int a2, int a3, int a4, int a5, int a6, struct S s) {
-  if (a1 != 1 || a2 != 2 || a3 != 3 || a4 != 4 || a5 != 5 || a6 != 6)
+
+/* Leading ten arguments force struct S onto the stack on both Alpha and MIPS.  */
+int
+foo (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10,
+     struct S s)
+{
+  if (a1 != 1 || a2 != 2 || a3 != 3 || a4 != 4 || a5 != 5 || a6 != 6 || a7 != 7
+      || a8 != 8 || a9 !=9 || a10 != 10)
     abort ();
+  
   if (first_time)
     {
       if (s.ll != x || s.xx != I2 || s.yy != 0)
        abort ();
+      
       first_time = 0;
     }
   else
@@ -48,16 +56,19 @@ int foo (int a1, int a2, int a3, int a4, int a5, int a6, struct S s) {
       if (s.ll != 0 || s.xx != 0 || s.yy != 0)
        abort ();
     }
+  
   return 0;
 }
 
-void test ()
+void
+test ()
 {
-  foo (1, 2, 3, 4, 5, 6, (struct S) { x, I2 });
-  foo (1, 2, 3, 4, 5, 6, (struct S) { 0 });
+  foo (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, (struct S) { x, I2 });
+  foo (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, (struct S) { 0 });
 }
 
-void setup () /* NOCHECK */
+void
+setup () /* NOCHECK */
 {
   mark_region (&x, sizeof (x), ACCESS_RO);
   mark_region (&first_time, sizeof (first_time), ACCESS_RW);
diff --git a/gcc/testsuite/gcc.c-torture/execute/memcheck/blkarg.x b/gcc/testsuite/gcc.c-torture/execute/memcheck/blkarg.x
new file mode 100644 (file)
index 0000000..52b53fe
--- /dev/null
@@ -0,0 +1,9 @@
+# The memeory checking code does not mark the stack as readable or writable
+# so this test fails.  Ideally the memory checking library ought to 
+# cooperate with the host OS to mark the stack as it is used or individual
+# function prologues and epilogues ought to mark their pieces of stack as 
+# writable and readable-after-written.
+
+set torture_execute_xfail "*-*-*"
+
+return 0
index 9002a0b8d2410517f6481cf1d677728a9a0af4c9..1da22e7a22228e72e34e9c779a2db557e99f9bca 100644 (file)
@@ -9,7 +9,8 @@ int verbose = 0;
 int debug = 0;
 int bad_accesses = 0;
 
-const char *const memory_use_strings[] = {
+const char *const memory_use_strings[] =
+{
 #define INIT(x)                [x] = #x
   INIT (MEMORY_USE_BAD),
   INIT (MEMORY_USE_DONT),
@@ -23,10 +24,12 @@ const char *const memory_use_strings[] = {
 /* This won't be used for any really huge test cases, so a simple
    linked list is adequate.  We won't even worry about overlapping
    regions; the matching entry that comes up first wins.  */
-const char *const access_mode_strings[] = {
+const char *const access_mode_strings[] =
+{
   "none", "ro", "wo", "rw",
 };
-struct access_node {
+struct access_node
+{
   struct access_node *next;
   const void *addr;
   size_t sz;
@@ -35,7 +38,8 @@ struct access_node {
 
 static struct access_node *access_list;
 
-void mark_region (const void *addr, size_t sz, enum access_mode mode)
+void
+mark_region (const void *addr, size_t sz, enum access_mode mode)
 {
   struct access_node *a;
   if (debug)
@@ -50,7 +54,8 @@ void mark_region (const void *addr, size_t sz, enum access_mode mode)
 }
 
 void report_bad_access (void *, size_t, enum memory_use_mode) NOCHECK;
-void report_bad_access (void *addr, size_t sz, enum memory_use_mode mode)
+void
+report_bad_access (void *addr, size_t sz, enum memory_use_mode mode)
 {
   if (++bad_accesses > 100)
     bad_accesses = 100;
@@ -72,8 +77,9 @@ void report_bad_access (void *addr, size_t sz, enum memory_use_mode mode)
 }
 
 int verify1 (void *, size_t, enum access_mode, struct access_node *) NOCHECK;
-int verify1 (void *addr, size_t sz, enum access_mode mode,
-            struct access_node *a)
+int
+verify1 (void *addr, size_t sz, enum access_mode mode,
+        struct access_node *a)
 {
   while (a && (addr + sz <= a->addr || addr >= a->addr + a->sz))
     a = a->next;
@@ -99,8 +105,8 @@ int verify1 (void *addr, size_t sz, enum access_mode mode,
 }
 
 int verify_range_permission (void *, size_t, enum access_mode) NOCHECK;
-
-int verify_range_permission (void *addr, size_t sz, enum access_mode mode)
+int
+verify_range_permission (void *addr, size_t sz, enum access_mode mode)
 {
   if (debug)
     printf ("verify_range_permission (%p, %ld, %s)\n", addr, (long) sz,
@@ -109,8 +115,8 @@ int verify_range_permission (void *addr, size_t sz, enum access_mode mode)
 }
 
 void chkr_check_addr (void *, size_t, int) NOCHECK;
-
-void chkr_check_addr (void *addr, size_t sz, int mode)
+void
+chkr_check_addr (void *addr, size_t sz, int mode)
 {
   switch (mode)
     {
@@ -146,7 +152,8 @@ void chkr_check_addr (void *addr, size_t sz, int mode)
 }
 
 void copy1 (void *, void *, size_t, struct access_node *) NOCHECK;
-void copy1 (void *dest, void *src, size_t sz, struct access_node *a)
+void
+copy1 (void *dest, void *src, size_t sz, struct access_node *a)
 {
   while (a && (src + sz <= a->addr || src >= a->addr + a->sz))
     a = a->next;
@@ -178,7 +185,8 @@ void copy1 (void *dest, void *src, size_t sz, struct access_node *a)
 }
 
 void chkr_copy_bitmap (void *, void *, size_t) NOCHECK;
-void chkr_copy_bitmap (void *dest, void *src, size_t sz)
+void
+chkr_copy_bitmap (void *dest, void *src, size_t sz)
 {
   if (verify_range_permission (dest, sz, MEMORY_USE_WO) == 0)
     report_bad_access (dest, sz, MEMORY_USE_WO);
@@ -186,22 +194,30 @@ void chkr_copy_bitmap (void *dest, void *src, size_t sz)
 }
 
 void chkr_set_right (void *, size_t, enum access_mode) NOCHECK;
-void chkr_set_right (void *addr, size_t sz, enum access_mode mode)
+void
+chkr_set_right (void *addr, size_t sz, enum access_mode mode)
 {
   mark_region (addr, sz, mode);
 }
 
 int main () NOCHECK;
-int main ()
+int
+main ()
 {
   setup ();
   test ();
   bad_accesses = !!bad_accesses; /* get 0 or 1 */
-  /* Return 0 if got expected results, 1 otherwise.  */
-  return !(bad_accesses == expect_error);
+  
+  if (bad_accesses == expect_error)
+    exit (0);
+  else
+    abort ();
+  
+  return 0;
 }
 
-struct malloc_node {
+struct malloc_node
+{
   struct malloc_node *next;
   void *addr;
   size_t sz;
@@ -209,7 +225,8 @@ struct malloc_node {
 };
 static struct malloc_node *malloc_list;
 
-void *c_malloc (size_t sz)
+void *
+c_malloc (size_t sz)
 {
   void *p;
   struct malloc_node *m;
@@ -238,7 +255,8 @@ void *c_malloc (size_t sz)
   return p;
 }
 
-void c_free (void *p)
+void
+c_free (void *p)
 {
   struct malloc_node *m;
   if (p == 0)