]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/9507.cc
1 // { dg-require-mkfifo "" }
3 // Copyright (C) 2001-2019 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 27.8.1.3 filebuf member functions
21 // @require@ %-*.tst %-*.txt
22 // @diff@ %-*.tst %-*.txt
24 // various tests for filebuf::open() and filebuf::close() including
25 // the non-portable functionality in the libstdc++-v3 IO library
31 #include <sys/types.h>
33 #include <testsuite_hooks.h>
38 using namespace __gnu_test
;
39 const char* name
= "tmp_fifo2";
41 signal(SIGPIPE
, SIG_IGN
);
44 mkfifo(name
, S_IRWXU
);
47 // The use of ios_base::ate implies an attempt to seek on the file
48 // descriptor. The seek will fail. Thus, at the OS level, this
49 // call to "fbuf.open" will result in a call to "open" (which will
50 // succeed), a call to "lseek" (which will fail), and, finally, a
51 // call to "close" (which will succeed). Thus, after this call, the
52 // file should be closed.
53 std::filebuf
* r
= fbuf
.open(name
,
56 | std::ios_base::ate
);
58 VERIFY( !fbuf
.is_open() );
60 VERIFY( fbuf
.is_open() );