1
0
mirror of https://github.com/google/cpu_features.git synced 2025-07-01 21:31:15 +02:00

S390X Support (#274)

* support for s390x

* added z15 T01, T02 model checking

* removed z15 checking

* removed empty strings

* added s390x unit tests

* added reference url for hwcaps

* moved documentation to S390XFeatures struct, updated copyright date, removed unused include statement

* changed num_processors to int

* removed newlines from test inputs

* scripts: Add bootlin s390x support

* cmake(ci): Add s390x support

* ci: Add s390x workflow

Co-authored-by: Marcos <marcos.araque.fiallos@ibm.com>
Co-authored-by: Corentin Le Molgat <corentinl@google.com>
This commit is contained in:
marquitos0119
2022-11-02 03:38:13 -05:00
committed by GitHub
parent bddcc3721c
commit 981fbe3914
11 changed files with 457 additions and 1 deletions

View File

@ -89,3 +89,10 @@ if(PROCESSOR_IS_POWER)
target_link_libraries(cpuinfo_ppc_test all_libraries)
add_test(NAME cpuinfo_ppc_test COMMAND cpuinfo_ppc_test)
endif()
##------------------------------------------------------------------------------
## cpuinfo_s390x_test
if(PROCESSOR_IS_S390X)
add_executable(cpuinfo_s390x_test cpuinfo_s390x_test.cc ../src/impl_s390x_linux.c)
target_link_libraries(cpuinfo_s390x_test all_libraries)
add_test(NAME cpuinfo_s390x_test COMMAND cpuinfo_s390x_test)
endif()

View File

@ -0,0 +1,82 @@
// Copyright 2022 IBM.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "cpuinfo_s390x.h"
#include "filesystem_for_testing.h"
#include "gtest/gtest.h"
#include "hwcaps_for_testing.h"
namespace cpu_features {
namespace {
TEST(CpustringsS390XTest, S390XFeaturesEnum) {
const char *last_name = GetS390XFeaturesEnumName(S390X_LAST_);
EXPECT_STREQ(last_name, "unknown_feature");
for (int i = static_cast<int>(S390_ZARCH); i != static_cast<int>(S390X_LAST_); ++i) {
const auto feature = static_cast<S390XFeaturesEnum>(i);
const char *name = GetS390XFeaturesEnumName(feature);
ASSERT_FALSE(name == nullptr);
EXPECT_STRNE(name, "");
EXPECT_STRNE(name, last_name);
}
}
TEST(CpustringsS390XTest, FromHardwareCap) {
ResetHwcaps();
SetHardwareCapabilities(HWCAP_S390_ESAN3 | HWCAP_S390_HPAGE |
HWCAP_S390_NNPA | HWCAP_S390_SIE, 0);
GetEmptyFilesystem(); // disabling /proc/cpuinfo
const auto info = GetS390XInfo();
EXPECT_TRUE(info.features.esan3);
EXPECT_TRUE(info.features.edat);
EXPECT_TRUE(info.features.nnpa);
EXPECT_TRUE(info.features.sie);
EXPECT_FALSE(info.features.msa);
EXPECT_FALSE(info.features.stfle);
EXPECT_FALSE(info.features.vxp2);
EXPECT_FALSE(info.features.pcimio);
}
TEST(CpustringsS390XTest, z16) {
ResetHwcaps();
auto& fs = GetEmptyFilesystem();
fs.CreateFile("/proc/cpuinfo",
R"(vendor_id : IBM/S390
# processors : 24
bogomips per cpu: 26315.00
max thread id : 1
features : esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs te vx vxd vxe gs vxe2 vxp sort dflt vxp2 nnpa pcimio sie )");
SetPlatformPointer("z16");
const auto strings = GetS390XPlatformStrings();
EXPECT_EQ(strings.num_processors, 24);
ASSERT_STREQ(strings.type.platform, "z16");
}
TEST(CpustringsS390XTest, z15) {
ResetHwcaps();
auto& fs = GetEmptyFilesystem();
fs.CreateFile("/proc/cpuinfo",
R"(vendor_id : IBM/S390
# processors : 2
bogomips per cpu: 24038.00
max thread id : 1
features : esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs te vx vxd vxe gs vxe2 vxp sort dflt sie)");
SetPlatformPointer("z15");
const auto strings = GetS390XPlatformStrings();
EXPECT_EQ(strings.num_processors, 2);
ASSERT_STREQ(strings.type.platform, "z15");
}
} // namespace
} // namespace cpu_features