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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_filebuf/] [open/] [char/] [9507.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// { dg-require-mkfifo "" }
2
 
3
// Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 2, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
// 27.8.1.3 filebuf member functions
22
// @require@ %-*.tst %-*.txt
23
// @diff@ %-*.tst %-*.txt
24
 
25
// various tests for filebuf::open() and filebuf::close() including
26
// the non-portable functionality in the libstdc++-v3 IO library
27
 
28
#include <fstream>
29
#include <unistd.h>
30
#include <signal.h>
31
#include <fcntl.h>
32
#include <sys/types.h>
33
#include <sys/stat.h>
34
#include <testsuite_hooks.h>
35
 
36
// libstdc++/9507
37
void test_06()
38
{
39
  using namespace __gnu_test;
40
  bool test __attribute__((unused)) = true;
41
  const char* name = "tmp_fifo2";
42
 
43
  signal(SIGPIPE, SIG_IGN);
44
 
45
  unlink(name);
46
  mkfifo(name, S_IRWXU);
47
 
48
  std::filebuf fbuf;
49
  // The use of ios_base::ate implies an attempt to seek on the file
50
  // descriptor.  The seek will fail.  Thus, at the OS level, this
51
  // call to "fbuf.open" will result in a call to "open" (which will
52
  // succeed), a call to "lseek" (which will fail), and, finally, a
53
  // call to "close" (which will succeed).  Thus, after this call, the
54
  // file should be closed.
55
  std::filebuf* r = fbuf.open(name,
56
                              std::ios_base::in
57
                              | std::ios_base::out
58
                              | std::ios_base::ate);
59
  if (r == NULL)
60
    VERIFY( !fbuf.is_open() );
61
  else
62
    VERIFY( fbuf.is_open() );
63
}
64
 
65
int
66
main()
67
{
68
  test_06();
69
  return 0;
70
}
71
 
72
 

powered by: WebSVN 2.1.0

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