#ifdefined(__aarch64__)
TEST(InstructionSetFeaturesTest, DISABLED_FeaturesFromSystemPropertyVariant) {
LOG(WARNING) << "Test disabled due to no CPP define for A53 erratum 835769"; #else
TEST(InstructionSetFeaturesTest, FeaturesFromSystemPropertyVariant) { #endif if (kIsTargetBuild) { // atest differs in build-time and run-time features.
TEST_DISABLED_FOR_X86();
TEST_DISABLED_FOR_X86_64();
}
// Take the default set of instruction features from the build.
std::unique_ptr<const InstructionSetFeatures> instruction_set_features(
InstructionSetFeatures::FromCppDefines());
// Read the variant property.
std::string key = StringPrintf("dalvik.vm.isa.%s.variant", GetInstructionSetString(kRuntimeISA));
std::string dex2oat_isa_variant = android::base::GetProperty(key, ""); if (!dex2oat_isa_variant.empty()) { // Use features from property to build InstructionSetFeatures and check against build's // features.
std::string error_msg;
std::unique_ptr<const InstructionSetFeatures> property_features(
InstructionSetFeatures::FromVariant(kRuntimeISA, dex2oat_isa_variant, &error_msg));
ASSERT_TRUE(property_features.get() != nullptr) << error_msg;
#ifdefined(__aarch64__)
TEST(InstructionSetFeaturesTest, DISABLED_FeaturesFromSystemPropertyString) {
LOG(WARNING) << "Test disabled due to no CPP define for A53 erratum 835769"; #else
TEST(InstructionSetFeaturesTest, FeaturesFromSystemPropertyString) { #endif if (kIsTargetBuild) { // atest differs in build-time and run-time features.
TEST_DISABLED_FOR_X86();
TEST_DISABLED_FOR_X86_64();
}
// Take the default set of instruction features from the build.
std::unique_ptr<const InstructionSetFeatures> instruction_set_features(
InstructionSetFeatures::FromCppDefines());
// Read the variant property.
std::string variant_key = StringPrintf("dalvik.vm.isa.%s.variant",
GetInstructionSetString(kRuntimeISA));
std::string dex2oat_isa_variant = android::base::GetProperty(variant_key, ""); if (!dex2oat_isa_variant.empty()) { // Read the features property.
std::string features_key = StringPrintf("dalvik.vm.isa.%s.features",
GetInstructionSetString(kRuntimeISA));
std::string dex2oat_isa_features = android::base::GetProperty(features_key, ""); if (!dex2oat_isa_features.empty()) { // Use features from property to build InstructionSetFeatures and check against build's // features.
std::string error_msg;
std::unique_ptr<const InstructionSetFeatures> base_features(
InstructionSetFeatures::FromVariant(kRuntimeISA, dex2oat_isa_variant, &error_msg));
ASSERT_TRUE(base_features.get() != nullptr) << error_msg;
#ifdefined(__arm__)
TEST(InstructionSetFeaturesTest, DISABLED_FeaturesFromCpuInfo) {
LOG(WARNING) << "Test disabled due to buggy ARM kernels"; #else
TEST(InstructionSetFeaturesTest, FeaturesFromCpuInfo) { #endif // Take the default set of instruction features from the build.
std::unique_ptr<const InstructionSetFeatures> instruction_set_features(
InstructionSetFeatures::FromCppDefines());
// Check we get the same instruction set features using /proc/cpuinfo.
std::unique_ptr<const InstructionSetFeatures> cpuinfo_features(
InstructionSetFeatures::FromCpuInfo());
EXPECT_TRUE(cpuinfo_features->HasAtLeast(instruction_set_features.get()))
<< "CPU Info features: " << *cpuinfo_features.get()
<< "\nFeatures from build: " << *instruction_set_features.get();
} #endif
#ifdefined(__arm__)
TEST(InstructionSetFeaturesTest, DISABLED_FeaturesFromHwcap) {
LOG(WARNING) << "Test disabled due to buggy ARM kernels"; #else
TEST(InstructionSetFeaturesTest, FeaturesFromHwcap) { #endif // Take the default set of instruction features from the build.
std::unique_ptr<const InstructionSetFeatures> instruction_set_features(
InstructionSetFeatures::FromCppDefines());
// Check we get the same instruction set features using AT_HWCAP.
std::unique_ptr<const InstructionSetFeatures> hwcap_features(
InstructionSetFeatures::FromHwcap());
EXPECT_TRUE(hwcap_features->HasAtLeast(instruction_set_features.get()))
<< "Hwcap features: " << *hwcap_features.get()
<< "\nFeatures from build: " << *instruction_set_features.get();
}
TEST(InstructionSetFeaturesTest, FeaturesFromAssembly) { // Take the default set of instruction features from the build.
std::unique_ptr<const InstructionSetFeatures> instruction_set_features(
InstructionSetFeatures::FromCppDefines());
// Check we get the same instruction set features using assembly tests.
std::unique_ptr<const InstructionSetFeatures> assembly_features(
InstructionSetFeatures::FromAssembly());
EXPECT_TRUE(assembly_features->HasAtLeast(instruction_set_features.get()))
<< "Assembly features: " << *assembly_features.get()
<< "\nFeatures from build: " << *instruction_set_features.get();
}
TEST(InstructionSetFeaturesTest, FeaturestFromCpuFeatures) { // Take the default set of instruction features from the build.
std::unique_ptr<const InstructionSetFeatures> instruction_set_features(
InstructionSetFeatures::FromCppDefines());
// Check we get the same instruction set features using the cpu_features library
std::unique_ptr<const InstructionSetFeatures> library_features(
InstructionSetFeatures::FromCpuFeatures());
TEST(InstructionSetFeaturesTest, FeaturesFromRuntimeDetection) { if (!InstructionSetFeatures::IsRuntimeDetectionSupported()) {
EXPECT_EQ(InstructionSetFeatures::FromRuntimeDetection(), nullptr);
}
}
// The instruction set feature string must not contain 'default' together with // other feature names. // // Test that InstructionSetFeatures::AddFeaturesFromString returns nullptr and // an error is reported when the value 'default' is specified together // with other feature names in an instruction set feature string.
TEST(InstructionSetFeaturesTest, AddFeaturesFromStringWithDefaultAndOtherNames) {
std::unique_ptr<const InstructionSetFeatures> cpp_defined_features(
InstructionSetFeatures::FromCppDefines());
std::vector<std::string> invalid_feature_strings = { "a,default", "default,a", "a,default,b", "a,b,default", "default,a,b,c", "a,b,default,c,d", "a, default ", " default , a", "a, default , b", "default,runtime"
};
for (const std::string& invalid_feature_string : invalid_feature_strings) {
std::string error_msg;
EXPECT_EQ(cpp_defined_features->AddFeaturesFromString(invalid_feature_string, &error_msg),
nullptr) << " Invalid feature string: '" << invalid_feature_string << "'";
EXPECT_EQ(error_msg, "Specific instruction set feature(s) cannot be used when 'default' is used.");
}
}
// The instruction set feature string must not contain 'runtime' together with // other feature names. // // Test that InstructionSetFeatures::AddFeaturesFromString returns nullptr and // an error is reported when the value 'runtime' is specified together // with other feature names in an instruction set feature string.
TEST(InstructionSetFeaturesTest, AddFeaturesFromStringWithRuntimeAndOtherNames) {
std::unique_ptr<const InstructionSetFeatures> cpp_defined_features(
InstructionSetFeatures::FromCppDefines());
std::vector<std::string> invalid_feature_strings = { "a,runtime", "runtime,a", "a,runtime,b", "a,b,runtime", "runtime,a,b,c", "a,b,runtime,c,d", "a, runtime ", " runtime , a", "a, runtime , b", "runtime,default"
};
for (const std::string& invalid_feature_string : invalid_feature_strings) {
std::string error_msg;
EXPECT_EQ(cpp_defined_features->AddFeaturesFromString(invalid_feature_string, &error_msg),
nullptr) << " Invalid feature string: '" << invalid_feature_string << "'";
EXPECT_EQ(error_msg, "Specific instruction set feature(s) cannot be used when 'runtime' is used.");
}
}
// Spaces and multiple commas are ignores in a instruction set feature string. // // Test that a use of spaces and multiple commas with 'default' and 'runtime' // does not cause errors.
TEST(InstructionSetFeaturesTest, AddFeaturesFromValidStringContainingDefaultOrRuntime) {
std::unique_ptr<const InstructionSetFeatures> cpp_defined_features(
InstructionSetFeatures::FromCppDefines());
std::vector<std::string> valid_feature_strings = { "default", ",,,default", "default,,,,", ",,,default,,,,", "default, , , ", " , , ,default", " , , ,default, , , ", " default , , , ", ",,,runtime", "runtime,,,,", ",,,runtime,,,,", "runtime, , , ", " , , ,runtime", " , , ,runtime, , , ", " runtime , , , "
}; for (const std::string& valid_feature_string : valid_feature_strings) {
std::string error_msg;
EXPECT_NE(cpp_defined_features->AddFeaturesFromString(valid_feature_string, &error_msg),
nullptr) << " Valid feature string: '" << valid_feature_string << "'";
EXPECT_TRUE(error_msg.empty()) << error_msg;
}
}
// Spaces and multiple commas are ignores in a instruction set feature string. // // Test that a use of spaces and multiple commas without any feature names // causes errors.
TEST(InstructionSetFeaturesTest, AddFeaturesFromInvalidStringWithoutFeatureNames) {
std::unique_ptr<const InstructionSetFeatures> cpp_defined_features(
InstructionSetFeatures::FromCppDefines());
std::vector<std::string> invalid_feature_strings = { " ", " ", ",", ",,", " , , ,,,,,,", "\t", " \t ", ",", ",,", " , , ,,,,,,"
}; for (const std::string& invalid_feature_string : invalid_feature_strings) {
std::string error_msg;
EXPECT_EQ(cpp_defined_features->AddFeaturesFromString(invalid_feature_string, &error_msg),
nullptr) << " Invalid feature string: '" << invalid_feature_string << "'";
EXPECT_EQ(error_msg, "No instruction set features specified");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.