]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_filebuf / imbue / char / 13171-2.cc
CommitLineData
be803e41 1// { dg-require-namedlocale "fr_FR.ISO8859-15" }
2// { dg-require-namedlocale "en_US.ISO8859-1" }
16cb9d1f 3// { dg-require-fork "" }
4// { dg-require-mkfifo "" }
5
fbd26352 6// Copyright (C) 2003-2019 Free Software Foundation, Inc.
524fbb3a 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
6bc9506f 11// Free Software Foundation; either version 3, or (at your option)
524fbb3a 12// any later version.
13
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.
18
19// You should have received a copy of the GNU General Public License along
6bc9506f 20// with this library; see the file COPYING3. If not see
21// <http://www.gnu.org/licenses/>.
524fbb3a 22
23// 27.8.1.4 Overridden virtual functions
24
25#include <fstream>
26#include <locale>
ceb6f07a 27#include <cstdlib>
524fbb3a 28
29#include <sys/types.h>
30#include <sys/stat.h>
31
32#include <testsuite_hooks.h>
33
34// libstdc++/13171
dfd22e84 35bool test01()
524fbb3a 36{
31483268 37 bool test = true;
524fbb3a 38 using namespace std;
7f26a832 39 using namespace __gnu_test;
524fbb3a 40
be803e41 41 locale loc_fr(locale(ISO_8859(15,fr_FR)));
42 locale loc_en(locale(ISO_8859(1,en_US)));
0fef54cd 43
524fbb3a 44 const char* name = "tmp_fifo_13171-2";
45 unlink(name);
16cb9d1f 46 mkfifo(name, S_IRWXU);
007b777a 47 semaphore s1, s2;
524fbb3a 48
49 int child = fork();
50 if (child == 0)
51 {
52 filebuf fb;
53 fb.open(name, ios_base::out);
54 fb.sputc('S');
0fef54cd 55 fb.pubsync();
dfd22e84 56 s1.signal();
57 s2.wait();
524fbb3a 58 fb.close();
0fef54cd 59 exit(0);
524fbb3a 60 }
61
62 filebuf fb;
0fef54cd 63 fb.pubimbue(loc_fr);
524fbb3a 64 fb.open(name, ios_base::in);
dfd22e84 65 s1.wait();
31483268 66 test &= bool( fb.is_open() );
0fef54cd 67 fb.pubimbue(loc_en);
524fbb3a 68 filebuf::int_type c = fb.sgetc();
524fbb3a 69 fb.close();
31483268 70 test &= bool( c == 'S' );
dfd22e84 71 s2.signal();
72
73 return test;
524fbb3a 74}
75
76int main()
77{
dfd22e84 78 return !test01();
524fbb3a 79}