]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc
alpha.c (alpha_gp_save_rtx): Insert the insns at the entry by means of emit_insn_at_e...
[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
9339bda8 5// Copyright (C) 2003, 2004, 2005, 2006 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>
c03d83d4
PC
27
28#include <sys/types.h>
29#include <sys/stat.h>
30
9339bda8
PC
31// No asserts, avoid leaking the semaphores if a VERIFY fails.
32#undef _GLIBCXX_ASSERT
33
c03d83d4
PC
34#include <testsuite_hooks.h>
35
36// libstdc++/13171
9339bda8 37bool test01()
c03d83d4
PC
38{
39 bool test __attribute__((unused)) = true;
40 using namespace std;
ea1ea21a 41 using namespace __gnu_test;
c03d83d4 42
f63a8495
PC
43 locale loc_fr(locale("fr_FR"));
44 locale loc_en(locale("en_US"));
2d25605a 45
c03d83d4
PC
46 const char* name = "tmp_fifo_13171-2";
47 unlink(name);
34f4edf8 48 mkfifo(name, S_IRWXU);
8f1032c1 49 semaphore s1, s2;
c03d83d4
PC
50
51 int child = fork();
52 if (child == 0)
53 {
54 filebuf fb;
55 fb.open(name, ios_base::out);
56 fb.sputc('S');
2d25605a 57 fb.pubsync();
9339bda8
PC
58 s1.signal();
59 s2.wait();
c03d83d4 60 fb.close();
2d25605a 61 exit(0);
c03d83d4
PC
62 }
63
64 filebuf fb;
2d25605a 65 fb.pubimbue(loc_fr);
c03d83d4 66 fb.open(name, ios_base::in);
9339bda8 67 s1.wait();
2d25605a
PC
68 VERIFY( fb.is_open() );
69 fb.pubimbue(loc_en);
c03d83d4 70 filebuf::int_type c = fb.sgetc();
c03d83d4 71 fb.close();
2d25605a 72 VERIFY( c == 'S' );
9339bda8
PC
73 s2.signal();
74
75 return test;
c03d83d4
PC
76}
77
78int main()
79{
9339bda8 80 return !test01();
c03d83d4 81}