aboutsummaryrefslogtreecommitdiff
path: root/sim/testsuite
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-10-11 18:44:07 +0000
committerDaniel Jacobowitz <drow@false.org>2007-10-11 18:44:07 +0000
commiteb639c500494ee8c4ca8978c50451dca10112744 (patch)
treeaea47081d1300f0357ab386bc139b3c53f2e31c5 /sim/testsuite
parentb981d7096356e3e92b66f0813881754fc69bf41d (diff)
downloadbinutils-eb639c500494ee8c4ca8978c50451dca10112744.zip
binutils-eb639c500494ee8c4ca8978c50451dca10112744.tar.gz
binutils-eb639c500494ee8c4ca8978c50451dca10112744.tar.bz2
2007-10-11 Jesper Nilsson <jesper.nilsson@axis.com>
* callback.c (cb_is_stdin, cb_is_stdout, cb_is_stderr): Add functions. * syscall.c (cb_syscall): Test for stdin/out/err, not just fd 0/1/2. 2007-10-11 Jesper Nilsson <jesper.nilsson@axis.com> * callback.h (cb_is_stdin, cb_is_stdout, cb_is_stderr): Add prototypes. 2007-10-11 Jesper Nilsson <jesper.nilsson@axis.com> * sim/cris/c/freopen2.c: Added testcase.
Diffstat (limited to 'sim/testsuite')
-rw-r--r--sim/testsuite/ChangeLog4
-rw-r--r--sim/testsuite/sim/cris/c/freopen1.c5
-rw-r--r--sim/testsuite/sim/cris/c/freopen2.c40
3 files changed, 45 insertions, 4 deletions
diff --git a/sim/testsuite/ChangeLog b/sim/testsuite/ChangeLog
index c7c0acc..168b05d 100644
--- a/sim/testsuite/ChangeLog
+++ b/sim/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2007-10-11 Jesper Nilsson <jesper.nilsson@axis.com>
+
+ * sim/cris/c/freopen2.c: Added testcase.
+
2006-10-02 Hans-Peter Nilsson <hp@axis.com>
Edgar E. Iglesias <edgar@axis.com>
diff --git a/sim/testsuite/sim/cris/c/freopen1.c b/sim/testsuite/sim/cris/c/freopen1.c
index eeb6079..0e0f28d 100644
--- a/sim/testsuite/sim/cris/c/freopen1.c
+++ b/sim/testsuite/sim/cris/c/freopen1.c
@@ -1,7 +1,4 @@
-/* Check that basic freopen functionality works.
-#xfail: *-*-*
- Currently doesn't work, because syscall.c:cb_syscall case
- CB_SYS_write intercepts writes to fd 1 and 2. */
+/* Check that basic freopen functionality works. */
#include <stdio.h>
#include <stdlib.h>
diff --git a/sim/testsuite/sim/cris/c/freopen2.c b/sim/testsuite/sim/cris/c/freopen2.c
new file mode 100644
index 0000000..3959607
--- /dev/null
+++ b/sim/testsuite/sim/cris/c/freopen2.c
@@ -0,0 +1,40 @@
+/* Tests that stdin can be redirected from a normal file. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (void)
+{
+ const char* fname = "freopen.dat";
+ const char tsttxt[]
+ = "A random line of text, used to test correct freopen etc.\n";
+ FILE* instream;
+ FILE *old_stderr;
+ char c1;
+
+ /* Like the freopen call in flex. */
+ old_stderr = freopen (fname, "w+", stderr);
+ if (old_stderr == NULL
+ || fwrite (tsttxt, 1, strlen (tsttxt), stderr) != strlen (tsttxt)
+ || fclose (stderr) != 0)
+ {
+ printf ("fail\n");
+ exit (1);
+ }
+
+ instream = freopen(fname, "r", stdin);
+ if (instream == NULL) {
+ printf("fail\n");
+ exit(1);
+ }
+
+ c1 = getc(instream);
+ if (c1 != 'A') {
+ printf("fail\n");
+ exit(1);
+ }
+
+ printf ("pass\n");
+ exit(0);
+}