Skip to content
Snippets Groups Projects
Commit fe524faa authored by Hans-Peter Nilsson's avatar Hans-Peter Nilsson
Browse files

* sim/cris/asm/badarch1.ms, sim/cris/c/badldso1.c,

	sim/cris/c/badldso2.c, sim/cris/c/badldso3.c,
	sim/cris/c/helloaout.c, sim/cris/c/hellodyn.c,
	sim/cris/c/hellodyn2.c, sim/cris/c/writev1.c,
	sim/cris/c/writev2.c: New tests.
	* sim/cris/c/c.exp: If compiler links libc.so when attempting to
	link dynamically, create symlink named "lib" to the directory
	where it is found.  Handle new test-case option "dynamic".
parent c06ccdf1
No related branches found
No related tags found
No related merge requests found
2008-12-30 Hans-Peter Nilsson <hp@axis.com>
* sim/cris/asm/badarch1.ms, sim/cris/c/badldso1.c,
sim/cris/c/badldso2.c, sim/cris/c/badldso3.c,
sim/cris/c/helloaout.c, sim/cris/c/hellodyn.c,
sim/cris/c/hellodyn2.c, sim/cris/c/writev1.c,
sim/cris/c/writev2.c: New tests.
* sim/cris/c/c.exp: If compiler links libc.so when attempting to
link dynamically, create symlink named "lib" to the directory
where it is found. Handle new test-case option "dynamic".
* sim/cris/asm/opterr1.ms, sim/cris/asm/opterr2.ms: Adjust for
differences in getopt_long error message quoting.
......
# mach: crisv3 crisv8 crisv10 crisv32
# xerror:
# output: *: not a CRIS program `/bin/sh'\n
# sim: /bin/sh
.include "nopv32t.ms"
/*
#notarget: cris*-*-elf
#dynamic:
#xerror:
#output: *: could not load ELF interpreter `*' for program `*'\n
*/
#include "hello.c"
/*
#notarget: cris*-*-elf
#dynamic:
#xerror:
#cc: additional_flags=-Wl,-dynamic-linker,/dev/null
#output: *: could not load ELF interpreter `*' for program `*'\n
*/
#include "hello.c"
/*
#notarget: cris*-*-elf
#dynamic:
#xerror:
#cc: additional_flags=-Wl,-dynamic-linker,/compilercheck.x
#sim: --sysroot=@exedir@
#output: *: could not load ELF interpreter `*' for program `*'\n
*/
#include "hello.c"
......@@ -30,6 +30,23 @@ if [istarget cris-*-*] {
if { [target_compile $srcdir/$subdir/hello.c compilercheck.x \
"executable" "" ] == "" } {
set has_cc 1
# Now check if we can link a program dynamically, and where
# libc.so is located. If it is, we provide a sym link to the
# directory (which must end in /lib) in [pwd], so /lib/ld.so.1 is
# found (which must reside along libc.so). We don't bother
# replacing the board ldflags like below as we don't care about
# detrimental effects on the executable from the specs and
# -static in the board ldflags, we just add -Bdynamic.
if [regexp "(.*/lib)/libc.so" \
[target_compile $srcdir/$subdir/hello.c compilercheck.x \
"executable" \
"ldflags=-print-file-name=libc.so -Wl,-Bdynamic"] \
xxx libcsodir] {
file delete lib
verbose -log "Creating link to $libcsodir in [pwd]"
file link lib $libcsodir
}
} {
verbose -log "Can't execute C compiler"
set has_cc 0
......@@ -48,6 +65,8 @@ proc anytarget { targets } {
}
foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
set orig_ldflags ""
if ![runtest_file_p $runtests $src] {
continue
}
......@@ -84,6 +103,7 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
set opts(xfail) ""
set opts(target) ""
set opts(notarget) ""
set opts(dynamic) ""
# Clear any machine specific options specified in a previous test case
if [info exists opts(sim,$mach)] {
......@@ -120,6 +140,16 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
}
}
if { $opt_name == "dynamic" \
&& [info exists board_info([target_info name],ldflags)] } {
# Weed out -static from ldflags, but keep the original in
# $orig_ldflags.
set orig_ldflags $board_info([target_info name],ldflags)
set ldflags " $orig_ldflags "
regsub -all " -static " $ldflags " " ldflags
set board_info([target_info name],ldflags) $ldflags
}
foreach m $opt_machs {
set opts($opt_name,$m) $opt_val
}
......@@ -160,6 +190,10 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
continue
}
if { $orig_ldflags != "" } {
set board_info([target_info name],ldflags) $orig_ldflags
}
verbose -log "Simulating $src with $opts(sim,$mach)"
# Time to setup xfailures and kfailures.
......
/* Make sure we don't just assume ELF all over. (We have to jump
through hoops to get runnable a.out out of the ELF setup, and
having problems with a.out and discontinous section arrangements
doesn't help. Adjust as needed to get a.out which says "pass". If
necessary, move to the asm subdir. By design, it doesn't work with
CRIS v32.)
#target: cris-*-elf
#cc: ldflags=-Wl,-mcrisaout\ -sim\ -Ttext=0
*/
#include "hello.c"
/*
#dynamic:
#sim: --sysroot=@exedir@
*/
#include "hello.c"
/*
#dynamic:
#sim: --sysroot=@exedir@ --load-vma
*/
#include "hello.c"
/* Trivial test of writev.
#notarget: cris*-*-elf
#output: abcdefghijklmn\npass\n
*/
#include <sys/uio.h>
#include <stdlib.h>
#include <stdio.h>
#define X(x) {x, sizeof (x) -1}
struct iovec v[] = {
X("a"),
X("bcd"),
X("efghi"),
X("j"),
X("klmn\n"),
};
int main (void)
{
if (writev (1, v, sizeof v / sizeof (v[0])) != 15)
abort ();
printf ("pass\n");
return 0;
}
/* Trivial test of failing writev: invalid file descriptor.
#notarget: cris*-*-elf
*/
#include <sys/uio.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#define X(x) {x, sizeof (x) -1}
struct iovec v[] = {
X("a"),
X("bcd"),
X("efghi"),
X("j"),
X("klmn\n"),
};
int main (void)
{
if (writev (99, v, sizeof v / sizeof (v[0])) != -1
/* The simulator write gives EINVAL instead of EBADF; let's
cope. */
|| (errno != EBADF && errno != EINVAL))
abort ();
printf ("pass\n");
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment