summaryrefslogtreecommitdiffstats
path: root/compiler
diff options
context:
space:
mode:
authorZheng Xu <zheng.xu@linaro.org>2015-06-19 14:12:45 +0800
committerAndreas Gampe <agampe@google.com>2015-07-01 10:21:54 -0700
commitc4e75e2d4319bd57461aed6d138de23032e511d5 (patch)
tree42dc473d3c7dd60c82cb9016da98ac8f093641da /compiler
parented40271dc6148252f6a0a810c59d3ff1cb9925ba (diff)
downloadart-c4e75e2d4319bd57461aed6d138de23032e511d5.zip
art-c4e75e2d4319bd57461aed6d138de23032e511d5.tar.gz
art-c4e75e2d4319bd57461aed6d138de23032e511d5.tar.bz2
ART: Fix data loss when symbolizing oat files.
Bug: 21760614 (cherry picked from commit 98088c424efd45ea3c172d4bc16e191f26a007cc) Change-Id: I1b40b8ee313a4d187439d969d083d12fb3997cda
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());