Allow large file tests to run by default on more platforms.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@63301 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Michael Wetherell
2010-01-28 21:38:27 +00:00
parent 1132633751
commit 0afb0efe19

View File

@@ -16,8 +16,8 @@
// //
// test --verbose largeFile // test --verbose largeFile
// //
// On systems supporting sparse files they may also be registered in the // On systems supporting sparse files they will also be registered in the
// Streams subsuite. // Streams subsuite so that they run by default.
// //
// For compilers that support precompilation, includes "wx/wx.h". // For compilers that support precompilation, includes "wx/wx.h".
@@ -292,10 +292,6 @@ CppUnit::Test *largeFile::suite()
// Ideally these tests will be part of the default suite so that regressions // Ideally these tests will be part of the default suite so that regressions
// are picked up. However this is only possible when sparse files are // are picked up. However this is only possible when sparse files are
// supported otherwise the tests require too much disk space. // supported otherwise the tests require too much disk space.
//
// On unix, most filesystems support sparse files, though not all. So for now
// I'm not assuming sparse file support on unix. On Windows it's possible to
// test, and sparse files should be available on Win 5+ with NTFS.
#ifdef __WXMSW__ #ifdef __WXMSW__
@@ -369,12 +365,17 @@ void MakeSparse(const wxString& path, int fd)
volumeFlags &= ~FILE_SUPPORTS_SPARSE_FILES; volumeFlags &= ~FILE_SUPPORTS_SPARSE_FILES;
} }
// return the suite if sparse files are supported, otherwise return NULL
//
CppUnit::Test* GetlargeFileSuite() CppUnit::Test* GetlargeFileSuite()
{ {
if (!volumeInfoInit) { if (!volumeInfoInit) {
wxFile file; wxString path;
wxString path = wxFileName::CreateTempFileName(_T("wxlfs-"), &file); {
MakeSparse(path, file.fd()); wxFile file;
path = wxFileName::CreateTempFileName(wxT("wxlfs-"), &file);
MakeSparse(path, file.fd());
}
wxRemoveFile(path); wxRemoveFile(path);
} }
@@ -389,7 +390,36 @@ CppUnit::Test* GetlargeFileSuite()
bool IsFAT(const wxString& WXUNUSED(path)) { return false; } bool IsFAT(const wxString& WXUNUSED(path)) { return false; }
void MakeSparse(const wxString& WXUNUSED(path), int WXUNUSED(fd)) { } void MakeSparse(const wxString& WXUNUSED(path), int WXUNUSED(fd)) { }
CppUnit::Test* GetlargeFileSuite() { return NULL; } // return the suite if sparse files are supported, otherwise return NULL
//
CppUnit::Test* GetlargeFileSuite()
{
wxString path;
struct stat st1, st2;
memset(&st1, 0, sizeof(st1));
memset(&st2, 0, sizeof(st2));
{
wxFile file;
path = wxFileName::CreateTempFileName(wxT("wxlfs-"), &file);
fstat(file.fd(), &st1);
file.Seek(st1.st_blksize);
file.Write("x", 1);
fstat(file.fd(), &st1);
file.Seek(0);
file.Write("x", 1);
fstat(file.fd(), &st2);
}
wxRemoveFile(path);
if (st1.st_blocks != st2.st_blocks)
return largeFile::suite();
else
return NULL;
}
#endif // __WXMSW__ #endif // __WXMSW__