summaryrefslogtreecommitdiffstats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-07-01 17:50:07 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-01 17:50:08 +0000
commitb46ff2c3c24c9b45457db80494056b7792ae0edb (patch)
treea8ee97d8f296abb9ce3729cf21916487bc63c663 /compiler
parentf801a6a69bac4a767c3b11da78145cc11b9ef7ac (diff)
parentc4e75e2d4319bd57461aed6d138de23032e511d5 (diff)
downloadart-b46ff2c3c24c9b45457db80494056b7792ae0edb.zip
art-b46ff2c3c24c9b45457db80494056b7792ae0edb.tar.gz
art-b46ff2c3c24c9b45457db80494056b7792ae0edb.tar.bz2
Merge "ART: Fix data loss when symbolizing oat files." into mnc-dev
Diffstat (limited to 'compiler')
-rw-r--r--compiler/buffered_output_stream.h1
-rw-r--r--compiler/output_stream_test.cc15
2 files changed, 10 insertions, 6 deletions
diff --git a/compiler/buffered_output_stream.h b/compiler/buffered_output_stream.h
index bbc49df..15fc033 100644
--- a/compiler/buffered_output_stream.h
+++ b/compiler/buffered_output_stream.h
@@ -28,6 +28,7 @@ class BufferedOutputStream FINAL : public OutputStream {
explicit BufferedOutputStream(OutputStream* out);
virtual ~BufferedOutputStream() {
+ Flush();
delete out_;
}
diff --git a/compiler/output_stream_test.cc b/compiler/output_stream_test.cc
index fbc9d0d..6104ccd 100644
--- a/compiler/output_stream_test.cc
+++ b/compiler/output_stream_test.cc
@@ -47,11 +47,12 @@ class OutputStreamTest : public CommonRuntimeTest {
CheckOffset(6);
EXPECT_TRUE(output_stream_->WriteFully(buf, 4));
CheckOffset(10);
+ EXPECT_TRUE(output_stream_->WriteFully(buf, 6));
}
void CheckTestOutput(const std::vector<uint8_t>& actual) {
uint8_t expected[] = {
- 0, 0, 1, 2, 0, 0, 1, 2, 3, 4
+ 0, 0, 1, 2, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6
};
EXPECT_EQ(sizeof(expected), actual.size());
EXPECT_EQ(0, memcmp(expected, &actual[0], actual.size()));
@@ -75,11 +76,13 @@ TEST_F(OutputStreamTest, File) {
TEST_F(OutputStreamTest, Buffered) {
ScratchFile tmp;
- std::unique_ptr<FileOutputStream> file_output_stream(new FileOutputStream(tmp.GetFile()));
- CHECK(file_output_stream.get() != nullptr);
- BufferedOutputStream buffered_output_stream(file_output_stream.release());
- SetOutputStream(buffered_output_stream);
- GenerateTestOutput();
+ {
+ std::unique_ptr<FileOutputStream> file_output_stream(new FileOutputStream(tmp.GetFile()));
+ CHECK(file_output_stream.get() != nullptr);
+ BufferedOutputStream buffered_output_stream(file_output_stream.release());
+ SetOutputStream(buffered_output_stream);
+ GenerateTestOutput();
+ }
std::unique_ptr<File> in(OS::OpenFileForReading(tmp.GetFilename().c_str()));
EXPECT_TRUE(in.get() != nullptr);
std::vector<uint8_t> actual(in->GetLength());