OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_filebuf/] [imbue/] [char/] [13171-2.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// { dg-require-namedlocale "" }
2
// { dg-require-fork "" }
3
// { dg-require-mkfifo "" }
4
 
5
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009
6
// 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 3, or (at your option)
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
20
// with this library; see the file COPYING3.  If not see
21
// <http://www.gnu.org/licenses/>.
22
 
23
// 27.8.1.4 Overridden virtual functions
24
 
25
#include <fstream>
26
#include <locale>
27
#include <cstdlib>
28
 
29
#include <sys/types.h>
30
#include <sys/stat.h>
31
 
32
// No asserts, avoid leaking the semaphores if a VERIFY fails.
33
#undef _GLIBCXX_ASSERT
34
 
35
#include <testsuite_hooks.h>
36
 
37
// libstdc++/13171
38
bool test01()
39
{
40
  bool test __attribute__((unused)) = true;
41
  using namespace std;
42
  using namespace __gnu_test;
43
 
44
  locale loc_fr(locale("fr_FR"));
45
  locale loc_en(locale("en_US"));
46
 
47
  const char* name = "tmp_fifo_13171-2";
48
  unlink(name);
49
  mkfifo(name, S_IRWXU);
50
  semaphore s1, s2;
51
 
52
  int child = fork();
53
  if (child == 0)
54
    {
55
      filebuf fb;
56
      fb.open(name, ios_base::out);
57
      fb.sputc('S');
58
      fb.pubsync();
59
      s1.signal();
60
      s2.wait();
61
      fb.close();
62
      exit(0);
63
    }
64
 
65
  filebuf fb;
66
  fb.pubimbue(loc_fr);
67
  fb.open(name, ios_base::in);
68
  s1.wait();
69
  VERIFY( fb.is_open() );
70
  fb.pubimbue(loc_en);
71
  filebuf::int_type c = fb.sgetc();
72
  fb.close();
73
  VERIFY( c == 'S' );
74
  s2.signal();
75
 
76
  return test;
77
}
78
 
79
int main()
80
{
81
  return !test01();
82
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.