runtime_test.cc revision 4dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4
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)); 3058ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom options.push_back(std::make_pair("-Ximage: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)); 4058ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom options.push_back(std::make_pair("host-prefix", "host_prefix")); 41f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("vfprintf", test_vfprintf)); 42f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("abort", test_abort)); 43f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("exit", test_exit)); 4490a3369d3b6238f1a4c9b19ca68978dab1c39bc4Elliott Hughes UniquePtr<Runtime::ParsedOptions> parsed(Runtime::ParsedOptions::Create(options, false)); 4590a3369d3b6238f1a4c9b19ca68978dab1c39bc4Elliott Hughes ASSERT_TRUE(parsed.get() != NULL); 46f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom 4758ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom EXPECT_EQ(lib_core, parsed->boot_class_path_); 4858ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom EXPECT_EQ(lib_core, parsed->class_path_); 4958ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom EXPECT_EQ(3U, parsed->images_.size()); 5058ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom EXPECT_EQ(std::string("boot_image"), parsed->images_[0]); 5158ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom EXPECT_EQ(std::string("image_1"), parsed->images_[1]); 5258ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom EXPECT_EQ(std::string("image_2"), parsed->images_[2]); 53f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ(true, parsed->check_jni_); 54f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ(2048U, parsed->heap_initial_size_); 55f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ(4 * KB, parsed->heap_maximum_size_); 56f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ(1 * MB, parsed->stack_size_); 5758ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom EXPECT_EQ("host_prefix", parsed->host_prefix_); 58f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_); 59f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_TRUE(test_exit == parsed->hook_exit_); 60f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_TRUE(test_abort == parsed->hook_abort_); 614dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_TRUE(VLOG_IS_ON(class_linker)); 624dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(compiler)); 634dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(heap)); 644dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_TRUE(VLOG_IS_ON(gc)); 654dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(jdwp)); 664dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_TRUE(VLOG_IS_ON(jni)); 674dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(monitor)); 684dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(startup)); 694dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(third_party_jni)); 704dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(threads)); 71f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom ASSERT_EQ(2U, parsed->properties_.size()); 72f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ("foo=bar", parsed->properties_[0]); 73f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ("baz=qux", parsed->properties_[1]); 74f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom} 75f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom 76f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom} // namespace art 77