aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2010-10-07 21:46:51 +0000
committerHans-Peter Nilsson <hp@gcc.gnu.org>2010-10-07 21:46:51 +0000
commit599fdf0ca5a98ac256321e68ab5af11950263fea (patch)
tree0686b70bd1d6f9d07c393fd73d751ee3dfe482f4
parent38851a969d70820c9519bf99e569e1da0a55ffe6 (diff)
downloadgcc-599fdf0ca5a98ac256321e68ab5af11950263fea.zip
gcc-599fdf0ca5a98ac256321e68ab5af11950263fea.tar.gz
gcc-599fdf0ca5a98ac256321e68ab5af11950263fea.tar.bz2
re PR libstdc++/45841 (r164529 cris-elf libstdc++ 27_io/basic_filebuf/seekoff/char/2-io.cc)
PR libstdc++/45841 * testsuite/lib/libstdc++.exp (check_v3_target_fileio): Rewrite to use an actual testsuite file and machinery, not ".". Specifically check that incorrectly seeking backwards from 0 yields an error, and that reading, seeking backwards and reading again works. From-SVN: r165136
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/testsuite/lib/libstdc++.exp23
2 files changed, 22 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 99c840d..10939d8 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,11 @@
2010-10-07 Hans-Peter Nilsson <hp@axis.com>
+ PR libstdc++/45841
+ * testsuite/lib/libstdc++.exp (check_v3_target_fileio): Rewrite to
+ use an actual testsuite file and machinery, not ".". Specifically
+ check that incorrectly seeking backwards from 0 yields an error,
+ and that reading, seeking backwards and reading again works.
+
* testsuite/libstdc++-dg/conformance.exp: Apply
check_v3_target_fileio as a gate for tests in
subdirectories matching the substring _filebuf.
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 41f593b..a0279a5 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -631,6 +631,7 @@ proc check_v3_target_fileio { } {
global et_fileio_saved
global et_fileio_target_name
global tool
+ global srcdir
if { ![info exists et_fileio_target_name] } {
set et_fileio_target_name ""
@@ -656,6 +657,8 @@ proc check_v3_target_fileio { } {
# the file functions
set src fileio[pid].cc
set exe fileio[pid].x
+ set testfile "cin_unget-1.txt"
+ v3-copy-files "$srcdir/data/$testfile"
set f [open $src "w"]
puts $f "#include <sys/types.h>"
@@ -663,20 +666,26 @@ proc check_v3_target_fileio { } {
puts $f "#include <fcntl.h>"
puts $f "#include <unistd.h>"
puts $f "#include <errno.h>"
+ puts $f "#include <string.h>"
puts $f "using namespace std;"
puts $f "int main ()"
puts $f "{"
- puts $f " int fd = open (\".\", O_RDONLY);"
+ puts $f " int fd = open (\"$testfile\", O_RDONLY);"
puts $f " int ret = 0;"
+ puts $f " char buf\[10\];"
puts $f " if (fd == -1)"
- puts $f " {"
- puts $f " int err = errno;"
- puts $f " if (err == EIO || err == ENOSYS)"
- puts $f " ret = 1;"
- puts $f " }"
+ puts $f " ret = 1;"
puts $f " else"
puts $f " {"
- puts $f " if (lseek (fd, 0, SEEK_CUR) == -1)"
+ puts $f " if (lseek (fd, -1, SEEK_CUR) != -1 || errno != EINVAL)"
+ puts $f " ret = 1;"
+ puts $f " errno = 0;"
+ puts $f " if (lseek (fd, 0, SEEK_CUR) != 0"
+ puts $f " || read (fd, buf, 4) != 4"
+ puts $f " || memcmp (buf, \"1234\", 4) != 0"
+ puts $f " || lseek (fd, -2, SEEK_CUR) != 2"
+ puts $f " || read (fd, buf, 2) != 2"
+ puts $f " || memcmp (buf, \"34\", 2) != 0)"
puts $f " ret = 1;"
puts $f " close (fd);"
puts $f " }"