common_runtime_test.cc revision 3774335b08076117d6950cd472cdd59a167470b5
1eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes/* 2eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * Copyright (C) 2012 The Android Open Source Project 3eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * 4eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 5eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * you may not use this file except in compliance with the License. 6eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * You may obtain a copy of the License at 7eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * 8eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 9eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * 10eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * Unless required by applicable law or agreed to in writing, software 11eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 12eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * See the License for the specific language governing permissions and 14eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes * limitations under the License. 15eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes */ 16eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes 17e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "common_runtime_test.h" 18e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 19e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include <dirent.h> 20e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include <dlfcn.h> 21e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include <fcntl.h> 22e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include <ScopedLocalRef.h> 23e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 24e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "../../external/icu/icu4c/source/common/unicode/uvernum.h" 251fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe#include "base/macros.h" 2607ed66b5ae659c452cbe1ab20c3dbf1d6f546461Elliott Hughes#include "base/logging.h" 27e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "base/stl_util.h" 28e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "base/stringprintf.h" 29e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "base/unix_file/fd_file.h" 30e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "class_linker.h" 31e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "compiler_callbacks.h" 32e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "dex_file.h" 3394f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi#include "gc_root-inl.h" 34e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "gc/heap.h" 35eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes#include "gtest/gtest.h" 36e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "jni_internal.h" 37e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "mirror/class_loader.h" 38e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "noop_compiler_callbacks.h" 39e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "os.h" 40e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "runtime-inl.h" 41e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "scoped_thread_state_change.h" 42e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "thread.h" 43e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "well_known_classes.h" 44eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes 45eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughesint main(int argc, char **argv) { 46eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes art::InitLogging(argv); 47c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers LOG(::art::INFO) << "Running main() from common_runtime_test.cc..."; 48eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes testing::InitGoogleTest(&argc, argv); 49eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes return RUN_ALL_TESTS(); 50eb02a124afcd6869ada475712bca8cbe0de20222Elliott Hughes} 51e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 52e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersnamespace art { 53e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 54e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian RogersScratchFile::ScratchFile() { 55e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // ANDROID_DATA needs to be set 56e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK_NE(static_cast<char*>(nullptr), getenv("ANDROID_DATA")) << 57e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers "Are you subclassing RuntimeTest?"; 58e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename_ = getenv("ANDROID_DATA"); 59e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename_ += "/TmpFile-XXXXXX"; 60e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers int fd = mkstemp(&filename_[0]); 61e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK_NE(-1, fd); 624303ba97313458491e038d78efa041d41cf7bb43Andreas Gampe file_.reset(new File(fd, GetFilename(), true)); 63e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 64e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 65e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian RogersScratchFile::ScratchFile(const ScratchFile& other, const char* suffix) { 66e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename_ = other.GetFilename(); 67e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename_ += suffix; 68e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers int fd = open(filename_.c_str(), O_RDWR | O_CREAT, 0666); 69e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK_NE(-1, fd); 704303ba97313458491e038d78efa041d41cf7bb43Andreas Gampe file_.reset(new File(fd, GetFilename(), true)); 71e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 72e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 73e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian RogersScratchFile::ScratchFile(File* file) { 74e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK(file != NULL); 75e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename_ = file->GetPath(); 76e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers file_.reset(file); 77e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 78e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 79e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian RogersScratchFile::~ScratchFile() { 80e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers Unlink(); 81e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 82e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 83e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersint ScratchFile::GetFd() const { 84e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return file_->Fd(); 85e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 86e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 87e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersvoid ScratchFile::Unlink() { 88e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (!OS::FileExists(filename_.c_str())) { 89e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return; 90e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 914303ba97313458491e038d78efa041d41cf7bb43Andreas Gampe if (file_.get() != nullptr) { 924303ba97313458491e038d78efa041d41cf7bb43Andreas Gampe if (file_->FlushCloseOrErase() != 0) { 934303ba97313458491e038d78efa041d41cf7bb43Andreas Gampe PLOG(WARNING) << "Error closing scratch file."; 944303ba97313458491e038d78efa041d41cf7bb43Andreas Gampe } 954303ba97313458491e038d78efa041d41cf7bb43Andreas Gampe } 96e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers int unlink_result = unlink(filename_.c_str()); 97e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK_EQ(0, unlink_result); 98e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 99e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 100e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian RogersCommonRuntimeTest::CommonRuntimeTest() {} 101e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian RogersCommonRuntimeTest::~CommonRuntimeTest() {} 102e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 1037747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampevoid CommonRuntimeTest::SetUpAndroidRoot() { 104e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (IsHost()) { 105e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // $ANDROID_ROOT is set on the device, but not necessarily on the host. 106e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // But it needs to be set so that icu4c can find its locale data. 107e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers const char* android_root_from_env = getenv("ANDROID_ROOT"); 108e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (android_root_from_env == nullptr) { 109e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // Use ANDROID_HOST_OUT for ANDROID_ROOT if it is set. 110e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers const char* android_host_out = getenv("ANDROID_HOST_OUT"); 111e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (android_host_out != nullptr) { 112e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers setenv("ANDROID_ROOT", android_host_out, 1); 113e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } else { 114e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // Build it from ANDROID_BUILD_TOP or cwd 115e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::string root; 116e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers const char* android_build_top = getenv("ANDROID_BUILD_TOP"); 117e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (android_build_top != nullptr) { 118e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers root += android_build_top; 119e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } else { 120e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // Not set by build server, so default to current directory 121e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers char* cwd = getcwd(nullptr, 0); 122e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers setenv("ANDROID_BUILD_TOP", cwd, 1); 123e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers root += cwd; 124e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers free(cwd); 125e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 126e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#if defined(__linux__) 127e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers root += "/out/host/linux-x86"; 128e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#elif defined(__APPLE__) 129e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers root += "/out/host/darwin-x86"; 130e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#else 131e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#error unsupported OS 132e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#endif 133e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers setenv("ANDROID_ROOT", root.c_str(), 1); 134e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 135e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 136e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers setenv("LD_LIBRARY_PATH", ":", 0); // Required by java.lang.System.<clinit>. 137e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 138e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // Not set by build server, so default 139e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (getenv("ANDROID_HOST_OUT") == nullptr) { 140e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers setenv("ANDROID_HOST_OUT", getenv("ANDROID_ROOT"), 1); 141e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 142e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 1437747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe} 144e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 1457747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampevoid CommonRuntimeTest::SetUpAndroidData(std::string& android_data) { 146e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // On target, Cannot use /mnt/sdcard because it is mounted noexec, so use subdir of dalvik-cache 1475a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe if (IsHost()) { 1485a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe const char* tmpdir = getenv("TMPDIR"); 1495a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe if (tmpdir != nullptr && tmpdir[0] != 0) { 1505a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe android_data = tmpdir; 1515a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe } else { 1525a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe android_data = "/tmp"; 1535a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe } 1545a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe } else { 1555a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe android_data = "/data/dalvik-cache"; 1565a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe } 1575a79fdecffbea657ebecd4cf19078925239eb1c3Andreas Gampe android_data += "/art-data-XXXXXX"; 158e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (mkdtemp(&android_data[0]) == nullptr) { 159e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers PLOG(FATAL) << "mkdtemp(\"" << &android_data[0] << "\") failed"; 160e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 161e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers setenv("ANDROID_DATA", android_data.c_str(), 1); 162e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 163e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 1647747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampevoid CommonRuntimeTest::TearDownAndroidData(const std::string& android_data, bool fail_on_error) { 1657747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe if (fail_on_error) { 1667747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe ASSERT_EQ(rmdir(android_data.c_str()), 0); 1677747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe } else { 1687747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe rmdir(android_data.c_str()); 1697747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe } 1707747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe} 1717747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe 1723774335b08076117d6950cd472cdd59a167470b5Igor Murashkinstd::string CommonRuntimeTest::GetCoreArtLocation() { 1733774335b08076117d6950cd472cdd59a167470b5Igor Murashkin return GetCoreFileLocation("art"); 1743774335b08076117d6950cd472cdd59a167470b5Igor Murashkin} 1753774335b08076117d6950cd472cdd59a167470b5Igor Murashkin 1763774335b08076117d6950cd472cdd59a167470b5Igor Murashkinstd::string CommonRuntimeTest::GetCoreOatLocation() { 1773774335b08076117d6950cd472cdd59a167470b5Igor Murashkin return GetCoreFileLocation("oat"); 1783774335b08076117d6950cd472cdd59a167470b5Igor Murashkin} 1797747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe 180e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersconst DexFile* CommonRuntimeTest::LoadExpectSingleDexFile(const char* location) { 181e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::vector<const DexFile*> dex_files; 182e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::string error_msg; 183e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (!DexFile::Open(location, location, &error_msg, &dex_files)) { 184e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers LOG(FATAL) << "Could not open .dex file '" << location << "': " << error_msg << "\n"; 185e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return nullptr; 186e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } else { 187e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK_EQ(1U, dex_files.size()) << "Expected only one dex file in " << location; 188e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return dex_files[0]; 189e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 190e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 191e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 192e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersvoid CommonRuntimeTest::SetUp() { 1937747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe SetUpAndroidRoot(); 1947747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe SetUpAndroidData(android_data_); 195e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers dalvik_cache_.append(android_data_.c_str()); 196e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers dalvik_cache_.append("/dalvik-cache"); 197e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers int mkdir_result = mkdir(dalvik_cache_.c_str(), 0700); 198e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers ASSERT_EQ(mkdir_result, 0); 199e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 2006e88ef6b604a7a945a466784580c42e6554c1289Mathieu Chartier MemMap::Init(); // For LoadExpectSingleDexFile 2016e88ef6b604a7a945a466784580c42e6554c1289Mathieu Chartier 202e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::string error_msg; 203e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers java_lang_dex_file_ = LoadExpectSingleDexFile(GetLibCoreDexFileName().c_str()); 204e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers boot_class_path_.push_back(java_lang_dex_file_); 205e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 206e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::string min_heap_string(StringPrintf("-Xms%zdm", gc::Heap::kDefaultInitialSize / MB)); 207e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::string max_heap_string(StringPrintf("-Xmx%zdm", gc::Heap::kDefaultMaximumSize / MB)); 208e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 209e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers callbacks_.reset(new NoopCompilerCallbacks()); 210e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 211e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers RuntimeOptions options; 212e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers options.push_back(std::make_pair("bootclasspath", &boot_class_path_)); 213e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers options.push_back(std::make_pair("-Xcheck:jni", nullptr)); 214e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers options.push_back(std::make_pair(min_heap_string.c_str(), nullptr)); 215e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers options.push_back(std::make_pair(max_heap_string.c_str(), nullptr)); 216e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers options.push_back(std::make_pair("compilercallbacks", callbacks_.get())); 217e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers SetUpRuntimeOptions(&options); 218e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (!Runtime::Create(options, false)) { 219e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers LOG(FATAL) << "Failed to create runtime"; 220e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return; 221e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 222e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers runtime_.reset(Runtime::Current()); 223e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers class_linker_ = runtime_->GetClassLinker(); 224e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers class_linker_->FixupDexCaches(runtime_->GetResolutionMethod()); 225e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers class_linker_->RunRootClinits(); 226e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 227e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // Runtime::Create acquired the mutator_lock_ that is normally given away when we 228e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // Runtime::Start, give it away now and then switch to a more managable ScopedObjectAccess. 229e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers Thread::Current()->TransitionFromRunnableToSuspended(kNative); 230e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 231e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // We're back in native, take the opportunity to initialize well known classes. 232e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers WellKnownClasses::Init(Thread::Current()->GetJniEnv()); 233e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 234e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // Create the heap thread pool so that the GC runs in parallel for tests. Normally, the thread 235e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // pool is created by the runtime. 236e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers runtime_->GetHeap()->CreateThreadPool(); 237e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers runtime_->GetHeap()->VerifyHeap(); // Check for heap corruption before the test 238e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 239e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 240a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Lightvoid CommonRuntimeTest::ClearDirectory(const char* dirpath) { 241a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light ASSERT_TRUE(dirpath != nullptr); 242a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light DIR* dir = opendir(dirpath); 243e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers ASSERT_TRUE(dir != nullptr); 244e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers dirent* e; 245a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light struct stat s; 246e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers while ((e = readdir(dir)) != nullptr) { 247e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if ((strcmp(e->d_name, ".") == 0) || (strcmp(e->d_name, "..") == 0)) { 248e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers continue; 249e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 250f0a3f09c3d54646166a55c05a6b39c7dd504129cJeff Hao std::string filename(dirpath); 251e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename.push_back('/'); 252e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename.append(e->d_name); 253a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light int stat_result = lstat(filename.c_str(), &s); 254a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light ASSERT_EQ(0, stat_result) << "unable to stat " << filename; 255a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light if (S_ISDIR(s.st_mode)) { 256a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light ClearDirectory(filename.c_str()); 257a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light int rmdir_result = rmdir(filename.c_str()); 258a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light ASSERT_EQ(0, rmdir_result) << filename; 259a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light } else { 260a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light int unlink_result = unlink(filename.c_str()); 261a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light ASSERT_EQ(0, unlink_result) << filename; 262a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light } 263e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 264e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers closedir(dir); 265a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light} 266a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light 267a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Lightvoid CommonRuntimeTest::TearDown() { 268a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light const char* android_data = getenv("ANDROID_DATA"); 269a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light ASSERT_TRUE(android_data != nullptr); 270a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light ClearDirectory(dalvik_cache_.c_str()); 271e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers int rmdir_cache_result = rmdir(dalvik_cache_.c_str()); 272e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers ASSERT_EQ(0, rmdir_cache_result); 2737747c8de402f64e3009ca3bcccebddbb70f617eeAndreas Gampe TearDownAndroidData(android_data_, true); 274e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 275e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // icu4c has a fixed 10-element array "gCommonICUDataArray". 276e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // If we run > 10 tests, we fill that array and u_setCommonData fails. 277e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // There's a function to clear the array, but it's not public... 278e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers typedef void (*IcuCleanupFn)(); 279e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers void* sym = dlsym(RTLD_DEFAULT, "u_cleanup_" U_ICU_VERSION_SHORT); 280e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK(sym != nullptr) << dlerror(); 281e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers IcuCleanupFn icu_cleanup_fn = reinterpret_cast<IcuCleanupFn>(sym); 282e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers (*icu_cleanup_fn)(); 283e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 284e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers STLDeleteElements(&opened_dex_files_); 285e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 286e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers Runtime::Current()->GetHeap()->VerifyHeap(); // Check for heap corruption after the test 287e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 288e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 289e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersstd::string CommonRuntimeTest::GetLibCoreDexFileName() { 290e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return GetDexFileName("core-libart"); 291e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 292e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 293e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersstd::string CommonRuntimeTest::GetDexFileName(const std::string& jar_prefix) { 294e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (IsHost()) { 295e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers const char* host_dir = getenv("ANDROID_HOST_OUT"); 296e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK(host_dir != nullptr); 297e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return StringPrintf("%s/framework/%s-hostdex.jar", host_dir, jar_prefix.c_str()); 298e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 299e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return StringPrintf("%s/framework/%s.jar", GetAndroidRoot(), jar_prefix.c_str()); 300e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 301e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 302e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersstd::string CommonRuntimeTest::GetTestAndroidRoot() { 303e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (IsHost()) { 304e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers const char* host_dir = getenv("ANDROID_HOST_OUT"); 305e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK(host_dir != nullptr); 306e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return host_dir; 307e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 308e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return GetAndroidRoot(); 309e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 310e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 3111fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe// Check that for target builds we have ART_TARGET_NATIVETEST_DIR set. 3121fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe#ifdef ART_TARGET 3131fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe#ifndef ART_TARGET_NATIVETEST_DIR 3141fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe#error "ART_TARGET_NATIVETEST_DIR not set." 3151fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe#endif 3161fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe// Wrap it as a string literal. 3171fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe#define ART_TARGET_NATIVETEST_DIR_STRING STRINGIFY(ART_TARGET_NATIVETEST_DIR) "/" 3181fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe#else 3191fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe#define ART_TARGET_NATIVETEST_DIR_STRING "" 3201fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe#endif 3211fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe 322e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersstd::vector<const DexFile*> CommonRuntimeTest::OpenTestDexFiles(const char* name) { 323e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK(name != nullptr); 324e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::string filename; 325e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers if (IsHost()) { 326e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename += getenv("ANDROID_HOST_OUT"); 327e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename += "/framework/"; 328e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } else { 3291fe5e5cce85a3cdc64a8d226a8ef4e6134c2b9ebAndreas Gampe filename += ART_TARGET_NATIVETEST_DIR_STRING; 330e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 331e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename += "art-gtest-"; 332e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename += name; 333e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers filename += ".jar"; 334e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::string error_msg; 335e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::vector<const DexFile*> dex_files; 336e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers bool success = DexFile::Open(filename.c_str(), filename.c_str(), &error_msg, &dex_files); 337e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK(success) << "Failed to open '" << filename << "': " << error_msg; 338e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers for (const DexFile* dex_file : dex_files) { 339e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK_EQ(PROT_READ, dex_file->GetPermissions()); 340e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK(dex_file->IsReadOnly()); 341e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 342e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers opened_dex_files_.insert(opened_dex_files_.end(), dex_files.begin(), dex_files.end()); 343e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return dex_files; 344e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 345e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 346e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersconst DexFile* CommonRuntimeTest::OpenTestDexFile(const char* name) { 347e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::vector<const DexFile*> vector = OpenTestDexFiles(name); 348e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers EXPECT_EQ(1U, vector.size()); 349e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return vector[0]; 350e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 351e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 352e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersjobject CommonRuntimeTest::LoadDex(const char* dex_name) { 353e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers std::vector<const DexFile*> dex_files = OpenTestDexFiles(dex_name); 354e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers CHECK_NE(0U, dex_files.size()); 355e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers for (const DexFile* dex_file : dex_files) { 356e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers class_linker_->RegisterDexFile(*dex_file); 357e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers } 35868d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers Thread* self = Thread::Current(); 35968d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers JNIEnvExt* env = self->GetJniEnv(); 36068d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers ScopedLocalRef<jobject> class_loader_local(env, 36168d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers env->AllocObject(WellKnownClasses::dalvik_system_PathClassLoader)); 36268d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers jobject class_loader = env->NewGlobalRef(class_loader_local.get()); 36368d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers self->SetClassLoaderOverride(class_loader_local.get()); 364e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers Runtime::Current()->SetCompileTimeClassPath(class_loader, dex_files); 365e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers return class_loader; 366e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 367e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 3683774335b08076117d6950cd472cdd59a167470b5Igor Murashkinstd::string CommonRuntimeTest::GetCoreFileLocation(const char* suffix) { 3693774335b08076117d6950cd472cdd59a167470b5Igor Murashkin CHECK(suffix != nullptr); 3703774335b08076117d6950cd472cdd59a167470b5Igor Murashkin 3713774335b08076117d6950cd472cdd59a167470b5Igor Murashkin std::string location; 3723774335b08076117d6950cd472cdd59a167470b5Igor Murashkin if (IsHost()) { 3733774335b08076117d6950cd472cdd59a167470b5Igor Murashkin const char* host_dir = getenv("ANDROID_HOST_OUT"); 3743774335b08076117d6950cd472cdd59a167470b5Igor Murashkin CHECK(host_dir != NULL); 3753774335b08076117d6950cd472cdd59a167470b5Igor Murashkin location = StringPrintf("%s/framework/core.%s", host_dir, suffix); 3763774335b08076117d6950cd472cdd59a167470b5Igor Murashkin } else { 3773774335b08076117d6950cd472cdd59a167470b5Igor Murashkin location = StringPrintf("/data/art-test/core.%s", suffix); 3783774335b08076117d6950cd472cdd59a167470b5Igor Murashkin } 3793774335b08076117d6950cd472cdd59a167470b5Igor Murashkin 3803774335b08076117d6950cd472cdd59a167470b5Igor Murashkin return location; 3813774335b08076117d6950cd472cdd59a167470b5Igor Murashkin} 3823774335b08076117d6950cd472cdd59a167470b5Igor Murashkin 383e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian RogersCheckJniAbortCatcher::CheckJniAbortCatcher() : vm_(Runtime::Current()->GetJavaVM()) { 38468d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers vm_->SetCheckJniAbortHook(Hook, &actual_); 385e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 386e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 387e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian RogersCheckJniAbortCatcher::~CheckJniAbortCatcher() { 38868d8b42ddec39ec0174162d90d4abaa004d1983eIan Rogers vm_->SetCheckJniAbortHook(nullptr, nullptr); 389e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers EXPECT_TRUE(actual_.empty()) << actual_; 390e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 391e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 392e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersvoid CheckJniAbortCatcher::Check(const char* expected_text) { 393e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers EXPECT_TRUE(actual_.find(expected_text) != std::string::npos) << "\n" 394e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers << "Expected to find: " << expected_text << "\n" 395e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers << "In the output : " << actual_; 396e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers actual_.clear(); 397e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 398e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 399e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersvoid CheckJniAbortCatcher::Hook(void* data, const std::string& reason) { 400e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // We use += because when we're hooking the aborts like this, multiple problems can be found. 401e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers *reinterpret_cast<std::string*>(data) += reason; 402e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 403e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 404e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} // namespace art 405e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 406e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersnamespace std { 407e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 408e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogerstemplate <typename T> 409e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersstd::ostream& operator<<(std::ostream& os, const std::vector<T>& rhs) { 410e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersos << ::art::ToString(rhs); 411e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersreturn os; 412e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} 413e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 414e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers} // namespace std 415