From a00f012660e9a4baa34c0ab96042f7146e9a6017 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Wed, 16 Dec 2015 16:54:35 -0800 Subject: ART: Refactor CommonRuntimeTest::SetUp Factor out finishing up the runtime. This code will execute the interpreter to initialize important classes etc., which is not necessary for testing RuntimeMethod sizes and trampoline entrypoints, in fact it may violate pointer-size invariants. Also add InstructionSet parsing tests to the ParsedOptions test. Change-Id: I75cd00c6d358e1bc962c8f1845244f6400c1cd6c --- runtime/parsed_options_test.cc | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'runtime/parsed_options_test.cc') diff --git a/runtime/parsed_options_test.cc b/runtime/parsed_options_test.cc index 06b40fd925..c32d76c715 100644 --- a/runtime/parsed_options_test.cc +++ b/runtime/parsed_options_test.cc @@ -18,6 +18,8 @@ #include +#include "arch/instruction_set.h" +#include "base/stringprintf.h" #include "common_runtime_test.h" namespace art { @@ -113,6 +115,40 @@ TEST_F(ParsedOptionsTest, ParsedOptionsGc) { EXPECT_TRUE(map.Exists(Opt::GcOption)); XGcOption xgc = map.GetOrDefault(Opt::GcOption); - EXPECT_EQ(gc::kCollectorTypeMC, xgc.collector_type_);} + EXPECT_EQ(gc::kCollectorTypeMC, xgc.collector_type_); +} + +TEST_F(ParsedOptionsTest, ParsedOptionsInstructionSet) { + using Opt = RuntimeArgumentMap; + + { + // Nothing set, should be kRuntimeISA. + RuntimeOptions options; + RuntimeArgumentMap map; + bool parsed = ParsedOptions::Parse(options, false, &map); + ASSERT_TRUE(parsed); + InstructionSet isa = map.GetOrDefault(Opt::ImageInstructionSet); + EXPECT_EQ(kRuntimeISA, isa); + } + + const char* isa_strings[] = { "arm", "arm64", "x86", "x86_64", "mips", "mips64" }; + InstructionSet ISAs[] = { InstructionSet::kArm, + InstructionSet::kArm64, + InstructionSet::kX86, + InstructionSet::kX86_64, + InstructionSet::kMips, + InstructionSet::kMips64 }; + static_assert(arraysize(isa_strings) == arraysize(ISAs), "Need same amount."); + + for (size_t i = 0; i < arraysize(isa_strings); ++i) { + RuntimeOptions options; + options.push_back(std::make_pair("imageinstructionset", isa_strings[i])); + RuntimeArgumentMap map; + bool parsed = ParsedOptions::Parse(options, false, &map); + ASSERT_TRUE(parsed); + InstructionSet isa = map.GetOrDefault(Opt::ImageInstructionSet); + EXPECT_EQ(ISAs[i], isa); + } +} } // namespace art -- cgit v1.2.3-59-g8ed1b