X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/224d978ffb483f93864f8bf9a5cd61b1425a7fd5..f155075229d771430f0793700f5048ad4be00e9d:/tests/streams/largefile.cpp diff --git a/tests/streams/largefile.cpp b/tests/streams/largefile.cpp index 8f35746d7d..9c8e0caf86 100644 --- a/tests/streams/largefile.cpp +++ b/tests/streams/largefile.cpp @@ -4,7 +4,7 @@ // Author: Mike Wetherell // RCS-ID: $Id$ // Copyright: (c) 2004 Mike Wetherell -// Licence: wxWidgets licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // @@ -16,8 +16,8 @@ // // test --verbose largeFile // -// On systems supporting sparse files they may also be registered in the -// Streams subsuite. +// On systems supporting sparse files they will also be registered in the +// Streams subsuite so that they run by default. // // For compilers that support precompilation, includes "wx/wx.h". @@ -35,7 +35,7 @@ #include "wx/filename.h" #include "wx/wfstream.h" -#ifdef __WXMSW__ +#ifdef __WINDOWS__ #include "wx/msw/wrapwin.h" #ifdef __VISUALC__ // 'nonstandard extension used : nameless struct/union' occurs inside @@ -220,7 +220,7 @@ protected: wxInputStream *LargeFileTest_wxFile::MakeInStream(const wxString& name) const { auto_ptr in(new wxFileInputStream(name)); - CPPUNIT_ASSERT(in->Ok()); + CPPUNIT_ASSERT(in->IsOk()); return in.release(); } @@ -252,7 +252,7 @@ protected: wxInputStream *LargeFileTest_wxFFile::MakeInStream(const wxString& name) const { auto_ptr in(new wxFFileInputStream(name)); - CPPUNIT_ASSERT(in->Ok()); + CPPUNIT_ASSERT(in->IsOk()); return in.release(); } @@ -304,12 +304,8 @@ CppUnit::Test *largeFile::suite() // 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 // 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 __WINDOWS__ #ifndef FILE_SUPPORTS_SPARSE_FILES #define FILE_SUPPORTS_SPARSE_FILES 0x00000040 @@ -384,12 +380,17 @@ void MakeSparse(const wxString& path, int fd) volumeFlags &= ~FILE_SUPPORTS_SPARSE_FILES; } +// return the suite if sparse files are supported, otherwise return NULL +// CppUnit::Test* GetlargeFileSuite() { if (!volumeInfoInit) { - wxFile file; - wxString path = wxFileName::CreateTempFileName(wxT("wxlfs-"), &file); - MakeSparse(path, file.fd()); + wxString path; + { + wxFile file; + path = wxFileName::CreateTempFileName(wxT("wxlfs-"), &file); + MakeSparse(path, file.fd()); + } wxRemoveFile(path); } @@ -399,14 +400,43 @@ CppUnit::Test* GetlargeFileSuite() return NULL; } -#else // __WXMSW__ +#else // __WINDOWS__ bool IsFAT(const wxString& WXUNUSED(path)) { return false; } 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 // __WINDOWS__ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(largeFile, "largeFile"); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(largeFile, "Streams.largeFile");