This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: Eliminate uses of "sleep" in V3 testsuite
Jonathan Wakely wrote:
But if there's a fifo with no reader, could open(name, O_WRONLY) block,
so we don't even get to the seek?
Yes.
As I asid in my earlier posting, the child process used to be necessary,
before Zack added the "ios_base::in" flag to the parent's call to
fbuf.open. However, without that flag, V3 calls "open" with "O_WRONLY |
O_TRUNC" which the HP-UX kernel does not accept on a FIFO.
As Mark said, using a pipe would avoid these peculiarities of fifos, and
the child would be redundant.
The child is redundant anyhow; the parent opens the FIFO for reading and
writing simultaneously. As Paolo and I have agreed on that, I've
checked in the attached patch, which should eliminate the timeouts.
As you and I agree, we could modify this test to use a pipe, rather than
a FIFO, but I'm not about to undertake that project.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
2005-01-05 Mark Mitchell <mark@codesourcery.com>
* testsuite/27_io/basic_filebuf/open/char/9507.cc: Remove child
process.
Index: testsuite/27_io/basic_filebuf/open/char/9507.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/9507.cc,v
retrieving revision 1.8
diff -c -5 -p -r1.8 9507.cc
*** testsuite/27_io/basic_filebuf/open/char/9507.cc 4 Jan 2005 00:17:15 -0000 1.8
--- testsuite/27_io/basic_filebuf/open/char/9507.cc 5 Jan 2005 16:05:12 -0000
***************
*** 35,71 ****
void test_06()
{
using namespace __gnu_test;
bool test __attribute__((unused)) = true;
const char* name = "tmp_fifo2";
- semaphore s1, s2;
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
- if (!fork())
- {
- std::filebuf fbuf;
- fbuf.open(name, std::ios_base::in);
- fbuf.sgetc();
- s1.signal ();
- fbuf.close();
- s2.wait ();
- exit(0);
- }
-
std::filebuf fbuf;
std::filebuf* r = fbuf.open(name,
std::ios_base::in
| std::ios_base::out
| std::ios_base::ate);
- s1.wait ();
VERIFY( !fbuf.is_open() );
VERIFY( r == NULL );
- s2.signal ();
}
int
main()
{
--- 35,63 ----
void test_06()
{
using namespace __gnu_test;
bool test __attribute__((unused)) = true;
const char* name = "tmp_fifo2";
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
std::filebuf fbuf;
+ // The use of ios_base::ate implies an attempt to seek on the file
+ // descriptor. The seek will fail. Thus, at the OS level, this
+ // call to "fbuf.open" will result in a call to "open" (which will
+ // succeed), a call to "lseek" (which will fail), and, finally, a
+ // call to "close" (which will succeed). Thus, after this call, the
+ // file should be closed.
std::filebuf* r = fbuf.open(name,
std::ios_base::in
| std::ios_base::out
| std::ios_base::ate);
VERIFY( !fbuf.is_open() );
VERIFY( r == NULL );
}
int
main()
{