blob: 460fe44be1d8f1541576ae79743a75b54b36c195 [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 Carlstromdb4d5402011-08-09 12:18:28 -070017#include "runtime.h"
Elliott Hughes90a33692011-08-30 13:27:07 -070018
19#include "UniquePtr.h"
Brian Carlstromf734cf52011-08-17 16:28:14 -070020#include "common_test.h"
Carl Shapirofc322c72011-07-27 00:20:01 -070021
22namespace art {
Carl Shapirofc322c72011-07-27 00:20:01 -070023
Brian Carlstromf734cf52011-08-17 16:28:14 -070024class RuntimeTest : public CommonTest {};
Carl Shapirofc322c72011-07-27 00:20:01 -070025
Brian Carlstromf734cf52011-08-17 16:28:14 -070026TEST_F(RuntimeTest, ParsedOptions) {
27 void* test_vfprintf = reinterpret_cast<void*>(0xa);
28 void* test_abort = reinterpret_cast<void*>(0xb);
29 void* test_exit = reinterpret_cast<void*>(0xc);
30 void* null = reinterpret_cast<void*>(NULL);
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070031
Elliott Hughes95572412011-12-13 18:14:20 -080032 std::string lib_core(GetLibCoreDexFileName());
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070033
34 std::string boot_class_path;
35 boot_class_path += "-Xbootclasspath:";
36 boot_class_path += lib_core;
Brian Carlstromf734cf52011-08-17 16:28:14 -070037
38 Runtime::Options options;
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070039 options.push_back(std::make_pair(boot_class_path.c_str(), null));
40 options.push_back(std::make_pair("-classpath", null));
41 options.push_back(std::make_pair(lib_core.c_str(), null));
42 options.push_back(std::make_pair("-cp", null));
43 options.push_back(std::make_pair(lib_core.c_str(), null));
Brian Carlstrom58ae9412011-10-04 00:56:06 -070044 options.push_back(std::make_pair("-Ximage:boot_image", null));
Brian Carlstromf734cf52011-08-17 16:28:14 -070045 options.push_back(std::make_pair("-Xcheck:jni", null));
46 options.push_back(std::make_pair("-Xms2048", null));
47 options.push_back(std::make_pair("-Xmx4k", null));
48 options.push_back(std::make_pair("-Xss1m", null));
49 options.push_back(std::make_pair("-Dfoo=bar", null));
50 options.push_back(std::make_pair("-Dbaz=qux", null));
51 options.push_back(std::make_pair("-verbose:gc,class,jni", null));
Brian Carlstrom58ae9412011-10-04 00:56:06 -070052 options.push_back(std::make_pair("host-prefix", "host_prefix"));
Brian Carlstromf734cf52011-08-17 16:28:14 -070053 options.push_back(std::make_pair("vfprintf", test_vfprintf));
54 options.push_back(std::make_pair("abort", test_abort));
55 options.push_back(std::make_pair("exit", test_exit));
Elliott Hughes90a33692011-08-30 13:27:07 -070056 UniquePtr<Runtime::ParsedOptions> parsed(Runtime::ParsedOptions::Create(options, false));
57 ASSERT_TRUE(parsed.get() != NULL);
Brian Carlstromf734cf52011-08-17 16:28:14 -070058
Brian Carlstrom58ae9412011-10-04 00:56:06 -070059 EXPECT_EQ(lib_core, parsed->boot_class_path_);
60 EXPECT_EQ(lib_core, parsed->class_path_);
Brian Carlstrom223f20f2012-02-04 23:06:55 -080061 EXPECT_EQ(std::string("boot_image"), parsed->image_);
Brian Carlstromf734cf52011-08-17 16:28:14 -070062 EXPECT_EQ(true, parsed->check_jni_);
63 EXPECT_EQ(2048U, parsed->heap_initial_size_);
64 EXPECT_EQ(4 * KB, parsed->heap_maximum_size_);
65 EXPECT_EQ(1 * MB, parsed->stack_size_);
Brian Carlstrom58ae9412011-10-04 00:56:06 -070066 EXPECT_EQ("host_prefix", parsed->host_prefix_);
Brian Carlstromf734cf52011-08-17 16:28:14 -070067 EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_);
68 EXPECT_TRUE(test_exit == parsed->hook_exit_);
69 EXPECT_TRUE(test_abort == parsed->hook_abort_);
Elliott Hughes4dd9b4d2011-12-12 18:29:24 -080070 EXPECT_TRUE(VLOG_IS_ON(class_linker));
71 EXPECT_FALSE(VLOG_IS_ON(compiler));
72 EXPECT_FALSE(VLOG_IS_ON(heap));
73 EXPECT_TRUE(VLOG_IS_ON(gc));
74 EXPECT_FALSE(VLOG_IS_ON(jdwp));
75 EXPECT_TRUE(VLOG_IS_ON(jni));
76 EXPECT_FALSE(VLOG_IS_ON(monitor));
77 EXPECT_FALSE(VLOG_IS_ON(startup));
78 EXPECT_FALSE(VLOG_IS_ON(third_party_jni));
79 EXPECT_FALSE(VLOG_IS_ON(threads));
Brian Carlstromf734cf52011-08-17 16:28:14 -070080 ASSERT_EQ(2U, parsed->properties_.size());
81 EXPECT_EQ("foo=bar", parsed->properties_[0]);
82 EXPECT_EQ("baz=qux", parsed->properties_[1]);
83}
84
85} // namespace art