summaryrefslogtreecommitdiffstats
path: root/src/image_test.cc
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2013-01-10 12:03:38 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-01-10 12:03:39 -0800
commite6270cce5338ff544b0fcddea234fe62678a9503 (patch)
tree69d8587e98e6db94bedabe4a76aba68d8a3ae48e /src/image_test.cc
parent16848f6c5c4d8394d491e887d7d805beddf173ad (diff)
parent10c5b78436bf9e603d817b40d1b98961919362b1 (diff)
downloadart-e6270cce5338ff544b0fcddea234fe62678a9503.zip
art-e6270cce5338ff544b0fcddea234fe62678a9503.tar.gz
art-e6270cce5338ff544b0fcddea234fe62678a9503.tar.bz2
Merge "Fixes for gtests on gPrecise." into dalvik-dev
Diffstat (limited to 'src/image_test.cc')
-rw-r--r--src/image_test.cc24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/image_test.cc b/src/image_test.cc
index a250b13..dc81587 100644
--- a/src/image_test.cc
+++ b/src/image_test.cc
@@ -23,11 +23,24 @@
#include "oat_writer.h"
#include "signal_catcher.h"
#include "gc/space.h"
+#include "UniquePtr.h"
#include "utils.h"
namespace art {
-class ImageTest : public CommonTest {};
+class ImageTest : public CommonTest {
+
+ protected:
+ virtual void SetUp() {
+ // Reserve where the image will be loaded up front so that other parts of test set up don't
+ // accidentally end up colliding with the fixed memory address when we need to load the image.
+ image_reservation_.reset(MemMap::MapAnonymous("Image reservation", (byte*)ART_BASE_ADDRESS,
+ (size_t)100 * 1024 *1024, // 100MB
+ PROT_NONE));
+ CommonTest::SetUp();
+ }
+ UniquePtr<MemMap> image_reservation_;
+};
TEST_F(ImageTest, WriteRead) {
ScratchFile tmp_oat;
@@ -74,15 +87,18 @@ TEST_F(ImageTest, WriteRead) {
}
// Need to delete the compiler since it has worker threads which are attached to runtime.
- delete compiler_.release();
+ compiler_.reset();
- // tear down old runtime before making a new one, clearing out misc state
- delete runtime_.release();
+ // Tear down old runtime before making a new one, clearing out misc state.
+ runtime_.reset();
java_lang_dex_file_ = NULL;
UniquePtr<const DexFile> dex(DexFile::Open(GetLibCoreDexFileName(), GetLibCoreDexFileName()));
ASSERT_TRUE(dex.get() != NULL);
+ // Remove the reservation of the memory for use to load the image.
+ image_reservation_.reset();
+
Runtime::Options options;
std::string image("-Ximage:");
image.append(tmp_image.GetFilename());