Fixes to HTTP repo tests on Windows.

Large alloca fails, and SGFIle dtor doesn't close the handle,
which breaks _wunlink on Windows :(
This commit is contained in:
James Turner 2018-07-18 07:20:18 +01:00
parent 0e9e5f77cc
commit 3dfce43de2
3 changed files with 11 additions and 3 deletions

View File

@ -749,6 +749,10 @@ HTTPRepository::failure() const
code = HTTPRepository::REPO_ERROR_CANCELLED; code = HTTPRepository::REPO_ERROR_CANCELLED;
} }
if (file) {
file->close();
}
file.reset(); file.reset();
if (pathInRepo.exists()) { if (pathInRepo.exists()) {
pathInRepo.remove(); pathInRepo.remove();

View File

@ -62,7 +62,7 @@ public:
SGFile( int existingFd ); SGFile( int existingFd );
/** Destructor */ /** Destructor */
~SGFile(); virtual ~SGFile();
// open the file based on specified direction // open the file based on specified direction
bool open( const SGProtocolDir dir ); bool open( const SGProtocolDir dir );

View File

@ -309,7 +309,8 @@ std::string test_computeHashForPath(const SGPath& p)
return std::string(); return std::string();
sha1nfo info; sha1nfo info;
sha1_init(&info); sha1_init(&info);
char* buf = static_cast<char*>(alloca(1024 * 1024)); char* buf = static_cast<char*>(malloc(1024 * 1024));
assert(buf);
size_t readLen; size_t readLen;
SGBinaryFile f(p); SGBinaryFile f(p);
@ -319,6 +320,9 @@ std::string test_computeHashForPath(const SGPath& p)
sha1_write(&info, buf, readLen); sha1_write(&info, buf, readLen);
} }
f.close();
free(buf);
std::string hashBytes((char*) sha1_result(&info), HASH_LENGTH); std::string hashBytes((char*) sha1_result(&info), HASH_LENGTH);
return strutils::encodeHex(hashBytes); return strutils::encodeHex(hashBytes);
} }
@ -725,7 +729,7 @@ void testCopyInstalledChildren(HTTP::Client* cl)
verifyRequestCount("dirJ/fileJC", 1); verifyRequestCount("dirJ/fileJC", 1);
verifyRequestCount("dirJ/fileJD", 1); verifyRequestCount("dirJ/fileJD", 1);
std::cout << "Copy installed children" << std::endl; std::cout << "passed Copy installed children" << std::endl;
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])