blob: 12a117d7a1001c5625d458802c7fb290face9f2b [file] [log] [blame]
Ian Rogersd582fa42014-11-05 23:46:43 -08001/*
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 Gampe542451c2016-07-26 09:02:02 -070021#include "base/enums.h"
Ian Rogersd582fa42014-11-05 23:46:43 -080022
23namespace art {
24
25TEST(InstructionSetTest, GetInstructionSetFromString) {
Vladimir Marko33bff252017-11-01 14:35:42 +000026 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::kMips, GetInstructionSetFromString("mips"));
31 EXPECT_EQ(InstructionSet::kMips64, GetInstructionSetFromString("mips64"));
32 EXPECT_EQ(InstructionSet::kNone, GetInstructionSetFromString("none"));
33 EXPECT_EQ(InstructionSet::kNone, GetInstructionSetFromString("random-string"));
Ian Rogersd582fa42014-11-05 23:46:43 -080034}
35
36TEST(InstructionSetTest, GetInstructionSetString) {
Vladimir Marko33bff252017-11-01 14:35:42 +000037 EXPECT_STREQ("arm", GetInstructionSetString(InstructionSet::kArm));
38 EXPECT_STREQ("arm", GetInstructionSetString(InstructionSet::kThumb2));
39 EXPECT_STREQ("arm64", GetInstructionSetString(InstructionSet::kArm64));
40 EXPECT_STREQ("x86", GetInstructionSetString(InstructionSet::kX86));
41 EXPECT_STREQ("x86_64", GetInstructionSetString(InstructionSet::kX86_64));
42 EXPECT_STREQ("mips", GetInstructionSetString(InstructionSet::kMips));
43 EXPECT_STREQ("mips64", GetInstructionSetString(InstructionSet::kMips64));
44 EXPECT_STREQ("none", GetInstructionSetString(InstructionSet::kNone));
Ian Rogersd582fa42014-11-05 23:46:43 -080045}
46
Mathieu Chartiera2f526f2017-01-19 14:48:48 -080047TEST(InstructionSetTest, GetInstructionSetInstructionAlignment) {
Vladimir Marko33bff252017-11-01 14:35:42 +000048 EXPECT_EQ(GetInstructionSetInstructionAlignment(InstructionSet::kThumb2),
49 kThumb2InstructionAlignment);
50 EXPECT_EQ(GetInstructionSetInstructionAlignment(InstructionSet::kArm64),
51 kArm64InstructionAlignment);
52 EXPECT_EQ(GetInstructionSetInstructionAlignment(InstructionSet::kX86),
53 kX86InstructionAlignment);
54 EXPECT_EQ(GetInstructionSetInstructionAlignment(InstructionSet::kX86_64),
55 kX86_64InstructionAlignment);
56 EXPECT_EQ(GetInstructionSetInstructionAlignment(InstructionSet::kMips),
57 kMipsInstructionAlignment);
58 EXPECT_EQ(GetInstructionSetInstructionAlignment(InstructionSet::kMips64),
59 kMips64InstructionAlignment);
Mathieu Chartiera2f526f2017-01-19 14:48:48 -080060}
61
Ian Rogersd582fa42014-11-05 23:46:43 -080062TEST(InstructionSetTest, TestRoundTrip) {
63 EXPECT_EQ(kRuntimeISA, GetInstructionSetFromString(GetInstructionSetString(kRuntimeISA)));
64}
65
66TEST(InstructionSetTest, PointerSize) {
Andreas Gampe542451c2016-07-26 09:02:02 -070067 EXPECT_EQ(kRuntimePointerSize, GetInstructionSetPointerSize(kRuntimeISA));
Ian Rogersd582fa42014-11-05 23:46:43 -080068}
69
70} // namespace art