Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Carl Shapiro | fc322c7 | 2011-07-27 00:20:01 -0700 | [diff] [blame] | 16 | |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 17 | #include "parsed_options.h" |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 18 | |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 19 | #include <memory> |
| 20 | |
Brian Carlstrom | a1ce1fe | 2014-02-24 23:23:58 -0800 | [diff] [blame] | 21 | #include "common_runtime_test.h" |
Carl Shapiro | fc322c7 | 2011-07-27 00:20:01 -0700 | [diff] [blame] | 22 | |
| 23 | namespace art { |
Carl Shapiro | fc322c7 | 2011-07-27 00:20:01 -0700 | [diff] [blame] | 24 | |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 25 | class ParsedOptionsTest : public CommonRuntimeTest {}; |
Carl Shapiro | fc322c7 | 2011-07-27 00:20:01 -0700 | [diff] [blame] | 26 | |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 27 | TEST_F(ParsedOptionsTest, ParsedOptions) { |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 28 | void* test_vfprintf = reinterpret_cast<void*>(0xa); |
| 29 | void* test_abort = reinterpret_cast<void*>(0xb); |
| 30 | void* test_exit = reinterpret_cast<void*>(0xc); |
| 31 | void* null = reinterpret_cast<void*>(NULL); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 32 | |
Elliott Hughes | 9557241 | 2011-12-13 18:14:20 -0800 | [diff] [blame] | 33 | std::string lib_core(GetLibCoreDexFileName()); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 34 | |
| 35 | std::string boot_class_path; |
| 36 | boot_class_path += "-Xbootclasspath:"; |
| 37 | boot_class_path += lib_core; |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 38 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 39 | RuntimeOptions options; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 40 | options.push_back(std::make_pair(boot_class_path.c_str(), null)); |
| 41 | options.push_back(std::make_pair("-classpath", null)); |
| 42 | options.push_back(std::make_pair(lib_core.c_str(), null)); |
| 43 | options.push_back(std::make_pair("-cp", null)); |
| 44 | options.push_back(std::make_pair(lib_core.c_str(), null)); |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 45 | options.push_back(std::make_pair("-Ximage:boot_image", null)); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 46 | options.push_back(std::make_pair("-Xcheck:jni", null)); |
| 47 | options.push_back(std::make_pair("-Xms2048", null)); |
| 48 | options.push_back(std::make_pair("-Xmx4k", null)); |
| 49 | options.push_back(std::make_pair("-Xss1m", null)); |
Brian Carlstrom | bd86bcc | 2013-03-10 20:26:16 -0700 | [diff] [blame] | 50 | options.push_back(std::make_pair("-XX:HeapTargetUtilization=0.75", null)); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 51 | options.push_back(std::make_pair("-Dfoo=bar", null)); |
| 52 | options.push_back(std::make_pair("-Dbaz=qux", null)); |
| 53 | options.push_back(std::make_pair("-verbose:gc,class,jni", null)); |
| 54 | options.push_back(std::make_pair("vfprintf", test_vfprintf)); |
| 55 | options.push_back(std::make_pair("abort", test_abort)); |
| 56 | options.push_back(std::make_pair("exit", test_exit)); |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 57 | std::unique_ptr<ParsedOptions> parsed(ParsedOptions::Create(options, false)); |
Elliott Hughes | 90a3369 | 2011-08-30 13:27:07 -0700 | [diff] [blame] | 58 | ASSERT_TRUE(parsed.get() != NULL); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 59 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 60 | EXPECT_EQ(lib_core, parsed->boot_class_path_string_); |
| 61 | EXPECT_EQ(lib_core, parsed->class_path_string_); |
Brian Carlstrom | 223f20f | 2012-02-04 23:06:55 -0800 | [diff] [blame] | 62 | EXPECT_EQ(std::string("boot_image"), parsed->image_); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 63 | EXPECT_EQ(true, parsed->check_jni_); |
| 64 | EXPECT_EQ(2048U, parsed->heap_initial_size_); |
| 65 | EXPECT_EQ(4 * KB, parsed->heap_maximum_size_); |
| 66 | EXPECT_EQ(1 * MB, parsed->stack_size_); |
Ian Rogers | 647b1a8 | 2014-10-10 11:02:11 -0700 | [diff] [blame] | 67 | EXPECT_DOUBLE_EQ(0.75, parsed->heap_target_utilization_); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 68 | EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_); |
| 69 | EXPECT_TRUE(test_exit == parsed->hook_exit_); |
| 70 | EXPECT_TRUE(test_abort == parsed->hook_abort_); |
Elliott Hughes | 4dd9b4d | 2011-12-12 18:29:24 -0800 | [diff] [blame] | 71 | EXPECT_TRUE(VLOG_IS_ON(class_linker)); |
| 72 | EXPECT_FALSE(VLOG_IS_ON(compiler)); |
| 73 | EXPECT_FALSE(VLOG_IS_ON(heap)); |
| 74 | EXPECT_TRUE(VLOG_IS_ON(gc)); |
| 75 | EXPECT_FALSE(VLOG_IS_ON(jdwp)); |
| 76 | EXPECT_TRUE(VLOG_IS_ON(jni)); |
| 77 | EXPECT_FALSE(VLOG_IS_ON(monitor)); |
| 78 | EXPECT_FALSE(VLOG_IS_ON(startup)); |
| 79 | EXPECT_FALSE(VLOG_IS_ON(third_party_jni)); |
| 80 | EXPECT_FALSE(VLOG_IS_ON(threads)); |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 81 | ASSERT_EQ(2U, parsed->properties_.size()); |
| 82 | EXPECT_EQ("foo=bar", parsed->properties_[0]); |
| 83 | EXPECT_EQ("baz=qux", parsed->properties_[1]); |
| 84 | } |
| 85 | |
| 86 | } // namespace art |