1*795d594fSAndroid Build Coastguard Worker /* 2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2014 The Android Open Source Project 3*795d594fSAndroid Build Coastguard Worker * 4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*795d594fSAndroid Build Coastguard Worker * 8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*795d594fSAndroid Build Coastguard Worker * 10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*795d594fSAndroid Build Coastguard Worker * limitations under the License. 15*795d594fSAndroid Build Coastguard Worker */ 16*795d594fSAndroid Build Coastguard Worker 17*795d594fSAndroid Build Coastguard Worker #ifndef ART_RUNTIME_DEX2OAT_ENVIRONMENT_TEST_H_ 18*795d594fSAndroid Build Coastguard Worker #define ART_RUNTIME_DEX2OAT_ENVIRONMENT_TEST_H_ 19*795d594fSAndroid Build Coastguard Worker 20*795d594fSAndroid Build Coastguard Worker #include <sys/wait.h> 21*795d594fSAndroid Build Coastguard Worker 22*795d594fSAndroid Build Coastguard Worker #include <fstream> 23*795d594fSAndroid Build Coastguard Worker #include <optional> 24*795d594fSAndroid Build Coastguard Worker #include <string> 25*795d594fSAndroid Build Coastguard Worker #include <vector> 26*795d594fSAndroid Build Coastguard Worker 27*795d594fSAndroid Build Coastguard Worker #include "android-base/result.h" 28*795d594fSAndroid Build Coastguard Worker #include "android-base/strings.h" 29*795d594fSAndroid Build Coastguard Worker #include "base/file_utils.h" 30*795d594fSAndroid Build Coastguard Worker #include "base/macros.h" 31*795d594fSAndroid Build Coastguard Worker #include "base/os.h" 32*795d594fSAndroid Build Coastguard Worker #include "base/stl_util.h" 33*795d594fSAndroid Build Coastguard Worker #include "base/utils.h" 34*795d594fSAndroid Build Coastguard Worker #include "common_runtime_test.h" 35*795d594fSAndroid Build Coastguard Worker #include "compiler_callbacks.h" 36*795d594fSAndroid Build Coastguard Worker #include "dex/art_dex_file_loader.h" 37*795d594fSAndroid Build Coastguard Worker #include "dex/dex_file_loader.h" 38*795d594fSAndroid Build Coastguard Worker #include "exec_utils.h" 39*795d594fSAndroid Build Coastguard Worker #include "gc/heap.h" 40*795d594fSAndroid Build Coastguard Worker #include "gc/space/image_space.h" 41*795d594fSAndroid Build Coastguard Worker #include "gtest/gtest.h" 42*795d594fSAndroid Build Coastguard Worker #include "oat/oat_file_assistant.h" 43*795d594fSAndroid Build Coastguard Worker #include "runtime.h" 44*795d594fSAndroid Build Coastguard Worker #include "ziparchive/zip_writer.h" 45*795d594fSAndroid Build Coastguard Worker 46*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN { 47*795d594fSAndroid Build Coastguard Worker 48*795d594fSAndroid Build Coastguard Worker using ::android::base::Result; 49*795d594fSAndroid Build Coastguard Worker 50*795d594fSAndroid Build Coastguard Worker static constexpr bool kDebugArgs = false; 51*795d594fSAndroid Build Coastguard Worker 52*795d594fSAndroid Build Coastguard Worker class Dex2oatScratchDirs { 53*795d594fSAndroid Build Coastguard Worker public: SetUp(const std::string & android_data)54*795d594fSAndroid Build Coastguard Worker void SetUp(const std::string& android_data) { 55*795d594fSAndroid Build Coastguard Worker // Create a scratch directory to work from. 56*795d594fSAndroid Build Coastguard Worker 57*795d594fSAndroid Build Coastguard Worker // Get the realpath of the android data. The oat dir should always point to real location 58*795d594fSAndroid Build Coastguard Worker // when generating oat files in dalvik-cache. This avoids complicating the unit tests 59*795d594fSAndroid Build Coastguard Worker // when matching the expected paths. 60*795d594fSAndroid Build Coastguard Worker UniqueCPtr<const char[]> android_data_real(realpath(android_data.c_str(), nullptr)); 61*795d594fSAndroid Build Coastguard Worker ASSERT_TRUE(android_data_real != nullptr) 62*795d594fSAndroid Build Coastguard Worker << "Could not get the realpath of the android data" << android_data << strerror(errno); 63*795d594fSAndroid Build Coastguard Worker 64*795d594fSAndroid Build Coastguard Worker scratch_dir_.assign(android_data_real.get()); 65*795d594fSAndroid Build Coastguard Worker scratch_dir_ += "/Dex2oatEnvironmentTest"; 66*795d594fSAndroid Build Coastguard Worker ASSERT_EQ(0, mkdir(scratch_dir_.c_str(), 0700)); 67*795d594fSAndroid Build Coastguard Worker 68*795d594fSAndroid Build Coastguard Worker // Create a subdirectory in scratch for odex files. 69*795d594fSAndroid Build Coastguard Worker odex_oat_dir_ = scratch_dir_ + "/oat"; 70*795d594fSAndroid Build Coastguard Worker ASSERT_EQ(0, mkdir(odex_oat_dir_.c_str(), 0700)); 71*795d594fSAndroid Build Coastguard Worker 72*795d594fSAndroid Build Coastguard Worker odex_dir_ = odex_oat_dir_ + "/" + std::string(GetInstructionSetString(kRuntimeISA)); 73*795d594fSAndroid Build Coastguard Worker ASSERT_EQ(0, mkdir(odex_dir_.c_str(), 0700)); 74*795d594fSAndroid Build Coastguard Worker } 75*795d594fSAndroid Build Coastguard Worker TearDown()76*795d594fSAndroid Build Coastguard Worker void TearDown() { 77*795d594fSAndroid Build Coastguard Worker CommonArtTest::ClearDirectory(odex_dir_.c_str()); 78*795d594fSAndroid Build Coastguard Worker ASSERT_EQ(0, rmdir(odex_dir_.c_str())); 79*795d594fSAndroid Build Coastguard Worker 80*795d594fSAndroid Build Coastguard Worker CommonArtTest::ClearDirectory(odex_oat_dir_.c_str()); 81*795d594fSAndroid Build Coastguard Worker ASSERT_EQ(0, rmdir(odex_oat_dir_.c_str())); 82*795d594fSAndroid Build Coastguard Worker 83*795d594fSAndroid Build Coastguard Worker CommonArtTest::ClearDirectory(scratch_dir_.c_str()); 84*795d594fSAndroid Build Coastguard Worker ASSERT_EQ(0, rmdir(scratch_dir_.c_str())); 85*795d594fSAndroid Build Coastguard Worker } 86*795d594fSAndroid Build Coastguard Worker 87*795d594fSAndroid Build Coastguard Worker // Scratch directory, for dex and odex files (oat files will go in the 88*795d594fSAndroid Build Coastguard Worker // dalvik cache). GetScratchDir()89*795d594fSAndroid Build Coastguard Worker const std::string& GetScratchDir() const { return scratch_dir_; } 90*795d594fSAndroid Build Coastguard Worker 91*795d594fSAndroid Build Coastguard Worker // Odex directory is the subdirectory in the scratch directory where odex 92*795d594fSAndroid Build Coastguard Worker // files should be located. GetOdexDir()93*795d594fSAndroid Build Coastguard Worker const std::string& GetOdexDir() const { return odex_dir_; } 94*795d594fSAndroid Build Coastguard Worker 95*795d594fSAndroid Build Coastguard Worker private: 96*795d594fSAndroid Build Coastguard Worker std::string scratch_dir_; 97*795d594fSAndroid Build Coastguard Worker std::string odex_oat_dir_; 98*795d594fSAndroid Build Coastguard Worker std::string odex_dir_; 99*795d594fSAndroid Build Coastguard Worker }; 100*795d594fSAndroid Build Coastguard Worker 101*795d594fSAndroid Build Coastguard Worker // Test class that provides some helpers to set a test up for compilation using dex2oat. 102*795d594fSAndroid Build Coastguard Worker class Dex2oatEnvironmentTest : public Dex2oatScratchDirs, public CommonRuntimeTest { 103*795d594fSAndroid Build Coastguard Worker public: SetUp()104*795d594fSAndroid Build Coastguard Worker void SetUp() override { 105*795d594fSAndroid Build Coastguard Worker CommonRuntimeTest::SetUp(); 106*795d594fSAndroid Build Coastguard Worker Dex2oatScratchDirs::SetUp(android_data_); 107*795d594fSAndroid Build Coastguard Worker 108*795d594fSAndroid Build Coastguard Worker // Verify the environment is as we expect 109*795d594fSAndroid Build Coastguard Worker std::optional<uint32_t> checksum; 110*795d594fSAndroid Build Coastguard Worker std::string error_msg; 111*795d594fSAndroid Build Coastguard Worker ASSERT_TRUE(OS::FileExists(GetSystemImageFile().c_str())) 112*795d594fSAndroid Build Coastguard Worker << "Expected pre-compiled boot image to be at: " << GetSystemImageFile(); 113*795d594fSAndroid Build Coastguard Worker ASSERT_TRUE(OS::FileExists(GetDexSrc1().c_str())) 114*795d594fSAndroid Build Coastguard Worker << "Expected dex file to be at: " << GetDexSrc1(); 115*795d594fSAndroid Build Coastguard Worker ASSERT_TRUE(OS::FileExists(GetResourceOnlySrc1().c_str())) 116*795d594fSAndroid Build Coastguard Worker << "Expected stripped dex file to be at: " << GetResourceOnlySrc1(); 117*795d594fSAndroid Build Coastguard Worker ArtDexFileLoader dex_file_loader0(GetResourceOnlySrc1()); 118*795d594fSAndroid Build Coastguard Worker ASSERT_TRUE(dex_file_loader0.GetMultiDexChecksum(&checksum, &error_msg)) 119*795d594fSAndroid Build Coastguard Worker << "Expected stripped dex file to be stripped: " << GetResourceOnlySrc1(); 120*795d594fSAndroid Build Coastguard Worker ASSERT_TRUE(OS::FileExists(GetDexSrc2().c_str())) 121*795d594fSAndroid Build Coastguard Worker << "Expected dex file to be at: " << GetDexSrc2(); 122*795d594fSAndroid Build Coastguard Worker 123*795d594fSAndroid Build Coastguard Worker // GetMultiDexSrc2 should have the same primary dex checksum as 124*795d594fSAndroid Build Coastguard Worker // GetMultiDexSrc1, but a different secondary dex checksum. 125*795d594fSAndroid Build Coastguard Worker static constexpr bool kVerifyChecksum = true; 126*795d594fSAndroid Build Coastguard Worker std::vector<std::unique_ptr<const DexFile>> multi1; 127*795d594fSAndroid Build Coastguard Worker ArtDexFileLoader dex_file_loader1(GetMultiDexSrc1()); 128*795d594fSAndroid Build Coastguard Worker ASSERT_TRUE(dex_file_loader1.Open(/* verify= */ true, kVerifyChecksum, &error_msg, &multi1)) 129*795d594fSAndroid Build Coastguard Worker << error_msg; 130*795d594fSAndroid Build Coastguard Worker ASSERT_GT(multi1.size(), 1u); 131*795d594fSAndroid Build Coastguard Worker 132*795d594fSAndroid Build Coastguard Worker std::vector<std::unique_ptr<const DexFile>> multi2; 133*795d594fSAndroid Build Coastguard Worker ArtDexFileLoader dex_file_loader2(GetMultiDexSrc2()); 134*795d594fSAndroid Build Coastguard Worker ASSERT_TRUE(dex_file_loader2.Open(/* verify= */ true, kVerifyChecksum, &error_msg, &multi2)) 135*795d594fSAndroid Build Coastguard Worker << error_msg; 136*795d594fSAndroid Build Coastguard Worker ASSERT_GT(multi2.size(), 1u); 137*795d594fSAndroid Build Coastguard Worker 138*795d594fSAndroid Build Coastguard Worker ASSERT_EQ(multi1[0]->GetHeader().checksum_, multi2[0]->GetHeader().checksum_); 139*795d594fSAndroid Build Coastguard Worker ASSERT_NE(multi1[1]->GetHeader().checksum_, multi2[1]->GetHeader().checksum_); 140*795d594fSAndroid Build Coastguard Worker 141*795d594fSAndroid Build Coastguard Worker if (multi1[0]->HasDexContainer()) { 142*795d594fSAndroid Build Coastguard Worker // Checksum is the CRC of the whole container, so both of them should differ. 143*795d594fSAndroid Build Coastguard Worker ASSERT_NE(multi1[0]->GetLocationChecksum(), multi2[0]->GetLocationChecksum()); 144*795d594fSAndroid Build Coastguard Worker ASSERT_NE(multi1[1]->GetLocationChecksum(), multi2[1]->GetLocationChecksum()); 145*795d594fSAndroid Build Coastguard Worker } else { 146*795d594fSAndroid Build Coastguard Worker ASSERT_EQ(multi1[0]->GetLocationChecksum(), multi2[0]->GetLocationChecksum()); 147*795d594fSAndroid Build Coastguard Worker ASSERT_NE(multi1[1]->GetLocationChecksum(), multi2[1]->GetLocationChecksum()); 148*795d594fSAndroid Build Coastguard Worker } 149*795d594fSAndroid Build Coastguard Worker } 150*795d594fSAndroid Build Coastguard Worker SetUpRuntimeOptions(RuntimeOptions * options)151*795d594fSAndroid Build Coastguard Worker void SetUpRuntimeOptions(RuntimeOptions* options) override { 152*795d594fSAndroid Build Coastguard Worker // options->push_back(std::make_pair("-verbose:oat", nullptr)); 153*795d594fSAndroid Build Coastguard Worker 154*795d594fSAndroid Build Coastguard Worker // Set up the image location. 155*795d594fSAndroid Build Coastguard Worker options->push_back(std::make_pair("-Ximage:" + GetImageLocation(), 156*795d594fSAndroid Build Coastguard Worker nullptr)); 157*795d594fSAndroid Build Coastguard Worker // Make sure compilercallbacks are not set so that relocation will be 158*795d594fSAndroid Build Coastguard Worker // enabled. 159*795d594fSAndroid Build Coastguard Worker callbacks_.reset(); 160*795d594fSAndroid Build Coastguard Worker } 161*795d594fSAndroid Build Coastguard Worker TearDown()162*795d594fSAndroid Build Coastguard Worker void TearDown() override { 163*795d594fSAndroid Build Coastguard Worker Dex2oatScratchDirs::TearDown(); 164*795d594fSAndroid Build Coastguard Worker CommonRuntimeTest::TearDown(); 165*795d594fSAndroid Build Coastguard Worker } 166*795d594fSAndroid Build Coastguard Worker Copy(const std::string & src,const std::string & dst)167*795d594fSAndroid Build Coastguard Worker static void Copy(const std::string& src, const std::string& dst) { 168*795d594fSAndroid Build Coastguard Worker std::ifstream src_stream(src, std::ios::binary); 169*795d594fSAndroid Build Coastguard Worker std::ofstream dst_stream(dst, std::ios::binary); 170*795d594fSAndroid Build Coastguard Worker 171*795d594fSAndroid Build Coastguard Worker dst_stream << src_stream.rdbuf(); 172*795d594fSAndroid Build Coastguard Worker } 173*795d594fSAndroid Build Coastguard Worker GetDexSrc1()174*795d594fSAndroid Build Coastguard Worker std::string GetDexSrc1() const { 175*795d594fSAndroid Build Coastguard Worker return GetTestDexFileName("Main"); 176*795d594fSAndroid Build Coastguard Worker } 177*795d594fSAndroid Build Coastguard Worker 178*795d594fSAndroid Build Coastguard Worker // Returns the path to a dex file equivalent to GetDexSrc1, but with the dex 179*795d594fSAndroid Build Coastguard Worker // file stripped. GetResourceOnlySrc1()180*795d594fSAndroid Build Coastguard Worker std::string GetResourceOnlySrc1() const { 181*795d594fSAndroid Build Coastguard Worker return GetTestDexFileName("MainStripped"); 182*795d594fSAndroid Build Coastguard Worker } 183*795d594fSAndroid Build Coastguard Worker GetMultiDexSrc1()184*795d594fSAndroid Build Coastguard Worker std::string GetMultiDexSrc1() const { 185*795d594fSAndroid Build Coastguard Worker return GetTestDexFileName("MultiDex"); 186*795d594fSAndroid Build Coastguard Worker } 187*795d594fSAndroid Build Coastguard Worker GetMultiDexUncompressedAlignedSrc1()188*795d594fSAndroid Build Coastguard Worker std::string GetMultiDexUncompressedAlignedSrc1() const { 189*795d594fSAndroid Build Coastguard Worker return GetTestDexFileName("MultiDexUncompressedAligned"); 190*795d594fSAndroid Build Coastguard Worker } 191*795d594fSAndroid Build Coastguard Worker 192*795d594fSAndroid Build Coastguard Worker // Returns the path to a multidex file equivalent to GetMultiDexSrc2, but 193*795d594fSAndroid Build Coastguard Worker // with the contents of the secondary dex file changed. GetMultiDexSrc2()194*795d594fSAndroid Build Coastguard Worker std::string GetMultiDexSrc2() const { 195*795d594fSAndroid Build Coastguard Worker return GetTestDexFileName("MultiDexModifiedSecondary"); 196*795d594fSAndroid Build Coastguard Worker } 197*795d594fSAndroid Build Coastguard Worker GetDexSrc2()198*795d594fSAndroid Build Coastguard Worker std::string GetDexSrc2() const { 199*795d594fSAndroid Build Coastguard Worker return GetTestDexFileName("Nested"); 200*795d594fSAndroid Build Coastguard Worker } 201*795d594fSAndroid Build Coastguard Worker Dex2Oat(const std::vector<std::string> & dex2oat_args,std::string * output)202*795d594fSAndroid Build Coastguard Worker Result<int> Dex2Oat(const std::vector<std::string>& dex2oat_args, std::string* output) { 203*795d594fSAndroid Build Coastguard Worker std::vector<std::string> argv; 204*795d594fSAndroid Build Coastguard Worker std::string error_msg; 205*795d594fSAndroid Build Coastguard Worker if (!CommonRuntimeTest::StartDex2OatCommandLine(&argv, &error_msg)) { 206*795d594fSAndroid Build Coastguard Worker return Errorf("Could not start dex2oat cmd line: {}", error_msg); 207*795d594fSAndroid Build Coastguard Worker } 208*795d594fSAndroid Build Coastguard Worker 209*795d594fSAndroid Build Coastguard Worker Runtime* runtime = Runtime::Current(); 210*795d594fSAndroid Build Coastguard Worker if (!runtime->IsVerificationEnabled()) { 211*795d594fSAndroid Build Coastguard Worker argv.push_back("--compiler-filter=assume-verified"); 212*795d594fSAndroid Build Coastguard Worker } 213*795d594fSAndroid Build Coastguard Worker 214*795d594fSAndroid Build Coastguard Worker if (runtime->MustRelocateIfPossible()) { 215*795d594fSAndroid Build Coastguard Worker argv.push_back("--runtime-arg"); 216*795d594fSAndroid Build Coastguard Worker argv.push_back("-Xrelocate"); 217*795d594fSAndroid Build Coastguard Worker } else { 218*795d594fSAndroid Build Coastguard Worker argv.push_back("--runtime-arg"); 219*795d594fSAndroid Build Coastguard Worker argv.push_back("-Xnorelocate"); 220*795d594fSAndroid Build Coastguard Worker } 221*795d594fSAndroid Build Coastguard Worker 222*795d594fSAndroid Build Coastguard Worker if (!kIsTargetBuild) { 223*795d594fSAndroid Build Coastguard Worker argv.push_back("--host"); 224*795d594fSAndroid Build Coastguard Worker } 225*795d594fSAndroid Build Coastguard Worker 226*795d594fSAndroid Build Coastguard Worker argv.insert(argv.end(), dex2oat_args.begin(), dex2oat_args.end()); 227*795d594fSAndroid Build Coastguard Worker 228*795d594fSAndroid Build Coastguard Worker // We must set --android-root. 229*795d594fSAndroid Build Coastguard Worker const char* android_root = getenv("ANDROID_ROOT"); 230*795d594fSAndroid Build Coastguard Worker CHECK(android_root != nullptr); 231*795d594fSAndroid Build Coastguard Worker argv.push_back("--android-root=" + std::string(android_root)); 232*795d594fSAndroid Build Coastguard Worker 233*795d594fSAndroid Build Coastguard Worker if (kDebugArgs) { 234*795d594fSAndroid Build Coastguard Worker std::string all_args; 235*795d594fSAndroid Build Coastguard Worker for (const std::string& arg : argv) { 236*795d594fSAndroid Build Coastguard Worker all_args += arg + " "; 237*795d594fSAndroid Build Coastguard Worker } 238*795d594fSAndroid Build Coastguard Worker LOG(ERROR) << all_args; 239*795d594fSAndroid Build Coastguard Worker } 240*795d594fSAndroid Build Coastguard Worker 241*795d594fSAndroid Build Coastguard Worker // We need dex2oat to actually log things. 242*795d594fSAndroid Build Coastguard Worker auto post_fork_fn = []() { return setenv("ANDROID_LOG_TAGS", "*:d", 1) == 0; }; 243*795d594fSAndroid Build Coastguard Worker 244*795d594fSAndroid Build Coastguard Worker ForkAndExecResult res = ForkAndExec(argv, post_fork_fn, output); 245*795d594fSAndroid Build Coastguard Worker if (res.stage != ForkAndExecResult::kFinished) { 246*795d594fSAndroid Build Coastguard Worker return ErrnoErrorf("Failed to finish dex2oat invocation '{}'", 247*795d594fSAndroid Build Coastguard Worker android::base::Join(argv, ' ')); 248*795d594fSAndroid Build Coastguard Worker } 249*795d594fSAndroid Build Coastguard Worker 250*795d594fSAndroid Build Coastguard Worker if (!WIFEXITED(res.status_code)) { 251*795d594fSAndroid Build Coastguard Worker return Errorf("dex2oat didn't terminate normally (status_code={:#x}): {}", 252*795d594fSAndroid Build Coastguard Worker res.status_code, 253*795d594fSAndroid Build Coastguard Worker android::base::Join(argv, ' ')); 254*795d594fSAndroid Build Coastguard Worker } 255*795d594fSAndroid Build Coastguard Worker 256*795d594fSAndroid Build Coastguard Worker return WEXITSTATUS(res.status_code); 257*795d594fSAndroid Build Coastguard Worker } 258*795d594fSAndroid Build Coastguard Worker CreateDexMetadata(const std::string & vdex,const std::string & out_dm)259*795d594fSAndroid Build Coastguard Worker void CreateDexMetadata(const std::string& vdex, const std::string& out_dm) { 260*795d594fSAndroid Build Coastguard Worker // Read the vdex bytes. 261*795d594fSAndroid Build Coastguard Worker std::unique_ptr<File> vdex_file(OS::OpenFileForReading(vdex.c_str())); 262*795d594fSAndroid Build Coastguard Worker std::vector<uint8_t> data(vdex_file->GetLength()); 263*795d594fSAndroid Build Coastguard Worker ASSERT_TRUE(vdex_file->ReadFully(data.data(), data.size())); 264*795d594fSAndroid Build Coastguard Worker 265*795d594fSAndroid Build Coastguard Worker // Zip the content. 266*795d594fSAndroid Build Coastguard Worker FILE* file = fopen(out_dm.c_str(), "wbe"); 267*795d594fSAndroid Build Coastguard Worker ZipWriter writer(file); 268*795d594fSAndroid Build Coastguard Worker writer.StartEntry("primary.vdex", ZipWriter::kAlign32); 269*795d594fSAndroid Build Coastguard Worker writer.WriteBytes(data.data(), data.size()); 270*795d594fSAndroid Build Coastguard Worker writer.FinishEntry(); 271*795d594fSAndroid Build Coastguard Worker writer.Finish(); 272*795d594fSAndroid Build Coastguard Worker fflush(file); 273*795d594fSAndroid Build Coastguard Worker fclose(file); 274*795d594fSAndroid Build Coastguard Worker } 275*795d594fSAndroid Build Coastguard Worker }; 276*795d594fSAndroid Build Coastguard Worker 277*795d594fSAndroid Build Coastguard Worker } // namespace art 278*795d594fSAndroid Build Coastguard Worker 279*795d594fSAndroid Build Coastguard Worker #endif // ART_RUNTIME_DEX2OAT_ENVIRONMENT_TEST_H_ 280