12faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes/* 22faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Copyright (C) 2011 The Android Open Source Project 32faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 42faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 52faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * you may not use this file except in compliance with the License. 62faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * You may obtain a copy of the License at 72faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 82faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 92faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 102faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Unless required by applicable law or agreed to in writing, software 112faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 122faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * See the License for the specific language governing permissions and 142faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * limitations under the License. 152faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes */ 16fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro 17db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom#include "runtime.h" 1890a3369d3b6238f1a4c9b19ca68978dab1c39bc4Elliott Hughes 1990a3369d3b6238f1a4c9b19ca68978dab1c39bc4Elliott Hughes#include "UniquePtr.h" 20f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom#include "common_test.h" 21fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro 22fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapironamespace art { 23fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro 24f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstromclass RuntimeTest : public CommonTest {}; 25fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro 26f734cf55d510976f4862b15e35fc86eae2a3daf8Brian CarlstromTEST_F(RuntimeTest, ParsedOptions) { 27f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom void* test_vfprintf = reinterpret_cast<void*>(0xa); 28f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom void* test_abort = reinterpret_cast<void*>(0xb); 29f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom void* test_exit = reinterpret_cast<void*>(0xc); 30f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom void* null = reinterpret_cast<void*>(NULL); 3169b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom 32955724179c6c739524f610023287f56b24dc31deElliott Hughes std::string lib_core(GetLibCoreDexFileName()); 3369b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom 3469b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom std::string boot_class_path; 3569b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom boot_class_path += "-Xbootclasspath:"; 3669b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom boot_class_path += lib_core; 37f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom 38f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom Runtime::Options options; 3969b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom options.push_back(std::make_pair(boot_class_path.c_str(), null)); 4069b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom options.push_back(std::make_pair("-classpath", null)); 4169b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom options.push_back(std::make_pair(lib_core.c_str(), null)); 4269b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom options.push_back(std::make_pair("-cp", null)); 4369b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom options.push_back(std::make_pair(lib_core.c_str(), null)); 4458ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom options.push_back(std::make_pair("-Ximage:boot_image", null)); 45f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("-Xcheck:jni", null)); 46f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("-Xms2048", null)); 47f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("-Xmx4k", null)); 48f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("-Xss1m", null)); 49bd86bccf1b47f1151842152ee52cf5d46d6b34abBrian Carlstrom options.push_back(std::make_pair("-XX:HeapTargetUtilization=0.75", null)); 50f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("-Dfoo=bar", null)); 51f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("-Dbaz=qux", null)); 52f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("-verbose:gc,class,jni", null)); 5358ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom options.push_back(std::make_pair("host-prefix", "host_prefix")); 54f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("vfprintf", test_vfprintf)); 55f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("abort", test_abort)); 56f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom options.push_back(std::make_pair("exit", test_exit)); 5790a3369d3b6238f1a4c9b19ca68978dab1c39bc4Elliott Hughes UniquePtr<Runtime::ParsedOptions> parsed(Runtime::ParsedOptions::Create(options, false)); 5890a3369d3b6238f1a4c9b19ca68978dab1c39bc4Elliott Hughes ASSERT_TRUE(parsed.get() != NULL); 59f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom 60a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom EXPECT_EQ(lib_core, parsed->boot_class_path_string_); 61a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom EXPECT_EQ(lib_core, parsed->class_path_string_); 62223f20fa939c386c695977263780dea2195093dbBrian Carlstrom EXPECT_EQ(std::string("boot_image"), parsed->image_); 63f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ(true, parsed->check_jni_); 64f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ(2048U, parsed->heap_initial_size_); 65f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ(4 * KB, parsed->heap_maximum_size_); 66f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ(1 * MB, parsed->stack_size_); 67bd86bccf1b47f1151842152ee52cf5d46d6b34abBrian Carlstrom EXPECT_EQ(0.75, parsed->heap_target_utilization_); 6858ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom EXPECT_EQ("host_prefix", parsed->host_prefix_); 69f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_); 70f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_TRUE(test_exit == parsed->hook_exit_); 71f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_TRUE(test_abort == parsed->hook_abort_); 724dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_TRUE(VLOG_IS_ON(class_linker)); 734dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(compiler)); 744dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(heap)); 754dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_TRUE(VLOG_IS_ON(gc)); 764dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(jdwp)); 774dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_TRUE(VLOG_IS_ON(jni)); 784dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(monitor)); 794dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(startup)); 804dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(third_party_jni)); 814dd9b4d95eec9db5338fb9bf132f9bb8facf6cf4Elliott Hughes EXPECT_FALSE(VLOG_IS_ON(threads)); 82f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom ASSERT_EQ(2U, parsed->properties_.size()); 83f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ("foo=bar", parsed->properties_[0]); 84f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom EXPECT_EQ("baz=qux", parsed->properties_[1]); 85f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom} 86f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom 87f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom} // namespace art 88