blob: 5154d69292f8ad7e7b87fdf42331de565c3dc9da [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
Elliott Hughes95572412011-12-13 18:14:20 -080033 std::string lib_core(GetLibCoreDexFileName());
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070034
35 std::string boot_class_path;
36 boot_class_path += "-Xbootclasspath:";
37 boot_class_path += lib_core;
Brian Carlstromf734cf52011-08-17 16:28:14 -070038
Ian Rogerse63db272014-07-15 15:36:11 -070039 RuntimeOptions options;
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070040 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 Carlstrom58ae9412011-10-04 00:56:06 -070045 options.push_back(std::make_pair("-Ximage:boot_image", null));
Brian Carlstromf734cf52011-08-17 16:28:14 -070046 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 Carlstrombd86bcc2013-03-10 20:26:16 -070050 options.push_back(std::make_pair("-XX:HeapTargetUtilization=0.75", null));
Brian Carlstromf734cf52011-08-17 16:28:14 -070051 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 Rogers700a4022014-05-19 16:49:03 -070057 std::unique_ptr<ParsedOptions> parsed(ParsedOptions::Create(options, false));
Elliott Hughes90a33692011-08-30 13:27:07 -070058 ASSERT_TRUE(parsed.get() != NULL);
Brian Carlstromf734cf52011-08-17 16:28:14 -070059
Brian Carlstroma004aa92012-02-08 18:05:09 -080060 EXPECT_EQ(lib_core, parsed->boot_class_path_string_);
61 EXPECT_EQ(lib_core, parsed->class_path_string_);
Brian Carlstrom223f20f2012-02-04 23:06:55 -080062 EXPECT_EQ(std::string("boot_image"), parsed->image_);
Brian Carlstromf734cf52011-08-17 16:28:14 -070063 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_);
Brian Carlstrombd86bcc2013-03-10 20:26:16 -070067 EXPECT_EQ(0.75, parsed->heap_target_utilization_);
Brian Carlstromf734cf52011-08-17 16:28:14 -070068 EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_);
69 EXPECT_TRUE(test_exit == parsed->hook_exit_);
70 EXPECT_TRUE(test_abort == parsed->hook_abort_);
Elliott Hughes4dd9b4d2011-12-12 18:29:24 -080071 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 Carlstromf734cf52011-08-17 16:28:14 -070081 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