jobject class_loader = fuzzer::RegisterDexFileAndGetClassLoader(runtime, dex_file.get());
fuzzer::VerifyClasses(class_loader, dex_file.get()); constbool at_least_one_method_called_the_compiler = fuzzer::CompileClasses(
class_loader, dex_file.get(), compiler.get(), callbacks.get(), /*kDebugPrints=*/false); // Note: no need to reset callbacks as they will get destroyed
fuzzer::IterationCleanup(class_loader, dex_file.get());
ASSERT_EQ(at_least_one_method_called_the_compiler, expected_success) << " Failed for " << name;
}
std::unique_ptr<fuzzer::FuzzerCompilerCallbacks> callbacks( new fuzzer::FuzzerCompilerCallbacks());
std::unique_ptr<CompilerOptions> compiler_options =
fuzzer::CreateCompilerOptions(/*is_baseline=*/false, InstructionSet::kArm64);
jobject class_loader = fuzzer::RegisterDexFileAndGetClassLoader(runtime, dex_file.get());
fuzzer::VerifyClasses(class_loader, dex_file.get()); constbool at_least_one_method_called_the_compiler =
fuzzer::CompileClassesFast(class_loader,
dex_file.get(),
compiler_options.get(),
callbacks.get(), /*kDebugPrints=*/false); // Note: no need to reset callbacks as they will get destroyed
fuzzer::IterationCleanup(class_loader, dex_file.get());
ASSERT_EQ(at_least_one_method_called_the_compiler, expected_success) << " Failed for " << name;
}
void TestFuzzerHelper( const std::string& archive_filename,
std::function<bool(std::string&)> should_expect_success,
std::function<void(const uint8_t*, size_t, const std::string&, bool)> verify_file) { // Consistency checks. const std::string folder = android::base::GetExecutableDirectory();
ASSERT_TRUE(std::filesystem::is_directory(folder)) << folder << " is not a folder";
ASSERT_FALSE(std::filesystem::is_empty(folder)) << " No files found for directory " << folder; const std::string filename = folder + "/" + archive_filename;
// Iterate using ZipArchiveHandle. We have to be careful about managing the pointers with // CloseArchive, StartIteration, and EndIteration.
std::string error_msg;
ZipArchiveHandle handle;
ZipArchiveHandleScope scope(&handle);
int32_t error = OpenArchive(filename.c_str(), &handle);
ASSERT_TRUE(error == 0) << "Error: " << error;
const uint8_t* file_data = reinterpret_cast<const uint8_t*>(data.data()); // Special case for empty dex file. Set a fake data since the size is 0 anyway. if (file_data == nullptr) {
ASSERT_EQ(data.size(), 0);
file_data = reinterpret_cast<const uint8_t*>(&name);
}
// Tests that we can verify dex files without crashing.
TEST_F(FuzzerCorpusTest, VerifyCorpusDexFiles) { // These dex files are expected to pass verification. The others are regressions tests. const std::unordered_set<std::string> valid_dex_files = {"Main.dex", "hello_world.dex"}; const std::string archive_filename = "dex_verification_fuzzer_corpus.zip";
// Tests that we can verify classes from dex files without crashing.
TEST_F(FuzzerCorpusTest, VerifyCorpusClassDexFiles) { // These dex files are expected to pass verification. The others are regressions tests. const std::unordered_set<std::string> valid_dex_files = {"Main.dex", "hello_world.dex"}; const std::string archive_filename = "class_verification_fuzzer_corpus.zip";
// Tests that we can compile classes with kOptimizing from dex files without crashing.
TEST_F(FuzzerCorpusTest, OptimizeCompileDexFiles) { const std::string archive_filename = "optimized_compiler_fuzzer_corpus.zip";
// All added dex files should try to compile at least one method.
constexpr auto should_expect_success = [](std::string&) { returntrue; };
TestFuzzerHelper(archive_filename, should_expect_success, OptimizedCompilation);
}
// Tests that we can compile classes with kBaseline from dex files without crashing.
TEST_F(FuzzerCorpusTest, BaselineCompileDexFiles) { const std::string archive_filename = "baseline_compiler_fuzzer_corpus.zip";
// All added dex files should try to compile at least one method.
constexpr auto should_expect_success = [](std::string&) { returntrue; };
TestFuzzerHelper(archive_filename, should_expect_success, BaselineCompilation);
}
// Tests that we can compile classes with FastCompiler from dex files without crashing.
TEST_F(FuzzerCorpusTest, FastCompileDexFiles) { const std::string archive_filename = "fast_compiler_fuzzer_corpus.zip";
// All added dex files should try to compile at least one method.
constexpr auto should_expect_success = [](std::string&) { returntrue; };
TestFuzzerHelper(archive_filename, should_expect_success, FastCompilation);
}
} // namespace art
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-06-29)
¤
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.