* [PATCH v2] libstdc++-v3: add more verifications to testsuite
@ 2010-06-26 6:20 Kees Cook
2010-06-26 22:16 ` Paolo Carlini
0 siblings, 1 reply; 7+ messages in thread
From: Kees Cook @ 2010-06-26 6:20 UTC (permalink / raw)
To: gcc-patches
Hello,
Here is a patch that adds additional tests to the libstdc++-v3 test suite.
Ubuntu builds packages with -D_FORTIFY_SOURCE=2, so running the suite
shows a few minor warnings. This cleans them up by providing additional
sanity checks around freopen, fgets, and fwrite, as already done in other
places in the testsuite.
v2:
- Adjusted to not use "!= NULL", as recommended by Paolo Carlini.
Thanks,
-Kees
2010-06-25 Kees Cook <kees.cook@canonical.com>
* testsuite/27_io/ios_base/sync_with_stdio/1.cc: verify freopen.
* testsuite/27_io/objects/wchar_t/9520.cc: Likewise.
* testsuite/27_io/objects/wchar_t/9661-1.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-2.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-4.cc: Likewise.
* testsuite/27_io/objects/wchar_t/11.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-1.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-3.cc: Likewise.
* testsuite/27_io/objects/wchar_t/10.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-5.cc: Likewise.
* testsuite/27_io/objects/char/9661-1.cc: Likewise.
* testsuite/27_io/objects/char/12048-2.cc: Likewise.
* testsuite/27_io/objects/char/12048-4.cc: Likewise.
* testsuite/27_io/objects/char/9.cc: Likewise.
* testsuite/27_io/objects/char/12048-1.cc: Likewise.
* testsuite/27_io/objects/char/12048-3.cc: Likewise.
* testsuite/27_io/objects/char/12048-5.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12077.cc: Likewise.
* testsuite/27_io/basic_filebuf/setbuf/char/12875-2.cc: verify fgets.
* testsuite/27_io/basic_filebuf/underflow/wchar_t/11544-2.cc: verify
fwrite.
* testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/char/1.cc: Likewise.
Index: libstdc++-v3/testsuite/27_io/ios_base/sync_with_stdio/1.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/ios_base/sync_with_stdio/1.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/ios_base/sync_with_stdio/1.cc (working copy)
@@ -41,7 +41,7 @@ void
test01()
{
std::ios_base::sync_with_stdio();
- std::freopen("ios_base_members_static-1.txt", "w", stderr);
+ VERIFY( std::freopen("ios_base_members_static-1.txt", "w", stderr) );
for (int i = 0; i < 2; i++)
{
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc (working copy)
@@ -38,7 +38,7 @@ void test01()
locale loc (locale("de_DE.ISO-8859-15@euro"));
locale::global(loc); // Set locale for stdin
- freopen(name, "r", stdin);
+ VERIFY( freopen(name, "r", stdin) );
wcin.imbue(loc);
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-1.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-1.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-1.cc (working copy)
@@ -67,7 +67,7 @@ bool test01()
exit(0);
}
- freopen(name, "r", stdin);
+ VERIFY( freopen(name, "r", stdin) );
s1.wait();
wint_t c1 = fgetwc(stdin);
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-2.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-2.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-2.cc (working copy)
@@ -23,7 +23,7 @@
void
test01()
{
- std::freopen("cin_unget-1.txt", "r", stdin);
+ VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) );
wchar_t c1;
std::wint_t c2;
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-4.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-4.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-4.cc (working copy)
@@ -23,7 +23,7 @@
void
test01()
{
- std::freopen("cin_unget-1.txt", "r", stdin);
+ VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) );
wchar_t buf[2];
VERIFY( std::wcin.rdbuf()->sgetn(buf, 2) == 2 );
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/11.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/11.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/wchar_t/11.cc (working copy)
@@ -90,7 +90,7 @@ void test11()
};
size_t i_size = wcslen(i_lit);
- freopen(name, "w", stdout);
+ VERIFY( freopen(name, "w", stdout) );
wcout.write(i_lit, i_size);
wcout.flush();
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-1.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-1.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-1.cc (working copy)
@@ -26,7 +26,7 @@
void
test01()
{
- std::freopen("cin_unget-1.txt", "r", stdin);
+ VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) );
wchar_t c1;
wchar_t c2;
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-3.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-3.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-3.cc (working copy)
@@ -27,7 +27,7 @@
void
test01()
{
- std::freopen("cin_unget-1.txt", "r", stdin);
+ VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) );
wchar_t buf[2];
VERIFY( std::wcin.rdbuf()->sgetn(buf, 2) == 2 );
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc (working copy)
@@ -95,7 +95,7 @@ void test10()
VERIFY( n == e_size );
fclose(file);
- freopen(name, "r", stdin);
+ VERIFY( freopen(name, "r", stdin) );
wchar_t* wbuf = new wchar_t[i_size + 10];
wcin.read(wbuf, i_size + 10);
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-5.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-5.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/wchar_t/12048-5.cc (working copy)
@@ -29,7 +29,7 @@
void
test01()
{
- std::freopen("cin_unget-1.txt", "r", stdin);
+ VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) );
wchar_t c1;
std::wint_t c2;
Index: libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc (working copy)
@@ -68,7 +68,7 @@ bool test01()
exit(0);
}
- freopen(name, "r", stdin);
+ VERIFY( freopen(name, "r", stdin) );
s1.wait();
int c1 = fgetc(stdin);
Index: libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc (working copy)
@@ -24,7 +24,7 @@
void
test01()
{
- std::freopen("cin_unget-1.txt", "r", stdin);
+ VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) );
char c1;
int c2;
Index: libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc (working copy)
@@ -24,7 +24,7 @@
void
test01()
{
- std::freopen("cin_unget-1.txt", "r", stdin);
+ VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) );
char buf[2];
VERIFY( std::cin.rdbuf()->sgetn(buf, 2) == 2 );
Index: libstdc++-v3/testsuite/27_io/objects/char/9.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/char/9.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/char/9.cc (working copy)
@@ -34,7 +34,7 @@ void test09()
fputs("abc\n", fout);
fclose(fout);
- freopen(name, "r", stdin);
+ VERIFY( freopen(name, "r", stdin) );
// basic_streambuf::showmanyc returns 0.
VERIFY( 0 == std::cin.rdbuf()->in_avail() );
Index: libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc (working copy)
@@ -28,7 +28,7 @@
void
test01()
{
- std::freopen("cin_unget-1.txt", "r", stdin);
+ VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) );
char c1;
char c2;
Index: libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc (working copy)
@@ -25,7 +25,7 @@
void
test01()
{
- std::freopen("cin_unget-1.txt", "r", stdin);
+ VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) );
char buf[2];
VERIFY( std::cin.rdbuf()->sgetn(buf, 2) == 2 );
Index: libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc (working copy)
@@ -33,7 +33,7 @@
void
test01()
{
- std::freopen("cin_unget-1.txt", "r", stdin);
+ VERIFY( std::freopen("cin_unget-1.txt", "r", stdin) );
char c1;
int c2;
Index: libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/12875-2.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/12875-2.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/12875-2.cc (working copy)
@@ -44,7 +44,7 @@ void test02()
FILE* in = fopen(name, "r");
char str[256];
- fgets(str, 256, in);
+ VERIFY( fgets(str, 256, in) );
VERIFY( !strcmp(str, "Hello, world") );
fclose(in);
}
Index: libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11544-2.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11544-2.cc (revision 161298)
+++ libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/wchar_t/11544-2.cc (working copy)
@@ -161,7 +161,7 @@ void test02()
const char* name = "tmp_11544-2";
FILE* f = fopen(name, "w");
- fwrite("aaaab", 1, 5, f);
+ VERIFY( fwrite("aaaab", 1, 5, f) == 5 );
fclose(f);
wifstream in;
Index: libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc
===================================================================
--- libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc (revision 161298)
+++ libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc (working copy)
@@ -33,7 +33,7 @@ void test01()
const char* name = "stdiobuf-1.txt";
FILE* fout = fopen(name, "w");
- fwrite(c_lit, 1, size, fout);
+ VERIFY( fwrite(c_lit, 1, size, fout) == size );
fclose(fout);
FILE* fin = fopen(name, "r");
Index: libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12077.cc
===================================================================
--- libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12077.cc (revision 161298)
+++ libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12077.cc (working copy)
@@ -64,7 +64,7 @@ void test01()
fputs(str, file);
fclose(file);
- freopen(name, "r", stdin);
+ VERIFY( freopen(name, "r", stdin) );
streamsize n = wcin.rdbuf()->in_avail();
while (n--)
Index: libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/1.cc
===================================================================
--- libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/1.cc (revision 161298)
+++ libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/1.cc (working copy)
@@ -33,7 +33,7 @@ void test01()
const char* name = "stdiobuf-1.txt";
FILE* fout = fopen(name, "w");
- fwrite(c_lit, 1, size, fout);
+ VERIFY( fwrite(c_lit, 1, size, fout) == size );
fclose(fout);
FILE* fin = fopen(name, "r");
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] libstdc++-v3: add more verifications to testsuite
2010-06-26 6:20 [PATCH v2] libstdc++-v3: add more verifications to testsuite Kees Cook
@ 2010-06-26 22:16 ` Paolo Carlini
2010-06-26 22:42 ` Matthias Klose
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Carlini @ 2010-06-26 22:16 UTC (permalink / raw)
To: Kees Cook; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 641 bytes --]
On 06/26/2010 12:50 AM, Kees Cook wrote:
> Hello,
>
> Here is a patch that adds additional tests to the libstdc++-v3 test suite.
> Ubuntu builds packages with -D_FORTIFY_SOURCE=2, so running the suite
> shows a few minor warnings. This cleans them up by providing additional
> sanity checks around freopen, fgets, and fwrite, as already done in other
> places in the testsuite.
>
> v2:
> - Adjusted to not use "!= NULL", as recommended by Paolo Carlini.
>
Thanks, applied to mainline together with the below small tweak to
testsuite_hooks.h (otherwise testsuite/27_io/objects/char/9661-1.cc
spuriously fails)
Paolo.
/////////////////
[-- Attachment #2: patchlet --]
[-- Type: text/plain, Size: 773 bytes --]
Index: testsuite/util/testsuite_hooks.h
===================================================================
--- testsuite/util/testsuite_hooks.h (revision 161439)
+++ testsuite/util/testsuite_hooks.h (working copy)
@@ -1,7 +1,8 @@
// -*- C++ -*-
// Utility subroutines for the C++ library testsuite.
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+// 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -59,7 +60,7 @@
# include <cassert>
# define VERIFY(fn) assert(fn)
#else
-# define VERIFY(fn) test &= (fn)
+# define VERIFY(fn) test &= bool(fn)
#endif
#ifdef _GLIBCXX_HAVE_UNISTD_H
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] libstdc++-v3: add more verifications to testsuite
2010-06-26 22:16 ` Paolo Carlini
@ 2010-06-26 22:42 ` Matthias Klose
2010-06-27 7:30 ` Paolo Carlini
0 siblings, 1 reply; 7+ messages in thread
From: Matthias Klose @ 2010-06-26 22:42 UTC (permalink / raw)
To: Paolo Carlini; +Cc: Kees Cook, gcc-patches
On 26.06.2010 22:14, Paolo Carlini wrote:
> On 06/26/2010 12:50 AM, Kees Cook wrote:
>> Hello,
>>
>> Here is a patch that adds additional tests to the libstdc++-v3 test suite.
>> Ubuntu builds packages with -D_FORTIFY_SOURCE=2, so running the suite
>> shows a few minor warnings. This cleans them up by providing additional
>> sanity checks around freopen, fgets, and fwrite, as already done in other
>> places in the testsuite.
>>
>> v2:
>> - Adjusted to not use "!= NULL", as recommended by Paolo Carlini.
>>
> Thanks, applied to mainline together with the below small tweak to
> testsuite_hooks.h (otherwise testsuite/27_io/objects/char/9661-1.cc
> spuriously fails)
ok to apply to the 4.4 and 4.5 branches as well?
Matthias
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] libstdc++-v3: add more verifications to testsuite
2010-06-26 22:42 ` Matthias Klose
@ 2010-06-27 7:30 ` Paolo Carlini
2010-06-27 7:55 ` Richard Guenther
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Carlini @ 2010-06-27 7:30 UTC (permalink / raw)
To: Matthias Klose; +Cc: Kees Cook, gcc-patches
On 06/26/2010 11:49 PM, Matthias Klose wrote:
>> Thanks, applied to mainline together with the below small tweak to
>> testsuite_hooks.h (otherwise testsuite/27_io/objects/char/9661-1.cc
>> spuriously fails)
>
> ok to apply to the 4.4 and 4.5 branches as well?
Seems more urgent reducing the huge testcases in 44039 and 44040.
Paolo.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] libstdc++-v3: add more verifications to testsuite
2010-06-27 7:30 ` Paolo Carlini
@ 2010-06-27 7:55 ` Richard Guenther
2010-06-27 8:01 ` Paolo Carlini
0 siblings, 1 reply; 7+ messages in thread
From: Richard Guenther @ 2010-06-27 7:55 UTC (permalink / raw)
To: Paolo Carlini; +Cc: Matthias Klose, Kees Cook, gcc-patches
On Sun, Jun 27, 2010 at 12:51 AM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
> On 06/26/2010 11:49 PM, Matthias Klose wrote:
>>> Thanks, applied to mainline together with the below small tweak to
>>> testsuite_hooks.h (otherwise testsuite/27_io/objects/char/9661-1.cc
>>> spuriously fails)
>>
>> ok to apply to the 4.4 and 4.5 branches as well?
> Seems more urgent reducing the huge testcases in 44039 and 44040.
Why don't you do it then?
Richard.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] libstdc++-v3: add more verifications to testsuite
2010-06-27 7:55 ` Richard Guenther
@ 2010-06-27 8:01 ` Paolo Carlini
2010-06-27 13:11 ` Richard Guenther
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Carlini @ 2010-06-27 8:01 UTC (permalink / raw)
To: Richard Guenther; +Cc: Matthias Klose, Kees Cook, gcc-patches
On 06/27/2010 01:06 AM, Richard Guenther wrote:
> Why don't you do it then?
Sure, I do 44039 and you 44040, ok?
Paolo.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] libstdc++-v3: add more verifications to testsuite
2010-06-27 8:01 ` Paolo Carlini
@ 2010-06-27 13:11 ` Richard Guenther
0 siblings, 0 replies; 7+ messages in thread
From: Richard Guenther @ 2010-06-27 13:11 UTC (permalink / raw)
To: Paolo Carlini; +Cc: Matthias Klose, Kees Cook, gcc-patches
On Sun, Jun 27, 2010 at 2:03 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> On 06/27/2010 01:06 AM, Richard Guenther wrote:
>> Why don't you do it then?
> Sure, I do 44039 and you 44040, ok?
Ok.
Richard.
> Paolo.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-06-27 8:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-26 6:20 [PATCH v2] libstdc++-v3: add more verifications to testsuite Kees Cook
2010-06-26 22:16 ` Paolo Carlini
2010-06-26 22:42 ` Matthias Klose
2010-06-27 7:30 ` Paolo Carlini
2010-06-27 7:55 ` Richard Guenther
2010-06-27 8:01 ` Paolo Carlini
2010-06-27 13:11 ` Richard Guenther
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).