From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/27_io/basic_filebuf/open/char/1.cc | 74 ++++++++++++++++++++++ .../testsuite/27_io/basic_filebuf/open/char/2.cc | 59 +++++++++++++++++ .../testsuite/27_io/basic_filebuf/open/char/3.cc | 54 ++++++++++++++++ .../testsuite/27_io/basic_filebuf/open/char/4.cc | 72 +++++++++++++++++++++ .../testsuite/27_io/basic_filebuf/open/char/5.cc | 30 +++++++++ .../27_io/basic_filebuf/open/char/9507.cc | 72 +++++++++++++++++++++ 6 files changed, 361 insertions(+) create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/2.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/3.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/4.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/5.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/9507.cc (limited to 'libstdc++-v3/testsuite/27_io/basic_filebuf/open/char') diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/1.cc new file mode 100644 index 000000000..1a40da155 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/1.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2001, 2002, 2003, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.3 filebuf member functions +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %-*.txt + +// various tests for filebuf::open() and filebuf::close() including +// the non-portable functionality in the libstdc++-v3 IO library + +// { dg-require-fileio "" } + +#include +#include + +const char name_01[] = "filebuf_members-1.tst"; +const char name_02[] = "filebuf_members-1.txt"; + +// Test member functions. +void test_01() +{ + bool test __attribute__((unused)) = true; + const char* name_03 = "filebuf_members-3"; // empty file, need to create + + std::filebuf fb_01; // in + std::filebuf fb_02; // out + std::filebuf fb_03; // in | out + + // bool is_open() + VERIFY( !fb_01.is_open() ); + VERIFY( !fb_02.is_open() ); + VERIFY( !fb_03.is_open() ); + + // filebuf_type* open(const char* __s, ios_base::openmode __mode) + fb_01.open(name_01, std::ios_base::in | std::ios_base::ate); + VERIFY( fb_01.is_open() ); + + // Try to open two different files without closing the first: + // Should keep the old file attached, and disregard attempt to overthrow. + std::filebuf* f = fb_02.open(name_02, std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + VERIFY( f ); + VERIFY( fb_02.is_open() ); + + f = fb_02.open(name_03, std::ios_base::in | std::ios_base::out); + VERIFY( !f ); + VERIFY( fb_02.is_open() ); + + fb_03.open(name_03, std::ios_base::out | std::ios_base::trunc); + VERIFY( fb_03.is_open() ); +} + +int +main() +{ + test_01(); + return 0; +} + + diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/2.cc new file mode 100644 index 000000000..755784fb9 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/2.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2001, 2002, 2003, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.3 filebuf member functions +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %-*.txt + +// various tests for filebuf::open() and filebuf::close() including +// the non-portable functionality in the libstdc++-v3 IO library + +// { dg-require-fileio "" } + +#include +#include +#include +#include +#include +#include +#include +#include + +const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it + +void test_03() +{ + bool test __attribute__((unused)) = true; + int first_fd = ::open(name_01, O_RDONLY); + VERIFY( first_fd != -1 ); + FILE* first_file = ::fdopen(first_fd, "r"); + VERIFY( first_file ); + __gnu_cxx::stdio_filebuf fb(first_file, std::ios_base::in); + + int second_fd = fb.fd(); + + VERIFY( first_fd == second_fd ); +} + +int +main() +{ + test_03(); + return 0; +} + + diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/3.cc new file mode 100644 index 000000000..6b076a699 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/3.cc @@ -0,0 +1,54 @@ +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.3 filebuf member functions +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %-*.txt + +// various tests for filebuf::open() and filebuf::close() including +// the non-portable functionality in the libstdc++-v3 IO library + +// { dg-require-fileio "" } + +#include +#include + +// Charles Leggett +void test_05() +{ + bool test __attribute__((unused)) = true; + const char* name = "tmp_file5"; + + std::fstream scratch_file; + + scratch_file.open(name, std::ios::out); + scratch_file.close(); + + scratch_file.open(name, std::ios::in); + if (!scratch_file) + VERIFY( false ); + scratch_file.close(); +} + +int +main() +{ + test_05(); + return 0; +} + + diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/4.cc new file mode 100644 index 000000000..31d25422b --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/4.cc @@ -0,0 +1,72 @@ +// 2006-10-01 Paolo Carlini + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-require-fileio "" } + +#include +#include + +// DR 596. +void test01() +{ + bool test __attribute__((unused)) = true; + const char* name = "tmp_file4"; + + std::fstream scratch_file; + + scratch_file.open(name, std::ios_base::app); + VERIFY( scratch_file ); + VERIFY( scratch_file.is_open() ); + scratch_file.close(); + + scratch_file.open(name, std::ios_base::in | std::ios_base::out + | std::ios_base::app); + VERIFY( scratch_file ); + VERIFY( scratch_file.is_open() ); + scratch_file.close(); + + scratch_file.open(name, std::ios_base::in | std::ios_base::app); + VERIFY( scratch_file ); + VERIFY( scratch_file.is_open() ); + scratch_file.close(); + + scratch_file.open(name, std::ios_base::app | std::ios_base::binary); + VERIFY( scratch_file ); + VERIFY( scratch_file.is_open() ); + scratch_file.close(); + + scratch_file.open(name, std::ios_base::in | std::ios_base::out + | std::ios_base::app | std::ios_base::binary); + VERIFY( scratch_file ); + VERIFY( scratch_file.is_open() ); + scratch_file.close(); + + scratch_file.open(name, std::ios_base::in | std::ios_base::app + | std::ios_base::binary); + VERIFY( scratch_file ); + VERIFY( scratch_file.is_open() ); + scratch_file.close(); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/5.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/5.cc new file mode 100644 index 000000000..47721e6ad --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/5.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include + +// Test member functions. +void test01() +{ + std::filebuf fb; + + const std::string name = "filebuf_name.txt"; + fb.open(name, std::ios_base::in | std::ios_base::ate); +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/9507.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/9507.cc new file mode 100644 index 000000000..5b404375e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/9507.cc @@ -0,0 +1,72 @@ +// { dg-require-mkfifo "" } + +// Copyright (C) 2001, 2002, 2003, 2005, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.3 filebuf member functions +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %-*.txt + +// various tests for filebuf::open() and filebuf::close() including +// the non-portable functionality in the libstdc++-v3 IO library + +#include +#include +#include +#include +#include +#include +#include + +// libstdc++/9507 +void test_06() +{ + using namespace __gnu_test; + bool test __attribute__((unused)) = true; + const char* name = "tmp_fifo2"; + + signal(SIGPIPE, SIG_IGN); + + unlink(name); + mkfifo(name, S_IRWXU); + + std::filebuf fbuf; + // The use of ios_base::ate implies an attempt to seek on the file + // descriptor. The seek will fail. Thus, at the OS level, this + // call to "fbuf.open" will result in a call to "open" (which will + // succeed), a call to "lseek" (which will fail), and, finally, a + // call to "close" (which will succeed). Thus, after this call, the + // file should be closed. + std::filebuf* r = fbuf.open(name, + std::ios_base::in + | std::ios_base::out + | std::ios_base::ate); + if (!r) + VERIFY( !fbuf.is_open() ); + else + VERIFY( fbuf.is_open() ); +} + +int +main() +{ + test_06(); + return 0; +} + + -- cgit v1.2.3