blob: ce035714868a7f13665458a5c30bb4291cbcc2fa [file] [log] [blame]
Carl Shapirofc322c72011-07-27 00:20:01 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
Brian Carlstromdb4d5402011-08-09 12:18:28 -07003#include "runtime.h"
Elliott Hughes90a33692011-08-30 13:27:07 -07004
5#include "UniquePtr.h"
Brian Carlstromf734cf52011-08-17 16:28:14 -07006#include "common_test.h"
Carl Shapirofc322c72011-07-27 00:20:01 -07007
8namespace art {
Carl Shapirofc322c72011-07-27 00:20:01 -07009
Brian Carlstromf734cf52011-08-17 16:28:14 -070010class RuntimeTest : public CommonTest {};
Carl Shapirofc322c72011-07-27 00:20:01 -070011
Brian Carlstromf734cf52011-08-17 16:28:14 -070012TEST_F(RuntimeTest, ParsedOptions) {
13 void* test_vfprintf = reinterpret_cast<void*>(0xa);
14 void* test_abort = reinterpret_cast<void*>(0xb);
15 void* test_exit = reinterpret_cast<void*>(0xc);
16 void* null = reinterpret_cast<void*>(NULL);
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070017
18 std::string lib_core = GetLibCoreDexFileName();
19
20 std::string boot_class_path;
21 boot_class_path += "-Xbootclasspath:";
22 boot_class_path += lib_core;
Brian Carlstromf734cf52011-08-17 16:28:14 -070023
24 Runtime::Options options;
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070025 options.push_back(std::make_pair(boot_class_path.c_str(), null));
26 options.push_back(std::make_pair("-classpath", null));
27 options.push_back(std::make_pair(lib_core.c_str(), null));
28 options.push_back(std::make_pair("-cp", null));
29 options.push_back(std::make_pair(lib_core.c_str(), null));
Brian Carlstrom58ae9412011-10-04 00:56:06 -070030 options.push_back(std::make_pair("-Ximage:boot_image", null));
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070031 options.push_back(std::make_pair("-Ximage:image_1", null));
32 options.push_back(std::make_pair("-Ximage:image_2", null));
Brian Carlstromf734cf52011-08-17 16:28:14 -070033 options.push_back(std::make_pair("-Xcheck:jni", null));
34 options.push_back(std::make_pair("-Xms2048", null));
35 options.push_back(std::make_pair("-Xmx4k", null));
36 options.push_back(std::make_pair("-Xss1m", null));
37 options.push_back(std::make_pair("-Dfoo=bar", null));
38 options.push_back(std::make_pair("-Dbaz=qux", null));
39 options.push_back(std::make_pair("-verbose:gc,class,jni", null));
Brian Carlstrom58ae9412011-10-04 00:56:06 -070040 options.push_back(std::make_pair("host-prefix", "host_prefix"));
Brian Carlstromf734cf52011-08-17 16:28:14 -070041 options.push_back(std::make_pair("vfprintf", test_vfprintf));
42 options.push_back(std::make_pair("abort", test_abort));
43 options.push_back(std::make_pair("exit", test_exit));
Elliott Hughes90a33692011-08-30 13:27:07 -070044 UniquePtr<Runtime::ParsedOptions> parsed(Runtime::ParsedOptions::Create(options, false));
45 ASSERT_TRUE(parsed.get() != NULL);
Brian Carlstromf734cf52011-08-17 16:28:14 -070046
Brian Carlstrom58ae9412011-10-04 00:56:06 -070047 EXPECT_EQ(lib_core, parsed->boot_class_path_);
48 EXPECT_EQ(lib_core, parsed->class_path_);
49 EXPECT_EQ(3U, parsed->images_.size());
50 EXPECT_EQ(std::string("boot_image"), parsed->images_[0]);
51 EXPECT_EQ(std::string("image_1"), parsed->images_[1]);
52 EXPECT_EQ(std::string("image_2"), parsed->images_[2]);
Brian Carlstromf734cf52011-08-17 16:28:14 -070053 EXPECT_EQ(true, parsed->check_jni_);
54 EXPECT_EQ(2048U, parsed->heap_initial_size_);
55 EXPECT_EQ(4 * KB, parsed->heap_maximum_size_);
56 EXPECT_EQ(1 * MB, parsed->stack_size_);
Brian Carlstrom58ae9412011-10-04 00:56:06 -070057 EXPECT_EQ("host_prefix", parsed->host_prefix_);
Brian Carlstromf734cf52011-08-17 16:28:14 -070058 EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_);
59 EXPECT_TRUE(test_exit == parsed->hook_exit_);
60 EXPECT_TRUE(test_abort == parsed->hook_abort_);
61 ASSERT_EQ(3U, parsed->verbose_.size());
62 EXPECT_TRUE(parsed->verbose_.find("gc") != parsed->verbose_.end());
63 EXPECT_TRUE(parsed->verbose_.find("class") != parsed->verbose_.end());
64 EXPECT_TRUE(parsed->verbose_.find("jni") != parsed->verbose_.end());
65 ASSERT_EQ(2U, parsed->properties_.size());
66 EXPECT_EQ("foo=bar", parsed->properties_[0]);
67 EXPECT_EQ("baz=qux", parsed->properties_[1]);
68}
69
70} // namespace art