7c5a675298c12735c109bc639faa8c5b0d6c89b0
[iec.git] / src / type3_AndroidCloud / anbox-master / external / cpu_features / test / cpuinfo_mips_test.cc
1 // Copyright 2017 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "cpuinfo_mips.h"
16 #include "filesystem_for_testing.h"
17 #include "hwcaps_for_testing.h"
18 #include "internal/stack_line_reader.h"
19 #include "internal/string_view.h"
20
21 #include "gtest/gtest.h"
22
23 namespace cpu_features {
24
25 namespace {
26
27 void DisableHardwareCapabilities() { SetHardwareCapabilities(0, 0); }
28
29 TEST(CpuinfoMipsTest, FromHardwareCapBoth) {
30   SetHardwareCapabilities(MIPS_HWCAP_EVA | MIPS_HWCAP_MSA, 0);
31   GetEmptyFilesystem();  // disabling /proc/cpuinfo
32   const auto info = GetMipsInfo();
33   EXPECT_TRUE(info.features.msa);
34   EXPECT_TRUE(info.features.eva);
35 }
36
37 TEST(CpuinfoMipsTest, FromHardwareCapOnlyOne) {
38   SetHardwareCapabilities(MIPS_HWCAP_MSA, 0);
39   GetEmptyFilesystem();  // disabling /proc/cpuinfo
40   const auto info = GetMipsInfo();
41   EXPECT_TRUE(info.features.msa);
42   EXPECT_FALSE(info.features.eva);
43 }
44
45 TEST(CpuinfoMipsTest, Ci40) {
46   DisableHardwareCapabilities();
47   auto& fs = GetEmptyFilesystem();
48   fs.CreateFile("/proc/cpuinfo", R"(system type : IMG Pistachio SoC (B0)
49 machine : IMG Marduk – Ci40 with cc2520
50 processor : 0
51 cpu model : MIPS interAptiv (multi) V2.0 FPU V0.0
52 BogoMIPS : 363.72
53 wait instruction : yes
54 microsecond timers : yes
55 tlb_entries : 64
56 extra interrupt vector : yes
57 hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
58 isa : mips1 mips2 mips32r1 mips32r2
59 ASEs implemented : mips16 dsp mt eva
60 shadow register sets : 1
61 kscratch registers : 0
62 package : 0
63 core : 0
64 VCED exceptions : not available
65 VCEI exceptions : not available
66 VPE : 0
67 )");
68   const auto info = GetMipsInfo();
69   EXPECT_FALSE(info.features.msa);
70   EXPECT_TRUE(info.features.eva);
71 }
72
73 TEST(CpuinfoMipsTest, AR7161) {
74   DisableHardwareCapabilities();
75   auto& fs = GetEmptyFilesystem();
76   fs.CreateFile("/proc/cpuinfo",
77                 R"(system type             : Atheros AR7161 rev 2
78 machine                 : NETGEAR WNDR3700/WNDR3800/WNDRMAC
79 processor               : 0
80 cpu model               : MIPS 24Kc V7.4
81 BogoMIPS                : 452.19
82 wait instruction        : yes
83 microsecond timers      : yes
84 tlb_entries             : 16
85 extra interrupt vector  : yes
86 hardware watchpoint     : yes, count: 4, address/irw mask: [0x0000, 0x0f98, 0x0f78, 0x0df8]
87 ASEs implemented        : mips16
88 shadow register sets    : 1
89 kscratch registers      : 0
90 core                    : 0
91 VCED exceptions         : not available
92 VCEI exceptions         : not available
93 )");
94   const auto info = GetMipsInfo();
95   EXPECT_FALSE(info.features.msa);
96   EXPECT_FALSE(info.features.eva);
97 }
98
99 TEST(CpuinfoMipsTest, Goldfish) {
100   DisableHardwareCapabilities();
101   auto& fs = GetEmptyFilesystem();
102   fs.CreateFile("/proc/cpuinfo", R"(system type         : MIPS-Goldfish
103 Hardware                : goldfish
104 Revison         : 1
105 processor               : 0
106 cpu model               : MIPS 24Kc V0.0  FPU V0.0
107 BogoMIPS                : 1042.02
108 wait instruction        : yes
109 microsecond timers      : yes
110 tlb_entries             : 16
111 extra interrupt vector  : yes
112 hardware watchpoint     : yes, count: 1, address/irw mask: [0x0ff8]
113 ASEs implemented        :
114 shadow register sets    : 1
115 core                    : 0
116 VCED exceptions         : not available
117 VCEI exceptions         : not available
118 )");
119   const auto info = GetMipsInfo();
120   EXPECT_FALSE(info.features.msa);
121   EXPECT_FALSE(info.features.eva);
122 }
123
124 }  // namespace
125 }  // namespace cpu_features