*** 9964.cc.orig Thu Apr 22 11:24:02 2004 --- 9964.cc Thu Apr 22 11:24:30 2004 *************** *** 1,4 **** ! // Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the --- 1,4 ---- ! // Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the *************** *** 16,27 **** // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. ! // 27.8.1.3 filebuf member functions ! // @require@ %-*.tst %-*.txt ! // @diff@ %-*.tst %-*.txt ! // various tests for filebuf::open() and filebuf::close() including ! // the non-portable functionality in the libstdc++-v3 IO library #include #include --- 16,25 ---- // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. ! // HPUX doesn't support opening fifos with O_WRONLY | O_TRUNC ! // { dg-do run { xfail *-*-hpux* } } ! // 27.8.1.3 filebuf member functions #include #include *************** *** 32,37 **** --- 30,37 ---- #include // libstdc++/9964 + // Check that if basic_filebuf::close() fails (that is, returns NULL), + // the file still gets closed. void test_07() { using namespace std; *************** void test_07() *** 45,55 **** unlink(name); try_mkfifo(name, S_IRWXU); ! int child = fork(); VERIFY( child != -1 ); if (child == 0) { filebuf fbin; fbin.open(name, ios_base::in); sleep(2); --- 45,58 ---- unlink(name); try_mkfifo(name, S_IRWXU); ! pid_t child = fork(); VERIFY( child != -1 ); if (child == 0) { + // Avoid blocking too long in open + alarm(10); + filebuf fbin; fbin.open(name, ios_base::in); sleep(2); *************** void test_07() *** 59,73 **** filebuf fb; sleep(1); ! filebuf* ret = fb.open(name, ios_base::in | ios_base::out); VERIFY( ret != NULL ); VERIFY( fb.is_open() ); sleep(3); fb.sputc('a'); ret = fb.close(); ! VERIFY( ret != NULL ); VERIFY( !fb.is_open() ); } --- 62,84 ---- filebuf fb; sleep(1); ! ! // This opens the fifo with O_WRONLY | O_TRUNC. The linux man page says ! // that this is OK and the O_TRUNC is ignored, but it seems that some ! // other systems don't like it. ! filebuf* ret = fb.open(name, ios_base::out); VERIFY( ret != NULL ); VERIFY( fb.is_open() ); sleep(3); fb.sputc('a'); + // Close should fail when it tries to flush the buffer, since the other + // end of the fifo should be closed by now. ret = fb.close(); ! // Make sure it failed. ! VERIFY( ret == NULL ); ! // Check that file really was closed. VERIFY( !fb.is_open() ); }