blob: 59e39d68fe41476aeb5d5622122cb3123e37dda5 [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"
Brian Carlstromf734cf52011-08-17 16:28:14 -07004#include "common_test.h"
Carl Shapirofc322c72011-07-27 00:20:01 -07005
6namespace art {
Carl Shapirofc322c72011-07-27 00:20:01 -07007
Brian Carlstromf734cf52011-08-17 16:28:14 -07008class RuntimeTest : public CommonTest {};
Carl Shapirofc322c72011-07-27 00:20:01 -07009
Brian Carlstromf734cf52011-08-17 16:28:14 -070010TEST_F(RuntimeTest, ParsedOptions) {
11 void* test_vfprintf = reinterpret_cast<void*>(0xa);
12 void* test_abort = reinterpret_cast<void*>(0xb);
13 void* test_exit = reinterpret_cast<void*>(0xc);
14 void* null = reinterpret_cast<void*>(NULL);
Brian Carlstromf734cf52011-08-17 16:28:14 -070015 std::vector<const DexFile*> boot_class_path;
16 boot_class_path.push_back(java_lang_dex_file_.get());
17
18 Runtime::Options options;
19 options.push_back(std::make_pair("-Xbootclasspath:class_path_foo:class_path_bar", null));
20 options.push_back(std::make_pair("bootclasspath", &boot_class_path));
21 options.push_back(std::make_pair("-Xbootimage:boot_image", null));
22 options.push_back(std::make_pair("-Xcheck:jni", null));
23 options.push_back(std::make_pair("-Xms2048", null));
24 options.push_back(std::make_pair("-Xmx4k", null));
25 options.push_back(std::make_pair("-Xss1m", null));
26 options.push_back(std::make_pair("-Dfoo=bar", null));
27 options.push_back(std::make_pair("-Dbaz=qux", null));
28 options.push_back(std::make_pair("-verbose:gc,class,jni", null));
29 options.push_back(std::make_pair("vfprintf", test_vfprintf));
30 options.push_back(std::make_pair("abort", test_abort));
31 options.push_back(std::make_pair("exit", test_exit));
32 scoped_ptr<Runtime::ParsedOptions> parsed(Runtime::ParsedOptions::Create(options, false));
33 ASSERT_TRUE(parsed != NULL);
34
35 EXPECT_EQ(1U, parsed->boot_class_path_.size()); // bootclasspath overrides -Xbootclasspath
36 EXPECT_STREQ("boot_image", parsed->boot_image_);
37 EXPECT_EQ(true, parsed->check_jni_);
38 EXPECT_EQ(2048U, parsed->heap_initial_size_);
39 EXPECT_EQ(4 * KB, parsed->heap_maximum_size_);
40 EXPECT_EQ(1 * MB, parsed->stack_size_);
41 EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_);
42 EXPECT_TRUE(test_exit == parsed->hook_exit_);
43 EXPECT_TRUE(test_abort == parsed->hook_abort_);
44 ASSERT_EQ(3U, parsed->verbose_.size());
45 EXPECT_TRUE(parsed->verbose_.find("gc") != parsed->verbose_.end());
46 EXPECT_TRUE(parsed->verbose_.find("class") != parsed->verbose_.end());
47 EXPECT_TRUE(parsed->verbose_.find("jni") != parsed->verbose_.end());
48 ASSERT_EQ(2U, parsed->properties_.size());
49 EXPECT_EQ("foo=bar", parsed->properties_[0]);
50 EXPECT_EQ("baz=qux", parsed->properties_[1]);
51}
52
53} // namespace art