blob: e5cb30d1b3e0a9b12ba3b6f2e896a587a10cefe9 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
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 Shapirofc322c72011-07-27 00:20:01 -070016
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080017#include "parsed_options.h"
Elliott Hughes90a33692011-08-30 13:27:07 -070018
Ian Rogers700a4022014-05-19 16:49:03 -070019#include <memory>
20
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080021#include "common_runtime_test.h"
Carl Shapirofc322c72011-07-27 00:20:01 -070022
23namespace art {
Carl Shapirofc322c72011-07-27 00:20:01 -070024
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080025class ParsedOptionsTest : public CommonRuntimeTest {};
Carl Shapirofc322c72011-07-27 00:20:01 -070026
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080027TEST_F(ParsedOptionsTest, ParsedOptions) {
Brian Carlstromf734cf52011-08-17 16:28:14 -070028 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 Carlstrom69b15fb2011-09-03 12:25:21 -070032
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070033 std::string boot_class_path;
Przemyslaw Szczepaniak5b8e6e32015-09-30 14:40:33 +010034 std::string class_path;
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070035 boot_class_path += "-Xbootclasspath:";
Przemyslaw Szczepaniak5b8e6e32015-09-30 14:40:33 +010036
37 bool first_dex_file = true;
38 for (const std::string &dex_file_name : GetLibCoreDexFileNames()) {
39 if (!first_dex_file) {
40 class_path += ":";
41 } else {
42 first_dex_file = false;
43 }
44 class_path += dex_file_name;
45 }
46 boot_class_path += class_path;
Brian Carlstromf734cf52011-08-17 16:28:14 -070047
Ian Rogerse63db272014-07-15 15:36:11 -070048 RuntimeOptions options;
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070049 options.push_back(std::make_pair(boot_class_path.c_str(), null));
50 options.push_back(std::make_pair("-classpath", null));
Przemyslaw Szczepaniak5b8e6e32015-09-30 14:40:33 +010051 options.push_back(std::make_pair(class_path.c_str(), null));
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070052 options.push_back(std::make_pair("-cp", null));
Przemyslaw Szczepaniak5b8e6e32015-09-30 14:40:33 +010053 options.push_back(std::make_pair(class_path.c_str(), null));
Brian Carlstrom58ae9412011-10-04 00:56:06 -070054 options.push_back(std::make_pair("-Ximage:boot_image", null));
Brian Carlstromf734cf52011-08-17 16:28:14 -070055 options.push_back(std::make_pair("-Xcheck:jni", null));
56 options.push_back(std::make_pair("-Xms2048", null));
57 options.push_back(std::make_pair("-Xmx4k", null));
58 options.push_back(std::make_pair("-Xss1m", null));
Brian Carlstrombd86bcc2013-03-10 20:26:16 -070059 options.push_back(std::make_pair("-XX:HeapTargetUtilization=0.75", null));
Brian Carlstromf734cf52011-08-17 16:28:14 -070060 options.push_back(std::make_pair("-Dfoo=bar", null));
61 options.push_back(std::make_pair("-Dbaz=qux", null));
62 options.push_back(std::make_pair("-verbose:gc,class,jni", null));
63 options.push_back(std::make_pair("vfprintf", test_vfprintf));
64 options.push_back(std::make_pair("abort", test_abort));
65 options.push_back(std::make_pair("exit", test_exit));
Ian Rogers700a4022014-05-19 16:49:03 -070066 std::unique_ptr<ParsedOptions> parsed(ParsedOptions::Create(options, false));
Elliott Hughes90a33692011-08-30 13:27:07 -070067 ASSERT_TRUE(parsed.get() != NULL);
Brian Carlstromf734cf52011-08-17 16:28:14 -070068
Przemyslaw Szczepaniak5b8e6e32015-09-30 14:40:33 +010069 EXPECT_EQ(class_path, parsed->boot_class_path_string_);
70 EXPECT_EQ(class_path, parsed->class_path_string_);
Brian Carlstrom223f20f2012-02-04 23:06:55 -080071 EXPECT_EQ(std::string("boot_image"), parsed->image_);
Brian Carlstromf734cf52011-08-17 16:28:14 -070072 EXPECT_EQ(true, parsed->check_jni_);
73 EXPECT_EQ(2048U, parsed->heap_initial_size_);
74 EXPECT_EQ(4 * KB, parsed->heap_maximum_size_);
75 EXPECT_EQ(1 * MB, parsed->stack_size_);
Brian Carlstrombd86bcc2013-03-10 20:26:16 -070076 EXPECT_EQ(0.75, parsed->heap_target_utilization_);
Brian Carlstromf734cf52011-08-17 16:28:14 -070077 EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_);
78 EXPECT_TRUE(test_exit == parsed->hook_exit_);
79 EXPECT_TRUE(test_abort == parsed->hook_abort_);
Elliott Hughes4dd9b4d2011-12-12 18:29:24 -080080 EXPECT_TRUE(VLOG_IS_ON(class_linker));
81 EXPECT_FALSE(VLOG_IS_ON(compiler));
82 EXPECT_FALSE(VLOG_IS_ON(heap));
83 EXPECT_TRUE(VLOG_IS_ON(gc));
84 EXPECT_FALSE(VLOG_IS_ON(jdwp));
85 EXPECT_TRUE(VLOG_IS_ON(jni));
86 EXPECT_FALSE(VLOG_IS_ON(monitor));
87 EXPECT_FALSE(VLOG_IS_ON(startup));
88 EXPECT_FALSE(VLOG_IS_ON(third_party_jni));
89 EXPECT_FALSE(VLOG_IS_ON(threads));
Brian Carlstromf734cf52011-08-17 16:28:14 -070090 ASSERT_EQ(2U, parsed->properties_.size());
91 EXPECT_EQ("foo=bar", parsed->properties_[0]);
92 EXPECT_EQ("baz=qux", parsed->properties_[1]);
93}
94
95} // namespace art