• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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  */
16 
17 #include "compiler_filter.h"
18 
19 #include <gtest/gtest.h>
20 
21 namespace art {
22 
TestCompilerFilterName(CompilerFilter::Filter filter,std::string name)23 static void TestCompilerFilterName(CompilerFilter::Filter filter, std::string name) {
24   CompilerFilter::Filter parsed;
25   EXPECT_TRUE(CompilerFilter::ParseCompilerFilter(name.c_str(), &parsed));
26   EXPECT_EQ(filter, parsed);
27 
28   EXPECT_EQ(name, CompilerFilter::NameOfFilter(filter));
29 }
30 
31 // Verify the dexopt status values from dalvik.system.DexFile
32 // match the OatFileAssistant::DexOptStatus values.
TEST(CompilerFilterTest,ParseCompilerFilter)33 TEST(CompilerFilterTest, ParseCompilerFilter) {
34   CompilerFilter::Filter filter;
35 
36   TestCompilerFilterName(CompilerFilter::kVerifyNone, "verify-none");
37   TestCompilerFilterName(CompilerFilter::kVerifyAtRuntime, "verify-at-runtime");
38   TestCompilerFilterName(CompilerFilter::kVerifyProfile, "verify-profile");
39   TestCompilerFilterName(CompilerFilter::kInterpretOnly, "interpret-only");
40   TestCompilerFilterName(CompilerFilter::kTime, "time");
41   TestCompilerFilterName(CompilerFilter::kSpaceProfile, "space-profile");
42   TestCompilerFilterName(CompilerFilter::kSpace, "space");
43   TestCompilerFilterName(CompilerFilter::kBalanced, "balanced");
44   TestCompilerFilterName(CompilerFilter::kSpeedProfile, "speed-profile");
45   TestCompilerFilterName(CompilerFilter::kSpeed, "speed");
46   TestCompilerFilterName(CompilerFilter::kEverythingProfile, "everything-profile");
47   TestCompilerFilterName(CompilerFilter::kEverything, "everything");
48 
49   EXPECT_FALSE(CompilerFilter::ParseCompilerFilter("super-awesome-filter", &filter));
50 }
51 
52 }  // namespace art
53