Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 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 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 21 | #include "base/enums.h" |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 22 | |
| 23 | namespace art { |
| 24 | |
| 25 | TEST(InstructionSetTest, GetInstructionSetFromString) { |
| 26 | EXPECT_EQ(kArm, GetInstructionSetFromString("arm")); |
| 27 | EXPECT_EQ(kArm64, GetInstructionSetFromString("arm64")); |
| 28 | EXPECT_EQ(kX86, GetInstructionSetFromString("x86")); |
| 29 | EXPECT_EQ(kX86_64, GetInstructionSetFromString("x86_64")); |
| 30 | EXPECT_EQ(kMips, GetInstructionSetFromString("mips")); |
Andreas Gampe | 57b3429 | 2015-01-14 15:45:59 -0800 | [diff] [blame] | 31 | EXPECT_EQ(kMips64, GetInstructionSetFromString("mips64")); |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 32 | EXPECT_EQ(kNone, GetInstructionSetFromString("none")); |
| 33 | EXPECT_EQ(kNone, GetInstructionSetFromString("random-string")); |
| 34 | } |
| 35 | |
| 36 | TEST(InstructionSetTest, GetInstructionSetString) { |
| 37 | EXPECT_STREQ("arm", GetInstructionSetString(kArm)); |
| 38 | EXPECT_STREQ("arm", GetInstructionSetString(kThumb2)); |
| 39 | EXPECT_STREQ("arm64", GetInstructionSetString(kArm64)); |
| 40 | EXPECT_STREQ("x86", GetInstructionSetString(kX86)); |
| 41 | EXPECT_STREQ("x86_64", GetInstructionSetString(kX86_64)); |
| 42 | EXPECT_STREQ("mips", GetInstructionSetString(kMips)); |
Andreas Gampe | 57b3429 | 2015-01-14 15:45:59 -0800 | [diff] [blame] | 43 | EXPECT_STREQ("mips64", GetInstructionSetString(kMips64)); |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 44 | EXPECT_STREQ("none", GetInstructionSetString(kNone)); |
| 45 | } |
| 46 | |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 47 | TEST(InstructionSetTest, GetInstructionSetInstructionAlignment) { |
| 48 | EXPECT_EQ(GetInstructionSetInstructionAlignment(kThumb2), kThumb2InstructionAlignment); |
| 49 | EXPECT_EQ(GetInstructionSetInstructionAlignment(kArm64), kArm64InstructionAlignment); |
| 50 | EXPECT_EQ(GetInstructionSetInstructionAlignment(kX86), kX86InstructionAlignment); |
| 51 | EXPECT_EQ(GetInstructionSetInstructionAlignment(kX86_64), kX86_64InstructionAlignment); |
| 52 | EXPECT_EQ(GetInstructionSetInstructionAlignment(kMips), kMipsInstructionAlignment); |
| 53 | EXPECT_EQ(GetInstructionSetInstructionAlignment(kMips64), kMips64InstructionAlignment); |
| 54 | } |
| 55 | |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 56 | TEST(InstructionSetTest, TestRoundTrip) { |
| 57 | EXPECT_EQ(kRuntimeISA, GetInstructionSetFromString(GetInstructionSetString(kRuntimeISA))); |
| 58 | } |
| 59 | |
| 60 | TEST(InstructionSetTest, PointerSize) { |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 61 | EXPECT_EQ(kRuntimePointerSize, GetInstructionSetPointerSize(kRuntimeISA)); |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | } // namespace art |