aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2008-12-30 13:57:11 +0000
committerHans-Peter Nilsson <hp@axis.com>2008-12-30 13:57:11 +0000
commitfe524faa87338b3324439dadbaf6afa3734312d5 (patch)
tree1be71131138ede993cd65234bea45d8664cd1dd5 /sim
parentc06ccdf1b680092e01cba0af3681c12bf63d2ed0 (diff)
downloadgdb-fe524faa87338b3324439dadbaf6afa3734312d5.zip
gdb-fe524faa87338b3324439dadbaf6afa3734312d5.tar.gz
gdb-fe524faa87338b3324439dadbaf6afa3734312d5.tar.bz2
* 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".
Diffstat (limited to 'sim')
-rw-r--r--sim/testsuite/ChangeLog9
-rw-r--r--sim/testsuite/sim/cris/asm/badarch1.ms5
-rw-r--r--sim/testsuite/sim/cris/c/badldso1.c7
-rw-r--r--sim/testsuite/sim/cris/c/badldso2.c8
-rw-r--r--sim/testsuite/sim/cris/c/badldso3.c9
-rw-r--r--sim/testsuite/sim/cris/c/c.exp34
-rw-r--r--sim/testsuite/sim/cris/c/helloaout.c10
-rw-r--r--sim/testsuite/sim/cris/c/hellodyn.c5
-rw-r--r--sim/testsuite/sim/cris/c/hellodyn2.c5
-rw-r--r--sim/testsuite/sim/cris/c/writev1.c25
-rw-r--r--sim/testsuite/sim/cris/c/writev2.c28
11 files changed, 145 insertions, 0 deletions
diff --git a/sim/testsuite/ChangeLog b/sim/testsuite/ChangeLog
index 97517e6..df46782 100644
--- a/sim/testsuite/ChangeLog
+++ b/sim/testsuite/ChangeLog
@@ -1,5 +1,14 @@
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.
diff --git a/sim/testsuite/sim/cris/asm/badarch1.ms b/sim/testsuite/sim/cris/asm/badarch1.ms
new file mode 100644
index 0000000..10f2774
--- /dev/null
+++ b/sim/testsuite/sim/cris/asm/badarch1.ms
@@ -0,0 +1,5 @@
+# mach: crisv3 crisv8 crisv10 crisv32
+# xerror:
+# output: *: not a CRIS program `/bin/sh'\n
+# sim: /bin/sh
+ .include "nopv32t.ms"
diff --git a/sim/testsuite/sim/cris/c/badldso1.c b/sim/testsuite/sim/cris/c/badldso1.c
new file mode 100644
index 0000000..58caa8d
--- /dev/null
+++ b/sim/testsuite/sim/cris/c/badldso1.c
@@ -0,0 +1,7 @@
+/*
+#notarget: cris*-*-elf
+#dynamic:
+#xerror:
+#output: *: could not load ELF interpreter `*' for program `*'\n
+ */
+#include "hello.c"
diff --git a/sim/testsuite/sim/cris/c/badldso2.c b/sim/testsuite/sim/cris/c/badldso2.c
new file mode 100644
index 0000000..db28889
--- /dev/null
+++ b/sim/testsuite/sim/cris/c/badldso2.c
@@ -0,0 +1,8 @@
+/*
+#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"
diff --git a/sim/testsuite/sim/cris/c/badldso3.c b/sim/testsuite/sim/cris/c/badldso3.c
new file mode 100644
index 0000000..3f9509b
--- /dev/null
+++ b/sim/testsuite/sim/cris/c/badldso3.c
@@ -0,0 +1,9 @@
+/*
+#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"
diff --git a/sim/testsuite/sim/cris/c/c.exp b/sim/testsuite/sim/cris/c/c.exp
index c97ad84..12a4fa1 100644
--- a/sim/testsuite/sim/cris/c/c.exp
+++ b/sim/testsuite/sim/cris/c/c.exp
@@ -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.
diff --git a/sim/testsuite/sim/cris/c/helloaout.c b/sim/testsuite/sim/cris/c/helloaout.c
new file mode 100644
index 0000000..0f77459
--- /dev/null
+++ b/sim/testsuite/sim/cris/c/helloaout.c
@@ -0,0 +1,10 @@
+/* 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"
diff --git a/sim/testsuite/sim/cris/c/hellodyn.c b/sim/testsuite/sim/cris/c/hellodyn.c
new file mode 100644
index 0000000..dc8042f
--- /dev/null
+++ b/sim/testsuite/sim/cris/c/hellodyn.c
@@ -0,0 +1,5 @@
+/*
+#dynamic:
+#sim: --sysroot=@exedir@
+ */
+#include "hello.c"
diff --git a/sim/testsuite/sim/cris/c/hellodyn2.c b/sim/testsuite/sim/cris/c/hellodyn2.c
new file mode 100644
index 0000000..00f5369
--- /dev/null
+++ b/sim/testsuite/sim/cris/c/hellodyn2.c
@@ -0,0 +1,5 @@
+/*
+#dynamic:
+#sim: --sysroot=@exedir@ --load-vma
+ */
+#include "hello.c"
diff --git a/sim/testsuite/sim/cris/c/writev1.c b/sim/testsuite/sim/cris/c/writev1.c
new file mode 100644
index 0000000..fad5b7f
--- /dev/null
+++ b/sim/testsuite/sim/cris/c/writev1.c
@@ -0,0 +1,25 @@
+/* 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;
+}
diff --git a/sim/testsuite/sim/cris/c/writev2.c b/sim/testsuite/sim/cris/c/writev2.c
new file mode 100644
index 0000000..5cb92b6
--- /dev/null
+++ b/sim/testsuite/sim/cris/c/writev2.c
@@ -0,0 +1,28 @@
+/* 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;
+}