diff options
Diffstat (limited to 'dexlayout/dexlayout_test.cc')
| -rw-r--r-- | dexlayout/dexlayout_test.cc | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/dexlayout/dexlayout_test.cc b/dexlayout/dexlayout_test.cc index 3c37e6dffb..03df258f04 100644 --- a/dexlayout/dexlayout_test.cc +++ b/dexlayout/dexlayout_test.cc @@ -14,13 +14,16 @@ * limitations under the License. */ -#include <sstream> -#include <string> -#include <vector> +#include "dexlayout.h" #include <sys/types.h> #include <unistd.h> +#include <memory> +#include <sstream> +#include <string> +#include <vector> + #include "base/common_art_test.h" #include "base/unix_file/fd_file.h" #include "base/utils.h" @@ -30,7 +33,6 @@ #include "dex/code_item_accessors-inl.h" #include "dex/dex_file-inl.h" #include "dex/dex_file_loader.h" -#include "dexlayout.h" #include "exec_utils.h" #include "profile/profile_compilation_info.h" @@ -328,11 +330,9 @@ class DexLayoutTest : public CommonArtTest { const std::string& out_profile) { std::vector<std::unique_ptr<const DexFile>> dex_files; std::string error_msg; - const ArtDexFileLoader dex_file_loader; - bool result = dex_file_loader.Open(input_dex.c_str(), - input_dex, - /*verify=*/ true, - /*verify_checksum=*/ false, + ArtDexFileLoader dex_file_loader(input_dex); + bool result = dex_file_loader.Open(/*verify=*/true, + /*verify_checksum=*/false, &error_msg, &dex_files); @@ -772,14 +772,15 @@ TEST_F(DexLayoutTest, LinkData) { TEST_F(DexLayoutTest, ClassFilter) { std::vector<std::unique_ptr<const DexFile>> dex_files; std::string error_msg; - const ArtDexFileLoader dex_file_loader; const std::string input_jar = GetTestDexFileName("ManyMethods"); - CHECK(dex_file_loader.Open(input_jar.c_str(), - input_jar.c_str(), - /*verify=*/ true, - /*verify_checksum=*/ true, - &error_msg, - &dex_files)) << error_msg; + { + ArtDexFileLoader dex_file_loader(input_jar); + CHECK(dex_file_loader.Open(/*verify=*/true, + /*verify_checksum=*/true, + &error_msg, + &dex_files)) + << error_msg; + } ASSERT_EQ(dex_files.size(), 1u); for (const std::unique_ptr<const DexFile>& dex_file : dex_files) { EXPECT_GT(dex_file->NumClassDefs(), 1u); @@ -802,18 +803,16 @@ TEST_F(DexLayoutTest, ClassFilter) { &out, &error_msg); ASSERT_TRUE(result) << "Failed to run dexlayout " << error_msg; - std::unique_ptr<const DexFile> output_dex_file( - dex_file_loader.OpenWithDataSection( - out->GetMainSection()->Begin(), - out->GetMainSection()->Size(), - out->GetDataSection()->Begin(), - out->GetDataSection()->Size(), - dex_file->GetLocation().c_str(), - /* location_checksum= */ 0, - /*oat_dex_file=*/ nullptr, - /* verify= */ true, - /*verify_checksum=*/ false, - &error_msg)); + auto container = std::make_unique<DexLoaderContainer>(out->GetMainSection()->Begin(), + out->GetMainSection()->End(), + out->GetDataSection()->Begin(), + out->GetDataSection()->End()); + ArtDexFileLoader dex_file_loader(std::move(container), dex_file->GetLocation()); + std::unique_ptr<const DexFile> output_dex_file(dex_file_loader.Open(/* location_checksum= */ 0, + /*oat_dex_file=*/nullptr, + /* verify= */ true, + /*verify_checksum=*/false, + &error_msg)); ASSERT_TRUE(output_dex_file != nullptr); ASSERT_EQ(output_dex_file->NumClassDefs(), options.class_filter_.size()); |