Carl Shapiro | fc322c7 | 2011-07-27 00:20:01 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
Brian Carlstrom | db4d540 | 2011-08-09 12:18:28 -0700 | [diff] [blame] | 3 | #include "runtime.h" |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 4 | |
| 5 | #include "UniquePtr.h" |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 6 | #include "common_test.h" |
Carl Shapiro | fc322c7 | 2011-07-27 00:20:01 -0700 | [diff] [blame] | 7 | |
| 8 | namespace art { |
Carl Shapiro | fc322c7 | 2011-07-27 00:20:01 -0700 | [diff] [blame] | 9 | |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 10 | class RuntimeTest : public CommonTest {}; |
Carl Shapiro | fc322c7 | 2011-07-27 00:20:01 -0700 | [diff] [blame] | 11 | |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 12 | TEST_F(RuntimeTest, ParsedOptions) { |
| 13 | void* test_vfprintf = reinterpret_cast<void*>(0xa); |
| 14 | void* test_abort = reinterpret_cast<void*>(0xb); |
| 15 | void* test_exit = reinterpret_cast<void*>(0xc); |
| 16 | void* null = reinterpret_cast<void*>(NULL); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 17 | |
| 18 | std::string lib_core = GetLibCoreDexFileName(); |
| 19 | |
| 20 | std::string boot_class_path; |
| 21 | boot_class_path += "-Xbootclasspath:"; |
| 22 | boot_class_path += lib_core; |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 23 | |
| 24 | Runtime::Options options; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 25 | options.push_back(std::make_pair(boot_class_path.c_str(), null)); |
| 26 | options.push_back(std::make_pair("-classpath", null)); |
| 27 | options.push_back(std::make_pair(lib_core.c_str(), null)); |
| 28 | options.push_back(std::make_pair("-cp", null)); |
| 29 | options.push_back(std::make_pair(lib_core.c_str(), null)); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 30 | options.push_back(std::make_pair("-Xbootimage:boot_image", null)); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 31 | options.push_back(std::make_pair("-Ximage:image_1", null)); |
| 32 | options.push_back(std::make_pair("-Ximage:image_2", null)); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 33 | options.push_back(std::make_pair("-Xcheck:jni", null)); |
| 34 | options.push_back(std::make_pair("-Xms2048", null)); |
| 35 | options.push_back(std::make_pair("-Xmx4k", null)); |
| 36 | options.push_back(std::make_pair("-Xss1m", null)); |
| 37 | options.push_back(std::make_pair("-Dfoo=bar", null)); |
| 38 | options.push_back(std::make_pair("-Dbaz=qux", null)); |
| 39 | options.push_back(std::make_pair("-verbose:gc,class,jni", null)); |
| 40 | options.push_back(std::make_pair("vfprintf", test_vfprintf)); |
| 41 | options.push_back(std::make_pair("abort", test_abort)); |
| 42 | options.push_back(std::make_pair("exit", test_exit)); |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 43 | UniquePtr<Runtime::ParsedOptions> parsed(Runtime::ParsedOptions::Create(options, false)); |
| 44 | ASSERT_TRUE(parsed.get() != NULL); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 45 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 46 | EXPECT_EQ(1U, parsed->boot_class_path_.size()); |
| 47 | EXPECT_EQ(1U, parsed->class_path_.size()); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 48 | EXPECT_STREQ("boot_image", parsed->boot_image_); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 49 | EXPECT_EQ(2U, parsed->images_.size()); |
| 50 | EXPECT_STREQ("image_1", parsed->images_[0]); |
| 51 | EXPECT_STREQ("image_2", parsed->images_[1]); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 52 | EXPECT_EQ(true, parsed->check_jni_); |
| 53 | EXPECT_EQ(2048U, parsed->heap_initial_size_); |
| 54 | EXPECT_EQ(4 * KB, parsed->heap_maximum_size_); |
| 55 | EXPECT_EQ(1 * MB, parsed->stack_size_); |
| 56 | EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_); |
| 57 | EXPECT_TRUE(test_exit == parsed->hook_exit_); |
| 58 | EXPECT_TRUE(test_abort == parsed->hook_abort_); |
| 59 | ASSERT_EQ(3U, parsed->verbose_.size()); |
| 60 | EXPECT_TRUE(parsed->verbose_.find("gc") != parsed->verbose_.end()); |
| 61 | EXPECT_TRUE(parsed->verbose_.find("class") != parsed->verbose_.end()); |
| 62 | EXPECT_TRUE(parsed->verbose_.find("jni") != parsed->verbose_.end()); |
| 63 | ASSERT_EQ(2U, parsed->properties_.size()); |
| 64 | EXPECT_EQ("foo=bar", parsed->properties_[0]); |
| 65 | EXPECT_EQ("baz=qux", parsed->properties_[1]); |
| 66 | } |
| 67 | |
| 68 | } // namespace art |