runtime_test.cc revision 69b15fb098162f19a4c20e6dccdcead04d9c77f0
1fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro// Copyright 2011 Google Inc. All Rights Reserved.
2fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro
3db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom#include "runtime.h"
490a3369d3b6238f1a4c9b19ca68978dab1c39bc4Elliott Hughes
590a3369d3b6238f1a4c9b19ca68978dab1c39bc4Elliott Hughes#include "UniquePtr.h"
6f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom#include "common_test.h"
7fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro
8fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapironamespace art {
9fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro
10f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstromclass RuntimeTest : public CommonTest {};
11fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro
12f734cf55d510976f4862b15e35fc86eae2a3daf8Brian CarlstromTEST_F(RuntimeTest, ParsedOptions) {
13f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  void* test_vfprintf = reinterpret_cast<void*>(0xa);
14f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  void* test_abort = reinterpret_cast<void*>(0xb);
15f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  void* test_exit = reinterpret_cast<void*>(0xc);
16f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  void* null = reinterpret_cast<void*>(NULL);
1769b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom
1869b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  std::string lib_core = GetLibCoreDexFileName();
1969b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom
2069b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  std::string boot_class_path;
2169b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  boot_class_path += "-Xbootclasspath:";
2269b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  boot_class_path += lib_core;
23f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom
24f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  Runtime::Options options;
2569b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  options.push_back(std::make_pair(boot_class_path.c_str(), null));
2669b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  options.push_back(std::make_pair("-classpath", null));
2769b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  options.push_back(std::make_pair(lib_core.c_str(), null));
2869b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  options.push_back(std::make_pair("-cp", null));
2969b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  options.push_back(std::make_pair(lib_core.c_str(), null));
30f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("-Xbootimage:boot_image", null));
3169b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  options.push_back(std::make_pair("-Ximage:image_1", null));
3269b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  options.push_back(std::make_pair("-Ximage:image_2", null));
33f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("-Xcheck:jni", null));
34f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("-Xms2048", null));
35f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("-Xmx4k", null));
36f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("-Xss1m", null));
37f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("-Dfoo=bar", null));
38f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("-Dbaz=qux", null));
39f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("-verbose:gc,class,jni", null));
40f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("vfprintf", test_vfprintf));
41f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("abort", test_abort));
42f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  options.push_back(std::make_pair("exit", test_exit));
4390a3369d3b6238f1a4c9b19ca68978dab1c39bc4Elliott Hughes  UniquePtr<Runtime::ParsedOptions> parsed(Runtime::ParsedOptions::Create(options, false));
4490a3369d3b6238f1a4c9b19ca68978dab1c39bc4Elliott Hughes  ASSERT_TRUE(parsed.get() != NULL);
45f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom
4669b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  EXPECT_EQ(1U, parsed->boot_class_path_.size());
4769b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  EXPECT_EQ(1U, parsed->class_path_.size());
48f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_STREQ("boot_image", parsed->boot_image_);
4969b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  EXPECT_EQ(2U, parsed->images_.size());
5069b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  EXPECT_STREQ("image_1", parsed->images_[0]);
5169b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  EXPECT_STREQ("image_2", parsed->images_[1]);
52f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_EQ(true, parsed->check_jni_);
53f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_EQ(2048U, parsed->heap_initial_size_);
54f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_EQ(4 * KB, parsed->heap_maximum_size_);
55f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_EQ(1 * MB, parsed->stack_size_);
56f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_);
57f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_TRUE(test_exit == parsed->hook_exit_);
58f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_TRUE(test_abort == parsed->hook_abort_);
59f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  ASSERT_EQ(3U, parsed->verbose_.size());
60f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_TRUE(parsed->verbose_.find("gc") != parsed->verbose_.end());
61f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_TRUE(parsed->verbose_.find("class") != parsed->verbose_.end());
62f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_TRUE(parsed->verbose_.find("jni") != parsed->verbose_.end());
63f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  ASSERT_EQ(2U, parsed->properties_.size());
64f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_EQ("foo=bar", parsed->properties_[0]);
65f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom  EXPECT_EQ("baz=qux", parsed->properties_[1]);
66f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom}
67f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom
68f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom}  // namespace art
69