2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libstdc++-v3 / testsuite / 27_io / objects / char / 7.cc
blob21a7b49c47962524ce39f5f6c2f3d51f67b08d07
1 // 2003-04-26 Petur Runolfsson <peturr02@ru.is>
3 // Copyright (C) 2003 Free Software Foundation, Inc.
4 //
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 2, or (at your option)
9 // any later version.
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 COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
21 // 27.3 Standard iostream objects
23 // XXX cygwin does not support mkfifo
24 // { dg-do run { xfail *-*-cygwin* } }
26 #include <fstream>
27 #include <iostream>
28 #include <unistd.h>
29 #include <signal.h>
30 #include <fcntl.h>
31 #include <sys/types.h>
32 #include <sys/stat.h>
33 #include <testsuite_hooks.h>
35 // Check that cout.flush() is called when last ios_base::Init is destroyed.
36 void test07()
38 using namespace std;
39 bool test __attribute__((unused)) = true;
41 const char* name = "tmp_fifo4";
43 signal(SIGPIPE, SIG_IGN);
45 unlink(name);
46 mkfifo(name, S_IRWXU);
48 int child = fork();
49 VERIFY( child != -1 );
51 if (child == 0)
53 filebuf fbout;
54 sleep(1);
55 fbout.open(name, ios_base::out);
56 cout.rdbuf(&fbout);
57 fbout.sputc('a');
58 sleep(2);
59 // NB: fbout is *not* destroyed here!
60 exit(0);
63 filebuf fbin;
64 fbin.open(name, ios_base::in);
65 sleep(2);
66 filebuf::int_type c = fbin.sbumpc();
67 VERIFY( c != filebuf::traits_type::eof() );
68 VERIFY( c == filebuf::traits_type::to_int_type('a') );
70 fbin.close();
73 int
74 main()
76 test07();
77 return 0;