Commit 9339bda8 by Paolo Carlini Committed by Paolo Carlini

9661-1.cc: Avoid leaking the semaphores if a VERIFY fails.

2006-05-19  Paolo Carlini  <pcarlini@suse.de>

	* testsuite/27_io/objects/wchar_t/9661-1.cc: Avoid leaking the
	semaphores if a VERIFY fails.
	* testsuite/27_io/objects/wchar_t/7.cc: Likewise.
	* testsuite/27_io/objects/char/9661-1.cc: Likewise.
	* testsuite/27_io/objects/char/7.cc: Likewise.
	* testsuite/27_io/basic_filebuf/seekoff/char/26777.cc: Likewise.
	* testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc: Likewise.
	* testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc: Likewise.
	* testsuite/27_io/basic_filebuf/close/char/4879.cc: Likewise.
	* testsuite/27_io/basic_filebuf/close/char/9964.cc: Likewise.
	* testsuite/27_io/basic_filebuf/underflow/char/10097.cc: Likewise.

From-SVN: r113916
parent 23249ac4
2006-05-19 Paolo Carlini <pcarlini@suse.de>
* testsuite/27_io/objects/wchar_t/9661-1.cc: Avoid leaking the
semaphores if a VERIFY fails.
* testsuite/27_io/objects/wchar_t/7.cc: Likewise.
* testsuite/27_io/objects/char/9661-1.cc: Likewise.
* testsuite/27_io/objects/char/7.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/26777.cc: Likewise.
* testsuite/27_io/basic_filebuf/imbue/wchar_t/14975-2.cc: Likewise.
* testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc: Likewise.
* testsuite/27_io/basic_filebuf/close/char/4879.cc: Likewise.
* testsuite/27_io/basic_filebuf/close/char/9964.cc: Likewise.
* testsuite/27_io/basic_filebuf/underflow/char/10097.cc: Likewise.
2006-05-17 Paolo Carlini <pcarlini@suse.de> 2006-05-17 Paolo Carlini <pcarlini@suse.de>
* include/tr1/hashtable (hashtable<>::m_find): Remove; update callers. * include/tr1/hashtable (hashtable<>::m_find): Remove; update callers.
......
// { dg-require-fork "" } // { dg-require-fork "" }
// { dg-require-mkfifo "" } // { dg-require-mkfifo "" }
// Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -33,11 +34,15 @@ ...@@ -33,11 +34,15 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
// No asserts, avoid leaking the semaphores if a VERIFY fails.
#undef _GLIBCXX_ASSERT
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// libstdc++/2913, libstdc++/4879 // libstdc++/2913, libstdc++/4879
// John Fardo <jfardo@laurelnetworks.com>, Brad Garcia <garsh@attbi.com> // John Fardo <jfardo@laurelnetworks.com>, Brad Garcia <garsh@attbi.com>
void bool
test_04() test_04()
{ {
using namespace __gnu_test; using namespace __gnu_test;
...@@ -60,20 +65,20 @@ test_04() ...@@ -60,20 +65,20 @@ test_04()
{ {
std::cerr << "failed to fork" << std::endl; std::cerr << "failed to fork" << std::endl;
unlink(name); unlink(name);
exit(-1); return false;
} }
else if (fval == 0) else if (fval == 0)
{ {
std::ifstream ifs(name); std::ifstream ifs(name);
s1.wait (); s1.wait();
ifs.close(); ifs.close();
s2.signal (); s2.signal();
exit(0); exit(0);
} }
std::ofstream ofs(name); std::ofstream ofs(name);
s1.signal (); s1.signal();
s2.wait (); s2.wait();
ofs.put('t'); ofs.put('t');
/* /*
...@@ -89,18 +94,15 @@ test_04() ...@@ -89,18 +94,15 @@ test_04()
{ {
test = false; test = false;
VERIFY( test ); VERIFY( test );
unlink(name);
exit(-1);
} }
unlink(name); unlink(name);
return test;
} }
int int
main() main()
{ {
test_04(); return !test_04();
return 0;
} }
// { dg-require-fork "" } // { dg-require-fork "" }
// { dg-require-mkfifo "" } // { dg-require-mkfifo "" }
// Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -32,10 +33,14 @@ ...@@ -32,10 +33,14 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
// No asserts, avoid leaking the semaphores if a VERIFY fails.
#undef _GLIBCXX_ASSERT
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// libstdc++/9964 // libstdc++/9964
void test_07() bool test_07()
{ {
using namespace std; using namespace std;
using namespace __gnu_test; using namespace __gnu_test;
...@@ -56,9 +61,9 @@ void test_07() ...@@ -56,9 +61,9 @@ void test_07()
{ {
filebuf fbin; filebuf fbin;
fbin.open(name, ios_base::in); fbin.open(name, ios_base::in);
s1.wait (); s1.wait();
fbin.close(); fbin.close();
s2.signal (); s2.signal();
exit(0); exit(0);
} }
...@@ -66,18 +71,19 @@ void test_07() ...@@ -66,18 +71,19 @@ void test_07()
filebuf* ret = fb.open(name, ios_base::in | ios_base::out); filebuf* ret = fb.open(name, ios_base::in | ios_base::out);
VERIFY( ret != NULL ); VERIFY( ret != NULL );
VERIFY( fb.is_open() ); VERIFY( fb.is_open() );
s1.signal (); s1.signal();
s2.wait (); s2.wait();
fb.sputc('a'); fb.sputc('a');
ret = fb.close(); ret = fb.close();
VERIFY( ret != NULL ); VERIFY( ret != NULL );
VERIFY( !fb.is_open() ); VERIFY( !fb.is_open() );
return test;
} }
int int
main() main()
{ {
test_07(); return !test_07();
return 0;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// { dg-require-fork "" } // { dg-require-fork "" }
// { dg-require-mkfifo "" } // { dg-require-mkfifo "" }
// Copyright (C) 2003, 2005 Free Software Foundation, Inc. // Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -28,10 +28,13 @@ ...@@ -28,10 +28,13 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
// No asserts, avoid leaking the semaphores if a VERIFY fails.
#undef _GLIBCXX_ASSERT
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// libstdc++/13171 // libstdc++/13171
void test01() bool test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
using namespace std; using namespace std;
...@@ -52,8 +55,8 @@ void test01() ...@@ -52,8 +55,8 @@ void test01()
fb.open(name, ios_base::out); fb.open(name, ios_base::out);
fb.sputc('S'); fb.sputc('S');
fb.pubsync(); fb.pubsync();
s1.signal (); s1.signal();
s2.wait (); s2.wait();
fb.close(); fb.close();
exit(0); exit(0);
} }
...@@ -61,17 +64,18 @@ void test01() ...@@ -61,17 +64,18 @@ void test01()
filebuf fb; filebuf fb;
fb.pubimbue(loc_fr); fb.pubimbue(loc_fr);
fb.open(name, ios_base::in); fb.open(name, ios_base::in);
s1.wait (); s1.wait();
VERIFY( fb.is_open() ); VERIFY( fb.is_open() );
fb.pubimbue(loc_en); fb.pubimbue(loc_en);
filebuf::int_type c = fb.sgetc(); filebuf::int_type c = fb.sgetc();
fb.close(); fb.close();
VERIFY( c == 'S' ); VERIFY( c == 'S' );
s2.signal (); s2.signal();
return test;
} }
int main() int main()
{ {
test01(); return !test01();
return 0;
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// 2004-04-16 Petur Runolfsson <peturr02@ru.is> // 2004-04-16 Petur Runolfsson <peturr02@ru.is>
// Copyright (C) 2004, 2005 Free Software Foundation, Inc. // Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -29,10 +29,14 @@ ...@@ -29,10 +29,14 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
// No asserts, avoid leaking the semaphore if a VERIFY fails.
#undef _GLIBCXX_ASSERT
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// libstdc++/14975 // libstdc++/14975
void test01() bool test01()
{ {
using namespace std; using namespace std;
using namespace __gnu_test; using namespace __gnu_test;
...@@ -57,7 +61,7 @@ void test01() ...@@ -57,7 +61,7 @@ void test01()
filebuf fbin; filebuf fbin;
fbin.open(name, ios_base::in); fbin.open(name, ios_base::in);
} }
s1.signal (); s1.signal();
exit(0); exit(0);
} }
...@@ -67,7 +71,7 @@ void test01() ...@@ -67,7 +71,7 @@ void test01()
VERIFY( ret != NULL ); VERIFY( ret != NULL );
VERIFY( fb.is_open() ); VERIFY( fb.is_open() );
s1.wait (); s1.wait();
try try
{ {
...@@ -80,10 +84,11 @@ void test01() ...@@ -80,10 +84,11 @@ void test01()
catch (std::exception&) catch (std::exception&)
{ {
} }
return test;
} }
int main() int main()
{ {
test01(); return !test01();
return 0;
} }
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA. // USA.
// No asserts, avoid leaking the semaphores if a VERIFY fails.
#undef _GLIBCXX_ASSERT
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
...@@ -31,7 +34,7 @@ ...@@ -31,7 +34,7 @@
#include <sys/stat.h> #include <sys/stat.h>
// libstdc++/26777 // libstdc++/26777
void test01() bool test01()
{ {
using namespace std; using namespace std;
using namespace __gnu_test; using namespace __gnu_test;
...@@ -77,10 +80,11 @@ void test01() ...@@ -77,10 +80,11 @@ void test01()
fbin.close(); fbin.close();
VERIFY( oss.str() == "Whatever" ); VERIFY( oss.str() == "Whatever" );
return test;
} }
int main() int main()
{ {
test01(); return !test01();
return 0;
} }
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
// No asserts, avoid leaking the semaphores if a VERIFY fails.
#undef _GLIBCXX_ASSERT
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
class UnderBuf : public std::filebuf class UnderBuf : public std::filebuf
...@@ -46,7 +50,7 @@ public: ...@@ -46,7 +50,7 @@ public:
// libstdc++/10097 // libstdc++/10097
// filebuf::underflow drops characters. // filebuf::underflow drops characters.
void test16() bool test16()
{ {
using namespace std; using namespace std;
using namespace __gnu_test; using namespace __gnu_test;
...@@ -84,7 +88,7 @@ void test16() ...@@ -84,7 +88,7 @@ void test16()
UnderBuf fb; UnderBuf fb;
fb.open(name, ios_base::in); fb.open(name, ios_base::in);
fb.sgetc(); fb.sgetc();
streamsize n = fb.pub_showmanyc(); streamsize n = fb.pub_showmanyc();
...@@ -101,10 +105,11 @@ void test16() ...@@ -101,10 +105,11 @@ void test16()
fb.close(); fb.close();
s1.signal(); s1.signal();
s2.wait(); s2.wait();
return test;
} }
int main() int main()
{ {
test16(); return !test16();
return 0;
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// 2003-04-26 Petur Runolfsson <peturr02@ru.is> // 2003-04-26 Petur Runolfsson <peturr02@ru.is>
// Copyright (C) 2003, 2005 Free Software Foundation, Inc. // Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -30,10 +30,14 @@ ...@@ -30,10 +30,14 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
// No asserts, avoid leaking the semaphore if a VERIFY fails.
#undef _GLIBCXX_ASSERT
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// Check that cout.flush() is called when last ios_base::Init is destroyed. // Check that cout.flush() is called when last ios_base::Init is destroyed.
void test07() bool test07()
{ {
using namespace std; using namespace std;
using namespace __gnu_test; using namespace __gnu_test;
...@@ -54,8 +58,8 @@ void test07() ...@@ -54,8 +58,8 @@ void test07()
{ {
filebuf fbout; filebuf fbout;
fbout.open(name, ios_base::in|ios_base::out); fbout.open(name, ios_base::in|ios_base::out);
s1.wait (); VERIFY( fbout.is_open() );
VERIFY ( fbout.is_open() ); s1.wait();
cout.rdbuf(&fbout); cout.rdbuf(&fbout);
fbout.sputc('a'); fbout.sputc('a');
// NB: fbout is *not* destroyed here! // NB: fbout is *not* destroyed here!
...@@ -64,17 +68,18 @@ void test07() ...@@ -64,17 +68,18 @@ void test07()
filebuf fbin; filebuf fbin;
fbin.open(name, ios_base::in); fbin.open(name, ios_base::in);
s1.signal (); s1.signal();
filebuf::int_type c = fbin.sbumpc(); filebuf::int_type c = fbin.sbumpc();
VERIFY( c != filebuf::traits_type::eof() ); VERIFY( c != filebuf::traits_type::eof() );
VERIFY( c == filebuf::traits_type::to_int_type('a') ); VERIFY( c == filebuf::traits_type::to_int_type('a') );
fbin.close(); fbin.close();
return test;
} }
int int
main() main()
{ {
test07(); return !test07();
return 0;
} }
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA. // USA.
// No asserts, avoid leaking the semaphores if a VERIFY fails.
#undef _GLIBCXX_ASSERT
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
...@@ -33,7 +36,7 @@ ...@@ -33,7 +36,7 @@
// Check that cin.rdbuf()->sputbackc() puts characters back to stdin. // Check that cin.rdbuf()->sputbackc() puts characters back to stdin.
// If cin.rdbuf() is a filebuf, this succeeds when stdin is a regular // If cin.rdbuf() is a filebuf, this succeeds when stdin is a regular
// file, but fails otherwise, hence the named fifo. // file, but fails otherwise, hence the named fifo.
void test01() bool test01()
{ {
using namespace std; using namespace std;
using namespace __gnu_test; using namespace __gnu_test;
...@@ -54,7 +57,7 @@ void test01() ...@@ -54,7 +57,7 @@ void test01()
if (child == 0) if (child == 0)
{ {
FILE* file = fopen(name, "r+"); FILE* file = fopen(name, "r+");
VERIFY (file != NULL); VERIFY( file != NULL );
fputs("Whatever\n", file); fputs("Whatever\n", file);
fflush(file); fflush(file);
s1.signal(); s1.signal();
...@@ -85,10 +88,11 @@ void test01() ...@@ -85,10 +88,11 @@ void test01()
VERIFY( c5 == c4 ); VERIFY( c5 == c4 );
s2.signal(); s2.signal();
s1.wait(); s1.wait();
return test;
} }
int main() int main()
{ {
test01(); return !test01();
return 0;
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// 2003-05-01 Petur Runolfsson <peturr02@ru.is> // 2003-05-01 Petur Runolfsson <peturr02@ru.is>
// Copyright (C) 2003, 2005 Free Software Foundation, Inc. // Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -30,10 +30,14 @@ ...@@ -30,10 +30,14 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
// No asserts, avoid leaking the semaphore if a VERIFY fails.
#undef _GLIBCXX_ASSERT
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// Check that wcout.flush() is called when last ios_base::Init is destroyed. // Check that wcout.flush() is called when last ios_base::Init is destroyed.
void test07() bool test07()
{ {
using namespace std; using namespace std;
using namespace __gnu_test; using namespace __gnu_test;
...@@ -46,7 +50,7 @@ void test07() ...@@ -46,7 +50,7 @@ void test07()
unlink(name); unlink(name);
mkfifo(name, S_IRWXU); mkfifo(name, S_IRWXU);
semaphore s1; semaphore s1;
int child = fork(); int child = fork();
VERIFY( child != -1 ); VERIFY( child != -1 );
...@@ -63,17 +67,18 @@ void test07() ...@@ -63,17 +67,18 @@ void test07()
wfilebuf fbin; wfilebuf fbin;
fbin.open(name, ios_base::in); fbin.open(name, ios_base::in);
s1.signal (); s1.signal();
wfilebuf::int_type c = fbin.sbumpc(); wfilebuf::int_type c = fbin.sbumpc();
VERIFY( c != wfilebuf::traits_type::eof() ); VERIFY( c != wfilebuf::traits_type::eof() );
VERIFY( c == wfilebuf::traits_type::to_int_type(L'a') ); VERIFY( c == wfilebuf::traits_type::to_int_type(L'a') );
fbin.close(); fbin.close();
return test;
} }
int int
main() main()
{ {
test07(); return !test07();
return 0;
} }
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA. // USA.
// No asserts, avoid leaking the semaphores if a VERIFY fails.
#undef _GLIBCXX_ASSERT
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
...@@ -33,7 +36,7 @@ ...@@ -33,7 +36,7 @@
// Check that wcin.rdbuf()->sputbackc() puts characters back to stdin. // Check that wcin.rdbuf()->sputbackc() puts characters back to stdin.
// If wcin.rdbuf() is a filebuf, this succeeds when stdin is a regular // If wcin.rdbuf() is a filebuf, this succeeds when stdin is a regular
// file, but fails otherwise, hence the named fifo. // file, but fails otherwise, hence the named fifo.
void test01() bool test01()
{ {
using namespace std; using namespace std;
using namespace __gnu_test; using namespace __gnu_test;
...@@ -83,11 +86,12 @@ void test01() ...@@ -83,11 +86,12 @@ void test01()
VERIFY( c5 != WEOF ); VERIFY( c5 != WEOF );
VERIFY( c5 == c4 ); VERIFY( c5 == c4 );
s2.signal(); s2.signal();
s1.wait(); s1.wait();
return test;
} }
int main() int main()
{ {
test01(); return !test01();
return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment