Add buffering to ELF file generation

Bug: 10496017
Change-Id: I3cbad249e0fb33f726bd0a504b3b6bd9b4f759c8
diff --git a/compiler/output_stream_test.cc b/compiler/output_stream_test.cc
index d5e9755..a957ee3 100644
--- a/compiler/output_stream_test.cc
+++ b/compiler/output_stream_test.cc
@@ -15,6 +15,7 @@
  */
 
 #include "base/logging.h"
+#include "buffered_output_stream.h"
 #include "common_test.h"
 #include "file_output_stream.h"
 #include "vector_output_stream.h"
@@ -70,6 +71,21 @@
   CheckTestOutput(actual);
 }
 
+TEST_F(OutputStreamTest, Buffered) {
+  ScratchFile tmp;
+  UniquePtr<FileOutputStream> file_output_stream(new FileOutputStream(tmp.GetFile()));
+  CHECK(file_output_stream.get() != NULL);
+  BufferedOutputStream buffered_output_stream(file_output_stream.release());
+  SetOutputStream(buffered_output_stream);
+  GenerateTestOutput();
+  UniquePtr<File> in(OS::OpenFileForReading(tmp.GetFilename().c_str()));
+  EXPECT_TRUE(in.get() != NULL);
+  std::vector<uint8_t> actual(in->GetLength());
+  bool readSuccess = in->ReadFully(&actual[0], actual.size());
+  EXPECT_TRUE(readSuccess);
+  CheckTestOutput(actual);
+}
+
 TEST_F(OutputStreamTest, Vector) {
   std::vector<uint8_t> output;
   VectorOutputStream output_stream("test vector output", output);