Commit 5aa33bdb by Jakub Jelinek Committed by Jakub Jelinek

Makefile.in (site.exp): Add HOSTCC and HOSTCFLAGS to site.exp.

	* Makefile.in (site.exp): Add HOSTCC and HOSTCFLAGS to site.exp.
testsuite/
	* README.compat: Add RUN_ALL_COMPAT_TESTS documentation.
	* lib/compat.exp: Replace ^$tmpdir/? in testcase names with tmpdir-.
	* gcc.dg/compat/struct-layout-1.exp: New testsuite driver.
	* gcc.dg/compat/struct-layout-1_generate.c: New testcase generator.
	* gcc.dg/compat/generate-random.c: New file.
	* gcc.dg/compat/generate-random.h: Likewise.
	* gcc.dg/compat/generate-random_r.c: Likewise.
	* gcc.dg/compat/struct-layout-1.h: Likewise.
	* gcc.dg/compat/struct-layout-1_x1.h: Likewise.
	* gcc.dg/compat/struct-layout-1_x2.h: Likewise.
	* gcc.dg/compat/struct-layout-1_y1.h: Likewise.
	* gcc.dg/compat/struct-layout-1_y2.h: Likewise.
	* gcc.dg/compat/struct-layout-1_main.c: New test.
	* gcc.dg/compat/struct-layout-1_x.c: New file.
	* gcc.dg/compat/struct-layout-1_y.c: New file.
	* gcc.dg/compat/struct-layout-1_test.h: New file.

From-SVN: r85098
parent ec5c28ec
2004-07-24 Jakub Jelinek <jakub@redhat.com>
* Makefile.in (site.exp): Add HOSTCC and HOSTCFLAGS to site.exp.
2004-07-23 Zack Weinberg <zack@codesourcery.com>
* print-rtl.c (print_rtx <case 'b'>): Don't attempt to print
......
......@@ -3417,6 +3417,8 @@ site.exp: ./config.status Makefile
# CFLAGS is set even though it's empty to show we reserve the right to set it.
@echo "set CFLAGS \"\"" >> ./tmp0
@echo "set CXXFLAGS \"\"" >> ./tmp0
@echo "set HOSTCC \"$(CC)\"" >> ./tmp0
@echo "set HOSTCFLAGS \"$(CFLAGS)\"" >> ./tmp0
@echo "set TESTING_IN_BUILD_TREE 1" >> ./tmp0
@echo "set HAVE_LIBSTDCXX_V3 1" >> ./tmp0
# If newlib has been configured, we need to pass -B to gcc so it can find
......
2004-07-24 Jakub Jelinek <jakub@redhat.com>
* README.compat: Add RUN_ALL_COMPAT_TESTS documentation.
* lib/compat.exp: Replace ^$tmpdir/? in testcase names with tmpdir-.
* gcc.dg/compat/struct-layout-1.exp: New testsuite driver.
* gcc.dg/compat/struct-layout-1_generate.c: New testcase generator.
* gcc.dg/compat/generate-random.c: New file.
* gcc.dg/compat/generate-random.h: Likewise.
* gcc.dg/compat/generate-random_r.c: Likewise.
* gcc.dg/compat/struct-layout-1.h: Likewise.
* gcc.dg/compat/struct-layout-1_x1.h: Likewise.
* gcc.dg/compat/struct-layout-1_x2.h: Likewise.
* gcc.dg/compat/struct-layout-1_y1.h: Likewise.
* gcc.dg/compat/struct-layout-1_y2.h: Likewise.
* gcc.dg/compat/struct-layout-1_main.c: New test.
* gcc.dg/compat/struct-layout-1_x.c: New file.
* gcc.dg/compat/struct-layout-1_y.c: New file.
* gcc.dg/compat/struct-layout-1_test.h: New file.
2004-07-23 Joseph S. Myers <jsm@polyomino.org.uk>
* gcc.dg/comp-return-1.c: New test
......
......@@ -29,6 +29,11 @@ sets of compiler options.
varible ALT_LD_LIBRARY_PATH. If it needs different options to build
a shared object, define those in ALT_SHOBJ_OPTIONS.
Normally, only a small amount of compatibility tests is run.
Setting RUN_ALL_COMPAT_TESTS=1 in the environment before running the
testsuite enables running all compatibility tests, but might take
significantly longer than it takes without this variable.
To run only the C++ compatibility tests, optionally specifying an
alternate compiler and/or sets of options, do from $objdir/gcc:
......
/* Copyright (C) 2004 Free Software Foundation
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU 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 for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
struct generate_random_data
{
int *fptr, *rptr, *state;
int rand_type, rand_deg, rand_sep;
int *end_ptr;
};
extern void generate_srandom (unsigned int);
extern char *generate_initstate (unsigned int, char *, size_t);
extern char *generate_setstate (char *);
extern long int generate_random (void);
extern int generate_random_r (struct generate_random_data *, int *);
extern int generate_srandom_r (unsigned int, struct generate_random_data *);
extern int generate_initstate_r (unsigned int, char *, size_t,
struct generate_random_data *);
extern int generate_setstate_r (char *, struct generate_random_data *);
# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
# 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.
#
# This file was written by Jakub Jelinek, <jakub@redhat.com>
# Based on compat.exp writte by Janis Johnson, <janis187@us.ibm.com>
# Test interoperability of two compilers that follow the same ABI.
#
# Break simple tests into two pieces and see that they work when linked
# together. If an alternate compiler is specified then the two main
# pieces of each test are compiled with different compilers. The
# alternate compiler must be installed, and is specified by defining
# ALT_CC_UNDER_TEST in the environment.
#
# struct-layout-1 are generated structure layout interoperability tests,
# so a generator first needs to be compiled on host, run there and the
# generated tests then compiled on build and executed on target.
if $tracelevel then {
strace $tracelevel
}
global GCC_UNDER_TEST
# Load procedures from common libraries.
load_lib standard.exp
load_lib gcc.exp
#
# compat-use-alt-compiler -- make the alternate compiler the default
#
proc compat-use-alt-compiler { } {
global GCC_UNDER_TEST ALT_CC_UNDER_TEST
global same_alt
# We don't need to do this if the alternate compiler is actually
# the same as the compiler under test.
if { $same_alt == 0 } then {
set GCC_UNDER_TEST $ALT_CC_UNDER_TEST
}
}
#
# compat-use-tst-compiler -- make compiler under test the default
#
proc compat-use-tst-compiler { } {
global GCC_UNDER_TEST save_gcc_under_test
global same_alt
# We don't need to do this if the alternate compiler is actually
# the same as the compiler under test.
if { $same_alt == 0 } then {
set GCC_UNDER_TEST $save_gcc_under_test
}
}
# Load the language-independent compabibility support procedures.
# This must be done after the compat-use-*-compiler definitions.
load_lib compat.exp
gcc_init
# Save variables for the C compiler under test, which each test will
# change a couple of times. This must be done after calling gcc-init.
set save_gcc_under_test $GCC_UNDER_TEST
# Define an identifier for use with this suite to avoid name conflicts
# with other compat tests running at the same time.
set sid "c_compat"
# Find out whether there is an alternate compiler to test. If the
# variable is defined but is set to "same", that means we use the same
# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS
# are different.
set use_alt 0
set same_alt 0
if [info exists ALT_CC_UNDER_TEST] then {
set use_alt 1
if [string match "same" $ALT_CC_UNDER_TEST] then {
set same_alt 1
}
}
set tstobjdir "$tmpdir/gcc.dg-struct-layout-1"
set generator "$tmpdir/gcc.dg-struct-layout-1_generate"
set generator_src "$srcdir/$subdir/struct-layout-1_generate.c"
set generator_src "$generator_src $srcdir/$subdir/generate-random.c"
set generator_src "$generator_src $srcdir/$subdir/generate-random_r.c"
set generator_inc "-I$srcdir/$subdir -I$srcdir/../../include"
set generator_inc "$generator_inc -I$rootme/../libiberty"
set generator_lib "-L$rootme/../libiberty -liberty"
set generator_cmd "-o $generator $generator_src $generator_inc $generator_lib"
set status [remote_exec host "$HOSTCC $HOSTCFLAGS $generator_cmd"]
set status [lindex $status 0]
if { $status == 0 } then {
file delete -force $tstobjdir
file mkdir $tstobjdir
set generator_args "-s $srcdir/$subdir -d $tstobjdir"
if [info exists env(RUN_ALL_COMPAT_TESTS) ] then {
set generator_args "$generator_args -n 15000"
}
set status [remote_exec host "$generator $generator_args"]
set status [lindex $status 0]
if { $status == 0 } then {
foreach src [lsort [find $tstobjdir *_main.c]] {
# If we're only testing specific files and this isn't one
# of them, skip it.
if ![runtest_file_p $runtests $src] then {
continue
}
compat-execute $src $sid $use_alt
}
} else {
warning "Could not execute gcc.dg/compat/struct-layout-1 generator"
}
} else {
warning "Could not compiler gcc.dg/compat/struct-layout-1 generator"
}
# Restore the original compiler under test.
compat-use-tst-compiler
#include "struct-layout-1.h"
#define TX(n, type, attrs, fields, ops) extern void test##n (void);
#include "struct-layout-1_test.h"
#undef TX
int main (void)
{
#define TX(n, type, attrs, fields, ops) test##n ();
#include "struct-layout-1_test.h"
#undef TX
if (fails)
abort ();
exit (0);
}
T(0,enum E2 a:31;,B(0,a,e2_m1,e2_0))
/* { dg-options "-w" } */
#include "struct-layout-1_x1.h"
#include "struct-layout-1_test.h"
#include "struct-layout-1_x2.h"
#include "struct-layout-1_test.h"
#include "struct-layout-1.h"
struct Info info;
int fails;
int intarray[256];
int fn0 (void) { return 0; }
int fn1 (void) { return 1; }
int fn2 (void) { return 2; }
int fn3 (void) { return 3; }
int fn4 (void) { return 4; }
int fn5 (void) { return 5; }
int fn6 (void) { return 6; }
int fn7 (void) { return 7; }
int fn8 (void) { return 8; }
int fn9 (void) { return 9; }
/* This macro is intended for fields where their
addresses/sizes/alignments and value passing should be checked. */
#define F(n, x, v, w) \
info.flds[i] = &s##n.x; \
info.sizes[i] = sizeof (s##n.x); \
info.aligns[i] = __alignof__ (s##n.x); \
s##n.x = v; \
a##n[2].x = w; \
++i;
/* This macro is for fields where just their addresses/sizes/alignments
should be checked. */
#define N(n, x) \
info.flds[i] = &s##n.x; \
info.sizes[i] = sizeof (s##n.x); \
info.aligns[i] = __alignof__ (s##n.x); \
++i;
/* This macro is for fields where just value passing should be checked. */
#define B(n, x, v, w) \
s##n.x = v; \
a##n[2].x = w; \
++j;
#define TX(n, type, attrs, fields, ops) \
type S##n { fields } attrs; \
type S##n s##n; \
extern type S##n a##n[5]; \
extern type S##n check##n (type S##n, type S##n *, \
type S##n); \
extern void check##n##va (int i, ...); \
extern void checkx##n (type S##n); \
void test##n (void) \
{ \
int i, j; \
memset (&s##n, '\0', sizeof (s##n)); \
memset (a##n, '\0', sizeof (a##n)); \
memset (&info, '\0', sizeof (info)); \
info.sp = &s##n; \
info.a0p = &a##n[0]; \
info.a3p = &a##n[3]; \
info.sz = sizeof (s##n); \
info.als = __alignof__ (s##n); \
info.ala0 = __alignof__ (a##n[0]); \
info.ala3 = __alignof__ (a##n[3]); \
if (((uintptr_t) &a##n[3]) & (info.als - 1)) \
FAIL (n, 1); \
i = 0; j = 0; \
ops \
info.nfields = i; \
info.nbitfields = j; \
checkx##n (check##n (s##n, &a##n[1], a##n[2])); \
check##n##va (1, 1.0, s##n, 2LL, a##n[2], a##n[2]); \
check##n##va (2, s##n, s##n, 2.0L, a##n[2], s##n); \
}
#undef F
#undef N
#undef B
#undef TX
#define F(n, x, v, w) \
if (arg.x != s##n.x) FAIL (n, 30);
#define N(n, x)
#define B(n, x, v, w) \
if (arg.x != s##n.x) FAIL (n, 30);
#define TX(n, type, attrs, fields, ops) \
void checkx##n (type S##n arg) \
{ \
ops \
}
/* { dg-options "-w" } */
#include "struct-layout-1_y1.h"
#include "struct-layout-1_test.h"
#include "struct-layout-1_y2.h"
#include "struct-layout-1_test.h"
#include "struct-layout-1.h"
#define F(n, x, v, w) \
if (info.flds[i] != &s##n.x) \
FAIL (n, 50); \
if (info.sizes[i] != sizeof (s##n.x)) \
FAIL (n, 51); \
if (info.aligns[i] != __alignof__ (s##n.x)) \
FAIL (n, 52); \
if (s##n.x != (__typeof__ (s##n.x)) v) \
FAIL (n, 53); \
if (a##n[2].x != (__typeof__ (s##n.x)) w) \
FAIL (n, 54); \
if (arg0.x != s##n.x) \
FAIL (n, 55); \
if (arg2.x != a##n[2].x) \
FAIL (n, 56); \
ret.x = s##n.x; \
++i;
#define N(n, x) \
if (info.flds[i] != &s##n.x) \
FAIL (n, 50); \
if (info.sizes[i] != sizeof (s##n.x)) \
FAIL (n, 51); \
if (info.aligns[i] != __alignof__ (s##n.x)) \
FAIL (n, 52); \
++i;
#define B(n, x, v, w) \
b1.x = v; b2.x = w; \
if (s##n.x != b1.x) \
FAIL (n, 53); \
if (a##n[2].x != b2.x) \
FAIL (n, 54); \
if (arg0.x != s##n.x) \
FAIL (n, 55); \
if (arg2.x != a##n[2].x) \
FAIL (n, 56); \
ret.x = s##n.x; \
++j;
#define TX(n, type, attrs, fields, ops) \
type S##n { fields } attrs; \
extern type S##n s##n; \
type S##n a##n[5]; \
type S##n \
check##n (type S##n arg0, type S##n *arg1, type S##n arg2) \
{ \
type S##n ret; \
type S##n b1, b2; \
int i, j; \
\
memset (&ret, 0, sizeof (ret)); \
memset (&b1, 0, sizeof (b1)); \
memset (&b2, 0, sizeof (b2)); \
if (info.sp != &s##n) \
FAIL (n, 10); \
if (info.a0p != &a##n[0]) \
FAIL (n, 11); \
if (info.a3p != &a##n[3]) \
FAIL (n, 12); \
if (info.sz != sizeof (s##n)) \
FAIL (n, 13); \
if (info.als != __alignof__ (s##n)) \
FAIL (n, 14); \
if (info.ala0 != __alignof__ (a##n[0])) \
FAIL (n, 15); \
if (info.ala3 != __alignof__ (a##n[3])) \
FAIL (n, 16); \
if (arg1 != &a##n[1]) \
FAIL (n, 17); \
i = 0; j = 0; \
ops \
if (i != info.nfields || j != info.nbitfields) \
FAIL (n, 18); \
\
return ret; \
}
#undef F
#undef N
#undef B
#undef TX
#ifdef SKIP_VA
const int test_va = 0;
#else
const int test_va = 1;
#endif
#define F(n, x, v, w) \
if (p->x != arg.x) FAIL (n, 74);
#define N(n, x)
#define B(n, x, v, w) \
if (p->x != arg.x) FAIL (n, 74);
#define TX(n, type, attrs, fields, ops) \
void \
check##n##va (int z, ...) \
{ \
type S##n arg, *p; \
va_list ap; \
int i; \
\
if (test_va) \
{ \
va_start (ap, z); \
for (i = 0; i < 5; ++i) \
{ \
p = NULL; \
switch ((z << 4) | i) \
{ \
case 0x10: \
if (va_arg (ap, double) != 1.0) \
FAIL (n, 70); \
break; \
case 0x12: \
if (va_arg (ap, long long) != 2LL) \
FAIL (n, 71); \
break; \
case 0x22: \
if (va_arg (ap, long double) != 2.0L) \
FAIL (n, 72); \
break; \
case 0x11: \
case 0x20: \
case 0x21: \
case 0x24: \
p = &s##n; \
arg = va_arg (ap, type S##n); \
break; \
case 0x13: \
case 0x14: \
case 0x23: \
p = &a##n[2]; \
arg = va_arg (ap, type S##n); \
break; \
default: \
FAIL (n, 73); \
break; \
} \
if (p) \
{ \
ops \
} \
} \
va_end (ap); \
} \
}
......@@ -277,6 +277,7 @@ proc compat-execute { src1 sid use_alt } {
# Get the base name of this test, for use in messages.
regsub "^$srcdir/?" $src1 "" testcase
regsub "^$tmpdir/?" $testcase "tmpdir-" testcase
regsub "_main.*" $testcase "" testcase
# Set up the base name of executable files so they'll be unique.
regsub -all "\[./\]" $testcase "-" execbase
......
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