* sim/cris/asm/badarch1.ms, sim/cris/c/badldso1.c,
authorHans-Peter Nilsson <hp@axis.com>
Tue, 30 Dec 2008 13:57:11 +0000 (13:57 +0000)
committerHans-Peter Nilsson <hp@axis.com>
Tue, 30 Dec 2008 13:57:11 +0000 (13:57 +0000)
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/testsuite/ChangeLog
sim/testsuite/sim/cris/asm/badarch1.ms [new file with mode: 0644]
sim/testsuite/sim/cris/c/badldso1.c [new file with mode: 0644]
sim/testsuite/sim/cris/c/badldso2.c [new file with mode: 0644]
sim/testsuite/sim/cris/c/badldso3.c [new file with mode: 0644]
sim/testsuite/sim/cris/c/c.exp
sim/testsuite/sim/cris/c/helloaout.c [new file with mode: 0644]
sim/testsuite/sim/cris/c/hellodyn.c [new file with mode: 0644]
sim/testsuite/sim/cris/c/hellodyn2.c [new file with mode: 0644]
sim/testsuite/sim/cris/c/writev1.c [new file with mode: 0644]
sim/testsuite/sim/cris/c/writev2.c [new file with mode: 0644]

index 97517e6..df46782 100644 (file)
@@ -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 (file)
index 0000000..10f2774
--- /dev/null
@@ -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 (file)
index 0000000..58caa8d
--- /dev/null
@@ -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 (file)
index 0000000..db28889
--- /dev/null
@@ -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 (file)
index 0000000..3f9509b
--- /dev/null
@@ -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"
index c97ad84..12a4fa1 100644 (file)
@@ -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 (file)
index 0000000..0f77459
--- /dev/null
@@ -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 (file)
index 0000000..dc8042f
--- /dev/null
@@ -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 (file)
index 0000000..00f5369
--- /dev/null
@@ -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 (file)
index 0000000..fad5b7f
--- /dev/null
@@ -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 (file)
index 0000000..5cb92b6
--- /dev/null
@@ -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; 
+}