• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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 "instruction_set.h"
18 
19 #include <gtest/gtest.h>
20 
21 #include "base/enums.h"
22 
23 namespace art {
24 
TEST(InstructionSetTest,GetInstructionSetFromString)25 TEST(InstructionSetTest, GetInstructionSetFromString) {
26   EXPECT_EQ(InstructionSet::kArm, GetInstructionSetFromString("arm"));
27   EXPECT_EQ(InstructionSet::kArm64, GetInstructionSetFromString("arm64"));
28   EXPECT_EQ(InstructionSet::kX86, GetInstructionSetFromString("x86"));
29   EXPECT_EQ(InstructionSet::kX86_64, GetInstructionSetFromString("x86_64"));
30   EXPECT_EQ(InstructionSet::kNone, GetInstructionSetFromString("none"));
31   EXPECT_EQ(InstructionSet::kNone, GetInstructionSetFromString("random-string"));
32 }
33 
TEST(InstructionSetTest,GetInstructionSetString)34 TEST(InstructionSetTest, GetInstructionSetString) {
35   EXPECT_STREQ("arm", GetInstructionSetString(InstructionSet::kArm));
36   EXPECT_STREQ("arm", GetInstructionSetString(InstructionSet::kThumb2));
37   EXPECT_STREQ("arm64", GetInstructionSetString(InstructionSet::kArm64));
38   EXPECT_STREQ("x86", GetInstructionSetString(InstructionSet::kX86));
39   EXPECT_STREQ("x86_64", GetInstructionSetString(InstructionSet::kX86_64));
40   EXPECT_STREQ("none", GetInstructionSetString(InstructionSet::kNone));
41 }
42 
TEST(InstructionSetTest,GetInstructionSetInstructionAlignment)43 TEST(InstructionSetTest, GetInstructionSetInstructionAlignment) {
44   EXPECT_EQ(GetInstructionSetInstructionAlignment(InstructionSet::kThumb2),
45             kThumb2InstructionAlignment);
46   EXPECT_EQ(GetInstructionSetInstructionAlignment(InstructionSet::kArm64),
47             kArm64InstructionAlignment);
48   EXPECT_EQ(GetInstructionSetInstructionAlignment(InstructionSet::kX86),
49             kX86InstructionAlignment);
50   EXPECT_EQ(GetInstructionSetInstructionAlignment(InstructionSet::kX86_64),
51             kX86_64InstructionAlignment);
52 }
53 
TEST(InstructionSetTest,TestRoundTrip)54 TEST(InstructionSetTest, TestRoundTrip) {
55   EXPECT_EQ(kRuntimeISA, GetInstructionSetFromString(GetInstructionSetString(kRuntimeISA)));
56 }
57 
TEST(InstructionSetTest,PointerSize)58 TEST(InstructionSetTest, PointerSize) {
59   EXPECT_EQ(kRuntimePointerSize, GetInstructionSetPointerSize(kRuntimeISA));
60 }
61 
62 }  // namespace art
63