From 6f9f7e02a8217ae94a5c37f8bcaf9d93dea0b713 Mon Sep 17 00:00:00 2001 From: Kyle Ambroff-Kao Date: Sat, 25 Apr 2020 18:14:34 -0700 Subject: [PATCH] tests/HttpTest: Fix build on x86_gcc2 * std::istreambuf_iterator template isn't available until C++11. * std::vector::cbegin() is not available * Add missing include of errno.h Change-Id: Ice344f6b0f93bf72d9120674607878c4c3e8ef54 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2515 Reviewed-by: waddlesplash --- src/tests/kits/net/service/HttpTest.cpp | 17 ++++++++++++----- src/tests/kits/net/service/TestServer.cpp | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/tests/kits/net/service/HttpTest.cpp b/src/tests/kits/net/service/HttpTest.cpp index 1dc17dfd07..f27c80fe04 100644 --- a/src/tests/kits/net/service/HttpTest.cpp +++ b/src/tests/kits/net/service/HttpTest.cpp @@ -318,11 +318,18 @@ HttpTest::UploadTest() // the server received it. std::string fileContents; { - std::ifstream inputStream(testFilePath); - CPPUNIT_ASSERT(inputStream.is_open()); - fileContents = std::string( - std::istreambuf_iterator(inputStream), - std::istreambuf_iterator()); + std::ifstream inputStream( + testFilePath.c_str(), + std::ios::in | std::ios::binary); + CPPUNIT_ASSERT(inputStream); + + inputStream.seekg(0, std::ios::end); + fileContents.resize(inputStream.tellg()); + + inputStream.seekg(0, std::ios::beg); + inputStream.read(&fileContents[0], fileContents.size()); + inputStream.close(); + CPPUNIT_ASSERT(!fileContents.empty()); } diff --git a/src/tests/kits/net/service/TestServer.cpp b/src/tests/kits/net/service/TestServer.cpp index 240c6972f6..d2551f962a 100644 --- a/src/tests/kits/net/service/TestServer.cpp +++ b/src/tests/kits/net/service/TestServer.cpp @@ -7,6 +7,7 @@ */ #include "TestServer.h" +#include #include #include #include @@ -208,7 +209,7 @@ status_t ChildProcess::Start(const std::vector& args) // If we reach this point we failed to load the Python image. std::ostringstream ostr; - for (std::vector::const_iterator iter = args.cbegin(); + for (std::vector::const_iterator iter = args.begin(); iter != args.end(); ++iter) { ostr << " " << *iter;