[PATCH] libstdc++/2913 & libstdc++/4879
Brad Garcia
garsh@attbi.com
Wed Dec 19 07:36:00 GMT 2001
On Wed, 19 Dec 2001, Brad Garcia wrote:
> On Tue, 18 Dec 2001, Benjamin Kosnik wrote:
>
> > There has to be testcase entries for these changes. Please add them and
> > include a ChangeLog entry.
>
> I'm not sure how to write a testcase for this.
Ok, I've figured out a way to test this.
Now my problem is that I'm unfamiliar with libstdc++'s testing
infrastructure, and now that we have a fix for our problem, I can't
spend many more cycles on cleaning it up for the library maintainers.
So if somebody on the list could take the original patch, and figure
out how to add in the following program into the test infrastructure,
I would really appreciate it.
For the changelog entry:
-------------------------------------------------------
2001-12-19 John Fardo <jfardo@laurelnetworks.com>
* include/bits/fstream.tcc (basic_filebuf::close): check for and
propagate errors when flushing & closing underlying file.
(basic_filebuf::_M_really_overflow): Same.
* include/bits/std_fstream.h (basic_filebuf::sync): Same.
-------------------------------------------------------
This program should return 0 when everything works correctly (failbit
should be set). I've confirmed that this program returns 0 when run
against the patched library, and -1 when run against an unpatched one.
Brad Garcia
-------------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main()
{
signal(SIGPIPE, SIG_IGN);
if (0 != mkfifo("xxx", S_IRWXU))
{
std::cerr << "failed to creat fifo" << std::endl;
exit(-1);
}
int fval = fork();
if (fval == -1)
{
std::cerr << "failed to fork" << std::endl;
unlink("xxx");
exit(-1);
}
else if (fval == 0)
{
std::ifstream ifs("xxx");
sleep(1);
ifs.close();
exit(0);
}
std::ofstream ofs("xxx");
sleep(2);
ofs.put('t');
/*
* ISO/IED 14882:1998(E) 27.8.1.10.4
*
* void close();
*
* Effects: Calls rdbuf()->close() and, if that function fails
* (returns a null pointer), calls setstate(failbit)...
*/
ofs.close();
if (!(ofs.rdstate() & std::ios::failbit))
{
std::cerr << "fail bit was not set!" << std::endl;
unlink("xxx");
exit(-1);
}
unlink("xxx");
exit(0);
}
More information about the Libstdc++
mailing list