Commit 978fd0cb by Nick Clifton Committed by Nick Clifton

Fix blkarg.c test to fail even on alpha.

Make blkarg.c an expected failure.
Fix driver.c to use exit()/abort().

From-SVN: r25002
parent 545954c9
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> 1999-01-28 Michael Meissner <meissner@cygnus.com>
* execute/990128-1.c: New test. * execute/990128-1.c: New test.
......
...@@ -23,24 +23,32 @@ ...@@ -23,24 +23,32 @@
int expect_error = 0; int expect_error = 0;
/* Must be BLKmode. Using only two fields gets TImode on Alpha. */ /* Must be BLKmode. Using only two fields gets TImode on Alpha. */
struct S { struct S
{
unsigned long long ll; unsigned long long ll;
long xx, yy; long xx;
long yy;
}; };
unsigned long long x = 0x12345689ULL; unsigned long long x = 0x12345689ULL;
#define I2 42 #define I2 42
/* Leading six arguments force X into stack on both Alpha and MIPS. */
static int first_time = 1; 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 (); abort ();
if (first_time) if (first_time)
{ {
if (s.ll != x || s.xx != I2 || s.yy != 0) if (s.ll != x || s.xx != I2 || s.yy != 0)
abort (); abort ();
first_time = 0; first_time = 0;
} }
else else
...@@ -48,16 +56,19 @@ int foo (int a1, int a2, int a3, int a4, int a5, int a6, struct S s) { ...@@ -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) if (s.ll != 0 || s.xx != 0 || s.yy != 0)
abort (); abort ();
} }
return 0; return 0;
} }
void test () void
test ()
{ {
foo (1, 2, 3, 4, 5, 6, (struct S) { x, I2 }); foo (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, (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) { 0 });
} }
void setup () /* NOCHECK */ void
setup () /* NOCHECK */
{ {
mark_region (&x, sizeof (x), ACCESS_RO); mark_region (&x, sizeof (x), ACCESS_RO);
mark_region (&first_time, sizeof (first_time), ACCESS_RW); mark_region (&first_time, sizeof (first_time), ACCESS_RW);
......
# 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
...@@ -9,7 +9,8 @@ int verbose = 0; ...@@ -9,7 +9,8 @@ int verbose = 0;
int debug = 0; int debug = 0;
int bad_accesses = 0; int bad_accesses = 0;
const char *const memory_use_strings[] = { const char *const memory_use_strings[] =
{
#define INIT(x) [x] = #x #define INIT(x) [x] = #x
INIT (MEMORY_USE_BAD), INIT (MEMORY_USE_BAD),
INIT (MEMORY_USE_DONT), INIT (MEMORY_USE_DONT),
...@@ -23,10 +24,12 @@ const char *const memory_use_strings[] = { ...@@ -23,10 +24,12 @@ const char *const memory_use_strings[] = {
/* This won't be used for any really huge test cases, so a simple /* 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 linked list is adequate. We won't even worry about overlapping
regions; the matching entry that comes up first wins. */ 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", "none", "ro", "wo", "rw",
}; };
struct access_node { struct access_node
{
struct access_node *next; struct access_node *next;
const void *addr; const void *addr;
size_t sz; size_t sz;
...@@ -35,7 +38,8 @@ struct access_node { ...@@ -35,7 +38,8 @@ struct access_node {
static struct access_node *access_list; 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; struct access_node *a;
if (debug) if (debug)
...@@ -50,7 +54,8 @@ void mark_region (const void *addr, size_t sz, enum access_mode mode) ...@@ -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 *, 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) if (++bad_accesses > 100)
bad_accesses = 100; bad_accesses = 100;
...@@ -72,8 +77,9 @@ void report_bad_access (void *addr, size_t sz, enum memory_use_mode mode) ...@@ -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 *, size_t, enum access_mode, struct access_node *) NOCHECK;
int verify1 (void *addr, size_t sz, enum access_mode mode, int
struct access_node *a) 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)) while (a && (addr + sz <= a->addr || addr >= a->addr + a->sz))
a = a->next; a = a->next;
...@@ -99,8 +105,8 @@ int verify1 (void *addr, size_t sz, enum access_mode mode, ...@@ -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 *, size_t, enum access_mode) NOCHECK;
int
int verify_range_permission (void *addr, size_t sz, enum access_mode mode) verify_range_permission (void *addr, size_t sz, enum access_mode mode)
{ {
if (debug) if (debug)
printf ("verify_range_permission (%p, %ld, %s)\n", addr, (long) sz, 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) ...@@ -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 *, size_t, int) NOCHECK;
void
void chkr_check_addr (void *addr, size_t sz, int mode) chkr_check_addr (void *addr, size_t sz, int mode)
{ {
switch (mode) switch (mode)
{ {
...@@ -146,7 +152,8 @@ void chkr_check_addr (void *addr, size_t sz, int 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 *, 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)) while (a && (src + sz <= a->addr || src >= a->addr + a->sz))
a = a->next; a = a->next;
...@@ -178,7 +185,8 @@ void copy1 (void *dest, void *src, size_t sz, struct access_node *a) ...@@ -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 *, 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) if (verify_range_permission (dest, sz, MEMORY_USE_WO) == 0)
report_bad_access (dest, sz, MEMORY_USE_WO); report_bad_access (dest, sz, MEMORY_USE_WO);
...@@ -186,22 +194,30 @@ void chkr_copy_bitmap (void *dest, void *src, size_t sz) ...@@ -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 *, 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); mark_region (addr, sz, mode);
} }
int main () NOCHECK; int main () NOCHECK;
int main () int
main ()
{ {
setup (); setup ();
test (); test ();
bad_accesses = !!bad_accesses; /* get 0 or 1 */ 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; struct malloc_node *next;
void *addr; void *addr;
size_t sz; size_t sz;
...@@ -209,7 +225,8 @@ struct malloc_node { ...@@ -209,7 +225,8 @@ struct malloc_node {
}; };
static struct malloc_node *malloc_list; static struct malloc_node *malloc_list;
void *c_malloc (size_t sz) void *
c_malloc (size_t sz)
{ {
void *p; void *p;
struct malloc_node *m; struct malloc_node *m;
...@@ -238,7 +255,8 @@ void *c_malloc (size_t sz) ...@@ -238,7 +255,8 @@ void *c_malloc (size_t sz)
return p; return p;
} }
void c_free (void *p) void
c_free (void *p)
{ {
struct malloc_node *m; struct malloc_node *m;
if (p == 0) if (p == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment