This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Eliminate uses of "sleep" in V3 testsuite
- From: Mark Mitchell <mark at codesourcery dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 3 Jan 2005 13:35:17 -0800
- Subject: PATCH: Eliminate uses of "sleep" in V3 testsuite
- Reply-to: mark at codesourcery dot com
As discussed previously, use of "sleep" as a synchronization primitive
in the V3 testsuite is (a) bogus, and (b) slow. This patch implements
a semaphore class that is used instead. The current implementation of
the semaphore class uses System V IPC, but there's no reason it needs
to do that; it could use some other synchronization primitive
instead. Since these tests already depend on "fork", we're clearly in
the land of UNIX-like systems.
Tested on x86_64-unknown-linux-gnu and i686-pc-linux-gnu. There may
be portability problems to other systems; let me know, and I'll
happily fix them.
This change cuts about 1 minute off of the V3 test time for me.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2005-01-03 Mark Mitchell <mark@codesourcery.com>
* configure.ac: Check for sys/ipc.h and sys/sem.h.
* config.h.in: Regenerated.
* configure: Likewise.
* testsuite/testsuite_hooks.cc (_GLIBCXX_SYSV_SEM): Conditionally
define.
(sys/types.h): Include.
(sys/ipc.h): Likewise.
(sys/sem.h): Likewise.
(__gnu_test::semun): New type.
(__gnu_test::semaphore::sempaphore): New function.
(__gnu_test::semaphore::~semaphore): Likewise.
(__gnu_test::semaphore::wait): Likewise.
(__gnu_test::semaphore::signal): Likewise.
* testsuite/testsuite_hooks.h (__gnu_test::semaphore): New class.
* testsuite/27_io/basic_filebuf/close/char/4789.cc: Use
semaphores, not sleep.
* testsuite/27_io/basic_filebuf/close/char/9964.cc: Likewise.
* testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc: Likewise.
* testsuite/27_io/basic_filebuf/imbue/char/13582-2.cc: Likewise.
* testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc:
Likewise.
* testsuite/27_io/basic_filebuf/open/char/9507.cc: Likewise.
* testsuite/27_io/basic_filebuf/underflow/char/10097.cc: Likewise.
* testsuite/27_io/objects/char/7.cc: Likewise.
* testsuite/27_io/objects/char/9661-1.cc: Likewise.
* testsuite/27_io/objects/wchar_t/7.cc: Likewise.
* testsuite/27_io/objects/wchar_t/9961-1.cc: Likewise.
Index: configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/configure.ac,v
retrieving revision 1.31
diff -c -5 -p -r1.31 configure.ac
*** configure.ac 8 Nov 2004 20:06:25 -0000 1.31
--- configure.ac 3 Jan 2005 21:29:18 -0000
*************** if $GLIBCXX_IS_NATIVE; then
*** 115,125 ****
CANADIAN=no
# Check for available headers.
AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h machine/endian.h \
machine/param.h sys/machine.h fp.h locale.h float.h inttypes.h gconv.h \
! sys/types.h])
GLIBCXX_CHECK_COMPILER_FEATURES
GLIBCXX_CHECK_LINKER_FEATURES
GLIBCXX_CHECK_MATH_SUPPORT
GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
--- 115,125 ----
CANADIAN=no
# Check for available headers.
AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h machine/endian.h \
machine/param.h sys/machine.h fp.h locale.h float.h inttypes.h gconv.h \
! sys/types.h sys/ipc.h sys/sem.h])
GLIBCXX_CHECK_COMPILER_FEATURES
GLIBCXX_CHECK_LINKER_FEATURES
GLIBCXX_CHECK_MATH_SUPPORT
GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
Index: testsuite/testsuite_hooks.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/testsuite_hooks.cc,v
retrieving revision 1.23
diff -c -5 -p -r1.23 testsuite_hooks.cc
*** testsuite/testsuite_hooks.cc 30 Dec 2004 00:21:10 -0000 1.23
--- testsuite/testsuite_hooks.cc 3 Jan 2005 21:29:19 -0000
***************
*** 40,49 ****
--- 40,63 ----
#include <stdexcept>
#include <clocale>
#include <locale>
#include <cxxabi.h>
+ // If we have <sys/types.h>, <sys/ipc.h>, and <sys/sem.h>, then assume
+ // that System V semaphores are available.
+ #if defined(_GLIBCXX_HAVE_SYS_TYPES_H) \
+ && defined(_GLIBCXX_HAVE_SYS_IPC_H) \
+ && defined(_GLIBCXX_HAVE_SYS_SEM_H)
+ #define _GLIBCXX_SYSV_SEM
+ #endif
+
+ #ifdef _GLIBCXX_SYSV_SEM
+ #include <sys/types.h>
+ #include <sys/ipc.h>
+ #include <sys/sem.h>
+ #endif
+
namespace __gnu_test
{
#ifdef _GLIBCXX_RES_LIMITS
void
set_memory_limits(float size)
*************** namespace __gnu_test
*** 250,259 ****
--- 264,351 ----
unsigned int copy_constructor::throw_on_ = 0;
unsigned int assignment_operator::count_ = 0;
unsigned int assignment_operator::throw_on_ = 0;
unsigned int destructor::_M_count = 0;
int copy_tracker::next_id_ = 0;
+
+ #ifdef _GLIBCXX_SYSV_SEM
+ // This union is not declared in system headers. Instead, it must
+ // be defined by user programs.
+ union semun
+ {
+ int val;
+ struct semid_ds *buf;
+ unsigned short *array;
+ };
+ #endif
+
+ semaphore::semaphore ()
+ {
+ #ifdef _GLIBCXX_SYSV_SEM
+ // Remeber the PID for the process that created the semaphore set
+ // so that only one process will destroy the set.
+ pid_ = getpid();
+
+ // GLIBC does not define SEM_R and SEM_A.
+ #ifndef SEM_R
+ #define SEM_R 0400
+ #endif
+
+ #ifndef SEM_A
+ #define SEM_A 0200
+ #endif
+
+ // Get a semaphore set with one semaphore.
+ sem_set_ = semget (IPC_PRIVATE, 1, SEM_R | SEM_A);
+ if (sem_set_ == -1)
+ throw std::runtime_error ("could not obtain semaphore set");
+
+ // Initialize the semaphore.
+ union semun val;
+ val.val = 0;
+ if (semctl (sem_set_, 0, SETVAL, val) == -1)
+ throw std::runtime_error ("could not initialize semaphore");
+ #else
+ // There are no semaphores on this system. We have no way to mark
+ // a test as "unsupported" at runtime, so we just exit, pretending
+ // that the test passed.
+ exit (0);
+ #endif
+ }
+
+ semaphore::~semaphore ()
+ {
+ #ifdef _GLIBCXX_SYSV_SEM
+ union semun val;
+ // Destroy the semaphore set only in the process that created it.
+ if (pid_ == getpid ())
+ semctl (sem_set_, 0, IPC_RMID, val);
+ #endif
+ }
+
+ void
+ semaphore::signal ()
+ {
+ #ifdef _GLIBCXX_SYSV_SEM
+ struct sembuf op[1] = {
+ { 0, 1, 0 }
+ };
+ if (semop (sem_set_, op, 1) == -1)
+ throw std::runtime_error ("could not signal semaphore");
+ #endif
+ }
+
+ void
+ semaphore::wait() {
+ #ifdef _GLIBCXX_SYSV_SEM
+ struct sembuf op[1] = {
+ { 0, -1, SEM_UNDO }
+ };
+ if (semop (sem_set_, op, 1) == -1)
+ throw std::runtime_error ("could not wait for semaphore");
+ #endif
+ }
}; // namespace __gnu_test
namespace std
{
// Member specializations for the existing facet classes.
Index: testsuite/testsuite_hooks.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/testsuite_hooks.h,v
retrieving revision 1.30
diff -c -5 -p -r1.30 testsuite_hooks.h
*** testsuite/testsuite_hooks.h 2 Nov 2004 19:00:17 -0000 1.30
--- testsuite/testsuite_hooks.h 3 Jan 2005 21:29:31 -0000
*************** namespace __gnu_test
*** 378,387 ****
--- 378,411 ----
const_iterator it = v.begin();
const_iterator end = v.end();
return it == end ? v.end() : it;
}
};
+
+ // A binary semaphore for use across multiple processes.
+ class semaphore
+ {
+ public:
+ // Creates a binary semaphore. The semaphore is initially in the
+ // unsignaled state.
+ semaphore ();
+
+ // Destroy the semaphore.
+ ~semaphore();
+
+ // Signal the semaphore. If there are processes blocked in
+ // "wait", exactly one will be permitted to proceed.
+ void signal ();
+
+ // Wait until the semaphore is signaled.
+ void wait ();
+
+ private:
+ int sem_set_;
+
+ pid_t pid_;
+ };
} // namespace __gnu_test
namespace std
{
template<class _CharT>
Index: testsuite/27_io/basic_filebuf/close/char/4879.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/4879.cc,v
retrieving revision 1.4
diff -c -5 -p -r1.4 4879.cc
*** testsuite/27_io/basic_filebuf/close/char/4879.cc 12 Jan 2004 08:11:05 -0000 1.4
--- testsuite/27_io/basic_filebuf/close/char/4879.cc 3 Jan 2005 21:29:32 -0000
*************** test_04()
*** 39,48 ****
--- 39,50 ----
{
using namespace __gnu_test;
bool test __attribute__((unused)) = true;
const char* name = "tmp_fifo1";
+ semaphore s1, s2;
+
signal(SIGPIPE, SIG_IGN);
unlink(name);
if (0 != try_mkfifo(name, S_IRWXU))
{
*************** test_04()
*** 58,74 ****
exit(-1);
}
else if (fval == 0)
{
std::ifstream ifs(name);
! sleep(1);
ifs.close();
exit(0);
}
std::ofstream ofs(name);
! sleep(2);
ofs.put('t');
/*
* ISO/IED 14882:1998(E) 27.8.1.10.4
*
--- 60,78 ----
exit(-1);
}
else if (fval == 0)
{
std::ifstream ifs(name);
! s1.wait ();
ifs.close();
+ s2.signal ();
exit(0);
}
std::ofstream ofs(name);
! s1.signal ();
! s2.wait ();
ofs.put('t');
/*
* ISO/IED 14882:1998(E) 27.8.1.10.4
*
Index: testsuite/27_io/basic_filebuf/close/char/9964.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/9964.cc,v
retrieving revision 1.6
diff -c -5 -p -r1.6 9964.cc
*** testsuite/27_io/basic_filebuf/close/char/9964.cc 5 Feb 2004 05:24:17 -0000 1.6
--- testsuite/27_io/basic_filebuf/close/char/9964.cc 3 Jan 2005 21:29:32 -0000
***************
*** 35,44 ****
--- 35,45 ----
void test_07()
{
using namespace std;
using namespace __gnu_test;
bool test __attribute__((unused)) = true;
+ semaphore s1, s2;
const char* name = "tmp_fifo3";
signal(SIGPIPE, SIG_IGN);
*************** void test_07()
*** 50,71 ****
if (child == 0)
{
filebuf fbin;
fbin.open(name, ios_base::in);
! sleep(2);
fbin.close();
exit(0);
}
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() );
--- 51,72 ----
if (child == 0)
{
filebuf fbin;
fbin.open(name, ios_base::in);
! s1.wait ();
fbin.close();
+ s2.signal ();
exit(0);
}
filebuf fb;
filebuf* ret = fb.open(name, ios_base::in | ios_base::out);
VERIFY( ret != NULL );
VERIFY( fb.is_open() );
! s1.signal ();
! s2.wait ();
fb.sputc('a');
ret = fb.close();
VERIFY( ret != NULL );
VERIFY( !fb.is_open() );
Index: testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc,v
retrieving revision 1.3
diff -c -5 -p -r1.3 13171-2.cc
*** testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc 12 Jan 2004 08:11:06 -0000 1.3
--- testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc 3 Jan 2005 21:29:32 -0000
*************** void test01()
*** 37,68 ****
locale loc_en(__gnu_test::try_named_locale("en_US"));
const char* name = "tmp_fifo_13171-2";
unlink(name);
try_mkfifo(name, S_IRWXU);
int child = fork();
if (child == 0)
{
filebuf fb;
fb.open(name, ios_base::out);
fb.sputc('S');
fb.pubsync();
! sleep(2);
fb.close();
exit(0);
}
filebuf fb;
fb.pubimbue(loc_fr);
fb.open(name, ios_base::in);
! sleep(1);
VERIFY( fb.is_open() );
fb.pubimbue(loc_en);
filebuf::int_type c = fb.sgetc();
fb.close();
VERIFY( c == 'S' );
}
int main()
{
test01();
--- 37,71 ----
locale loc_en(__gnu_test::try_named_locale("en_US"));
const char* name = "tmp_fifo_13171-2";
unlink(name);
try_mkfifo(name, S_IRWXU);
+ semaphore s1, s2;
int child = fork();
if (child == 0)
{
filebuf fb;
fb.open(name, ios_base::out);
fb.sputc('S');
fb.pubsync();
! s1.signal ();
! s2.wait ();
fb.close();
exit(0);
}
filebuf fb;
fb.pubimbue(loc_fr);
fb.open(name, ios_base::in);
! s1.wait ();
VERIFY( fb.is_open() );
fb.pubimbue(loc_en);
filebuf::int_type c = fb.sgetc();
fb.close();
VERIFY( c == 'S' );
+ s2.signal ();
}
int main()
{
test01();
Index: testsuite/27_io/basic_filebuf/imbue/char/13582-2.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/13582-2.cc,v
retrieving revision 1.2
diff -c -5 -p -r1.2 13582-2.cc
*** testsuite/27_io/basic_filebuf/imbue/char/13582-2.cc 12 Jan 2004 17:25:25 -0000 1.2
--- testsuite/27_io/basic_filebuf/imbue/char/13582-2.cc 3 Jan 2005 21:29:32 -0000
*************** void test01()
*** 40,65 ****
locale loc_fr(__gnu_test::try_named_locale("fr_FR"));
const char* name = "tmp_fifo_13582-2";
unlink(name);
try_mkfifo(name, S_IRWXU);
!
int child = fork();
if (child == 0)
{
filebuf fbout;
fbout.open(name, ios_base::out);
fbout.sputn("12345", 5);
fbout.pubsync();
- sleep(2);
fbout.close();
exit(0);
}
filebuf fbin;
fbin.open(name, ios_base::in);
- sleep(1);
filebuf::int_type n = fbin.sbumpc();
VERIFY( n == '1' );
fbin.pubimbue(loc_en);
n = fbin.sbumpc();
VERIFY( n == '2' );
--- 40,63 ----
locale loc_fr(__gnu_test::try_named_locale("fr_FR"));
const char* name = "tmp_fifo_13582-2";
unlink(name);
try_mkfifo(name, S_IRWXU);
!
int child = fork();
if (child == 0)
{
filebuf fbout;
fbout.open(name, ios_base::out);
fbout.sputn("12345", 5);
fbout.pubsync();
fbout.close();
exit(0);
}
filebuf fbin;
fbin.open(name, ios_base::in);
filebuf::int_type n = fbin.sbumpc();
VERIFY( n == '1' );
fbin.pubimbue(loc_en);
n = fbin.sbumpc();
VERIFY( n == '2' );
Index: testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc,v
retrieving revision 1.1
diff -c -5 -p -r1.1 14975-2.cc
*** testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc 16 Apr 2004 16:06:21 -0000 1.1
--- testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc 3 Jan 2005 21:29:32 -0000
*************** void test01()
*** 40,69 ****
signal(SIGPIPE, SIG_IGN);
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);
exit(0);
}
wfilebuf fb;
fb.pubimbue(loc_us);
- sleep(1);
wfilebuf* ret = fb.open(name, ios_base::out);
VERIFY( ret != NULL );
VERIFY( fb.is_open() );
! sleep(3);
try
{
fb.sputc(L'a');
fb.sputc(L'b');
--- 40,71 ----
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
! semaphore s1;
!
int child = fork();
VERIFY( child != -1 );
if (child == 0)
{
! {
! filebuf fbin;
! fbin.open(name, ios_base::in);
! }
! s1.signal ();
exit(0);
}
wfilebuf fb;
fb.pubimbue(loc_us);
wfilebuf* ret = fb.open(name, ios_base::out);
VERIFY( ret != NULL );
VERIFY( fb.is_open() );
! s1.wait ();
try
{
fb.sputc(L'a');
fb.sputc(L'b');
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.6
diff -c -5 -p -r1.6 9507.cc
*** testsuite/27_io/basic_filebuf/open/char/9507.cc 6 Feb 2004 11:45:23 -0000 1.6
--- testsuite/27_io/basic_filebuf/open/char/9507.cc 3 Jan 2005 21:29:32 -0000
***************
*** 35,68 ****
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);
!
if (!fork())
{
std::filebuf fbuf;
fbuf.open(name, std::ios_base::in);
fbuf.sgetc();
! sleep(2);
fbuf.close();
exit(0);
}
std::filebuf fbuf;
- sleep(1);
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()
{
--- 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()
{
Index: testsuite/27_io/basic_filebuf/underflow/char/10097.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/char/10097.cc,v
retrieving revision 1.5
diff -c -5 -p -r1.5 10097.cc
*** testsuite/27_io/basic_filebuf/underflow/char/10097.cc 20 Feb 2004 23:51:07 -0000 1.5
--- testsuite/27_io/basic_filebuf/underflow/char/10097.cc 3 Jan 2005 21:29:32 -0000
*************** void test16()
*** 56,65 ****
--- 56,66 ----
if (0 != try_mkfifo(name, S_IRWXU))
{
VERIFY( false );
}
+ semaphore s1;
int fval = fork();
if (fval == -1)
{
unlink(name);
VERIFY( false );
*************** void test16()
*** 69,86 ****
filebuf fbout;
fbout.open(name, ios_base::in|ios_base::out);
VERIFY ( fbout.is_open() );
fbout.sputn("0123456789", 10);
fbout.pubsync();
! sleep(2);
fbout.close();
exit(0);
}
UnderBuf fb;
fb.open(name, ios_base::in);
- sleep(1);
fb.sgetc();
streamsize n = fb.pub_showmanyc();
while (n > 0)
--- 70,86 ----
filebuf fbout;
fbout.open(name, ios_base::in|ios_base::out);
VERIFY ( fbout.is_open() );
fbout.sputn("0123456789", 10);
fbout.pubsync();
! s1.wait ();
fbout.close();
exit(0);
}
UnderBuf fb;
fb.open(name, ios_base::in);
fb.sgetc();
streamsize n = fb.pub_showmanyc();
while (n > 0)
*************** void test16()
*** 92,101 ****
--- 92,102 ----
fb.sbumpc();
}
fb.close();
+ s1.signal ();
}
int main()
{
test16();
Index: testsuite/27_io/objects/char/7.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/objects/char/7.cc,v
retrieving revision 1.5
diff -c -5 -p -r1.5 7.cc
*** testsuite/27_io/objects/char/7.cc 20 Feb 2004 23:51:07 -0000 1.5
--- testsuite/27_io/objects/char/7.cc 3 Jan 2005 21:29:32 -0000
*************** void test07()
*** 40,69 ****
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
!
int child = fork();
VERIFY( child != -1 );
if (child == 0)
{
filebuf fbout;
- sleep(1);
fbout.open(name, ios_base::in|ios_base::out);
VERIFY ( fbout.is_open() );
cout.rdbuf(&fbout);
fbout.sputc('a');
- sleep(2);
// NB: fbout is *not* destroyed here!
exit(0);
}
filebuf fbin;
fbin.open(name, ios_base::in);
! sleep(2);
filebuf::int_type c = fbin.sbumpc();
VERIFY( c != filebuf::traits_type::eof() );
VERIFY( c == filebuf::traits_type::to_int_type('a') );
fbin.close();
--- 40,69 ----
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
! semaphore s1;
!
int child = fork();
VERIFY( child != -1 );
if (child == 0)
{
filebuf fbout;
fbout.open(name, ios_base::in|ios_base::out);
+ s1.wait ();
VERIFY ( fbout.is_open() );
cout.rdbuf(&fbout);
fbout.sputc('a');
// NB: fbout is *not* destroyed here!
exit(0);
}
filebuf fbin;
fbin.open(name, ios_base::in);
! s1.signal ();
filebuf::int_type c = fbin.sbumpc();
VERIFY( c != filebuf::traits_type::eof() );
VERIFY( c == filebuf::traits_type::to_int_type('a') );
fbin.close();
Index: testsuite/27_io/objects/char/9661-1.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc,v
retrieving revision 1.5
diff -c -5 -p -r1.5 9661-1.cc
*** testsuite/27_io/objects/char/9661-1.cc 20 Feb 2004 23:51:07 -0000 1.5
--- testsuite/27_io/objects/char/9661-1.cc 3 Jan 2005 21:29:32 -0000
*************** void test01()
*** 41,68 ****
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
int child = fork();
VERIFY( child != -1 );
if (child == 0)
{
- sleep(1);
FILE* file = fopen(name, "r+");
VERIFY (file != NULL);
fputs("Whatever\n", file);
fflush(file);
! sleep(2);
fclose(file);
exit(0);
}
freopen(name, "r", stdin);
! sleep(2);
int c1 = fgetc(stdin);
VERIFY( c1 != EOF );
int c2 = cin.rdbuf()->sputbackc('a');
VERIFY( c2 != EOF );
--- 41,69 ----
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
+ semaphore s1, s2;
int child = fork();
VERIFY( child != -1 );
if (child == 0)
{
FILE* file = fopen(name, "r+");
VERIFY (file != NULL);
fputs("Whatever\n", file);
fflush(file);
! s1.signal ();
! s2.wait ();
fclose(file);
exit(0);
}
freopen(name, "r", stdin);
! s1.wait ();
int c1 = fgetc(stdin);
VERIFY( c1 != EOF );
int c2 = cin.rdbuf()->sputbackc('a');
VERIFY( c2 != EOF );
*************** void test01()
*** 76,85 ****
--- 77,87 ----
VERIFY( c4 == 'b' );
int c5 = cin.rdbuf()->sgetc();
VERIFY( c5 != EOF );
VERIFY( c5 == c4 );
+ s2.signal ();
}
int main()
{
test01();
Index: testsuite/27_io/objects/wchar_t/7.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/objects/wchar_t/7.cc,v
retrieving revision 1.3
diff -c -5 -p -r1.3 7.cc
*** testsuite/27_io/objects/wchar_t/7.cc 12 Jan 2004 08:11:08 -0000 1.3
--- testsuite/27_io/objects/wchar_t/7.cc 3 Jan 2005 21:29:32 -0000
*************** void test07()
*** 40,68 ****
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
int child = fork();
VERIFY( child != -1 );
if (child == 0)
{
wfilebuf fbout;
- sleep(1);
fbout.open(name, ios_base::out);
wcout.rdbuf(&fbout);
fbout.sputc(L'a');
- sleep(2);
// NB: fbout is *not* destroyed here!
exit(0);
}
wfilebuf fbin;
fbin.open(name, ios_base::in);
! sleep(2);
wfilebuf::int_type c = fbin.sbumpc();
VERIFY( c != wfilebuf::traits_type::eof() );
VERIFY( c == wfilebuf::traits_type::to_int_type(L'a') );
fbin.close();
--- 40,68 ----
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
+ semaphore s1;
int child = fork();
VERIFY( child != -1 );
if (child == 0)
{
wfilebuf fbout;
fbout.open(name, ios_base::out);
+ s1.wait();
wcout.rdbuf(&fbout);
fbout.sputc(L'a');
// NB: fbout is *not* destroyed here!
exit(0);
}
wfilebuf fbin;
fbin.open(name, ios_base::in);
! s1.signal ();
wfilebuf::int_type c = fbin.sbumpc();
VERIFY( c != wfilebuf::traits_type::eof() );
VERIFY( c == wfilebuf::traits_type::to_int_type(L'a') );
fbin.close();
Index: testsuite/27_io/objects/wchar_t/9661-1.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-1.cc,v
retrieving revision 1.3
diff -c -5 -p -r1.3 9661-1.cc
*** testsuite/27_io/objects/wchar_t/9661-1.cc 12 Jan 2004 08:11:08 -0000 1.3
--- testsuite/27_io/objects/wchar_t/9661-1.cc 3 Jan 2005 21:29:32 -0000
*************** void test01()
*** 41,67 ****
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
!
int child = fork();
VERIFY( child != -1 );
if (child == 0)
{
- sleep(1);
FILE* file = fopen(name, "w");
fputs("Whatever\n", file);
fflush(file);
! sleep(2);
fclose(file);
exit(0);
}
freopen(name, "r", stdin);
! sleep(2);
wint_t c1 = fgetwc(stdin);
VERIFY( c1 != WEOF );
wint_t c2 = wcin.rdbuf()->sputbackc(L'a');
VERIFY( c2 != WEOF );
--- 41,68 ----
signal(SIGPIPE, SIG_IGN);
unlink(name);
try_mkfifo(name, S_IRWXU);
! semaphore s1, s2;
!
int child = fork();
VERIFY( child != -1 );
if (child == 0)
{
FILE* file = fopen(name, "w");
fputs("Whatever\n", file);
fflush(file);
! s1.signal ();
! s2.wait ();
fclose(file);
exit(0);
}
freopen(name, "r", stdin);
! s1.wait ();
wint_t c1 = fgetwc(stdin);
VERIFY( c1 != WEOF );
wint_t c2 = wcin.rdbuf()->sputbackc(L'a');
VERIFY( c2 != WEOF );
*************** void test01()
*** 75,84 ****
--- 76,86 ----
VERIFY( c4 == L'b' );
wint_t c5 = wcin.rdbuf()->sgetc();
VERIFY( c5 != WEOF );
VERIFY( c5 == c4 );
+ s2.signal ();
}
int main()
{
test01();