Dead
[official-gcc.git] / gomp-20050608-branch / libstdc++-v3 / testsuite / 27_io / basic_filebuf / underflow / char / 10097.cc
blob33c72306990c0df754e71d1724185e48df66d91e
1 // { dg-require-fork "" }
2 // { dg-require-mkfifo "" }
4 // 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
6 // Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
7 //
8 // This file is part of the GNU ISO C++ Library. This library is free
9 // software; you can redistribute it and/or modify it under the
10 // terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 2, or (at your option)
12 // any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License along
20 // with this library; see the file COPYING. If not, write to the Free
21 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 // USA.
24 // 27.8.1.4 Overridden virtual functions
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>
34 class UnderBuf : public std::filebuf
36 public:
37 int_type
38 pub_underflow()
39 { return underflow(); }
41 std::streamsize
42 pub_showmanyc()
43 { return showmanyc(); }
46 // libstdc++/10097
47 // filebuf::underflow drops characters.
48 void test16()
50 using namespace std;
51 using namespace __gnu_test;
52 bool test __attribute__((unused)) = true;
54 const char* name = "tmp_fifo1";
56 signal(SIGPIPE, SIG_IGN);
57 unlink(name);
59 if (0 != mkfifo(name, S_IRWXU))
61 VERIFY( false );
64 semaphore s1;
65 int fval = fork();
66 if (fval == -1)
68 unlink(name);
69 VERIFY( false );
71 else if (fval == 0)
73 filebuf fbout;
74 fbout.open(name, ios_base::in|ios_base::out);
75 VERIFY ( fbout.is_open() );
76 fbout.sputn("0123456789", 10);
77 fbout.pubsync();
78 s1.wait ();
79 fbout.close();
80 exit(0);
83 UnderBuf fb;
84 fb.open(name, ios_base::in);
86 fb.sgetc();
87 streamsize n = fb.pub_showmanyc();
89 while (n > 0)
91 --n;
93 UnderBuf::int_type c = fb.pub_underflow();
94 VERIFY( c != UnderBuf::traits_type::eof() );
96 fb.sbumpc();
99 fb.close();
100 s1.signal ();
103 int main()
105 test16();
106 return 0;