]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/9507.cc
testsuite_hooks.cc: Update coypright and follow style guidelines.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_filebuf / open / char / 9507.cc
1 // Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 2, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING. If not, write to the Free
16 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 // USA.
18
19 // 27.8.1.3 filebuf member functions
20 // @require@ %-*.tst %-*.txt
21 // @diff@ %-*.tst %-*.txt
22
23 // various tests for filebuf::open() and filebuf::close() including
24 // the non-portable functionality in the libstdc++-v3 IO library
25
26 #include <fstream>
27 #include <unistd.h>
28 #include <signal.h>
29 #include <fcntl.h>
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <testsuite_hooks.h>
33
34 // libstdc++/9507
35 void test_06()
36 {
37 using namespace __gnu_test;
38 bool test __attribute__((unused)) = true;
39 const char* name = "tmp_fifo2";
40 semaphore s1, s2;
41
42 signal(SIGPIPE, SIG_IGN);
43
44 unlink(name);
45 try_mkfifo(name, S_IRWXU);
46
47 if (!fork())
48 {
49 std::filebuf fbuf;
50 fbuf.open(name, std::ios_base::in);
51 fbuf.sgetc();
52 s1.signal ();
53 fbuf.close();
54 s2.wait ();
55 exit(0);
56 }
57
58 std::filebuf fbuf;
59 std::filebuf* r = fbuf.open(name,
60 std::ios_base::in
61 | std::ios_base::out
62 | std::ios_base::ate);
63 s1.wait ();
64 VERIFY( !fbuf.is_open() );
65 VERIFY( r == NULL );
66 s2.signal ();
67 }
68
69 int
70 main()
71 {
72 test_06();
73 return 0;
74 }
75
76