]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc
re PR testsuite/39696 (gcc.dg/tree-ssa/ssa-ccp-25.c scan-tree-dump doesn't work on...
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_filebuf / imbue / char / 13171-2.cc
CommitLineData
f63a8495 1// { dg-require-namedlocale "" }
34f4edf8
MM
2// { dg-require-fork "" }
3// { dg-require-mkfifo "" }
4
debac9f4 5// Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
c03d83d4
PC
6//
7// This file is part of the GNU ISO C++ Library. This library is free
8// software; you can redistribute it and/or modify it under the
9// terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 2, or (at your option)
11// any later version.
12
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17
18// You should have received a copy of the GNU General Public License along
19// with this library; see the file COPYING. If not, write to the Free
83f51799 20// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
c03d83d4
PC
21// USA.
22
23// 27.8.1.4 Overridden virtual functions
24
25#include <fstream>
26#include <locale>
debac9f4 27#include <cstdlib>
c03d83d4
PC
28
29#include <sys/types.h>
30#include <sys/stat.h>
31
9339bda8
PC
32// No asserts, avoid leaking the semaphores if a VERIFY fails.
33#undef _GLIBCXX_ASSERT
34
c03d83d4
PC
35#include <testsuite_hooks.h>
36
37// libstdc++/13171
9339bda8 38bool test01()
c03d83d4
PC
39{
40 bool test __attribute__((unused)) = true;
41 using namespace std;
ea1ea21a 42 using namespace __gnu_test;
c03d83d4 43
f63a8495
PC
44 locale loc_fr(locale("fr_FR"));
45 locale loc_en(locale("en_US"));
2d25605a 46
c03d83d4
PC
47 const char* name = "tmp_fifo_13171-2";
48 unlink(name);
34f4edf8 49 mkfifo(name, S_IRWXU);
8f1032c1 50 semaphore s1, s2;
c03d83d4
PC
51
52 int child = fork();
53 if (child == 0)
54 {
55 filebuf fb;
56 fb.open(name, ios_base::out);
57 fb.sputc('S');
2d25605a 58 fb.pubsync();
9339bda8
PC
59 s1.signal();
60 s2.wait();
c03d83d4 61 fb.close();
2d25605a 62 exit(0);
c03d83d4
PC
63 }
64
65 filebuf fb;
2d25605a 66 fb.pubimbue(loc_fr);
c03d83d4 67 fb.open(name, ios_base::in);
9339bda8 68 s1.wait();
2d25605a
PC
69 VERIFY( fb.is_open() );
70 fb.pubimbue(loc_en);
c03d83d4 71 filebuf::int_type c = fb.sgetc();
c03d83d4 72 fb.close();
2d25605a 73 VERIFY( c == 'S' );
9339bda8
PC
74 s2.signal();
75
76 return test;
c03d83d4
PC
77}
78
79int main()
80{
9339bda8 81 return !test01();
c03d83d4 82}