Clean up `ResetOffset()` calls in profile tests.

Most are unnecessary since
    https://android-review.googlesource.com/1685637
and we remove a few more by using `PreadFully()` instead
of `ReadFully()`.

Test: m test-art-host-gtest
Bug: 148067697
Change-Id: Ia654f4519ea9ca91f9a5ca26af55899ccdf4bb78
diff --git a/libprofile/profile/profile_compilation_info_test.cc b/libprofile/profile/profile_compilation_info_test.cc
index 1e3c3b9..433fa73 100644
--- a/libprofile/profile/profile_compilation_info_test.cc
+++ b/libprofile/profile/profile_compilation_info_test.cc
@@ -138,9 +138,8 @@
     ASSERT_EQ(0, profile.GetFile()->Flush());
 
     // Prepare the profile content for zipping.
-    ASSERT_TRUE(profile.GetFile()->ResetOffset());
     std::vector<uint8_t> data(profile.GetFile()->GetLength());
-    ASSERT_TRUE(profile.GetFile()->ReadFully(data.data(), data.size()));
+    ASSERT_TRUE(profile.GetFile()->PreadFully(data.data(), data.size(), /*offset=*/ 0));
 
     // Zip the profile content.
     ScratchFile zip;
@@ -155,7 +154,6 @@
 
     // Verify loading from the zip archive.
     ProfileCompilationInfo loaded_info;
-    ASSERT_TRUE(zip.GetFile()->ResetOffset());
     ASSERT_EQ(should_succeed, loaded_info.Load(zip.GetFile()->GetPath(), false));
     if (should_succeed) {
       if (should_succeed_with_empty_profile) {
@@ -211,8 +209,6 @@
 
     ASSERT_TRUE(boot_profile.Save(GetFd(boot_file)));
     ASSERT_TRUE(reg_profile.Save(GetFd(reg_file)));
-    ASSERT_TRUE(boot_file.GetFile()->ResetOffset());
-    ASSERT_TRUE(reg_file.GetFile()->ResetOffset());
 
     ProfileCompilationInfo loaded_boot;
     ProfileCompilationInfo loaded_reg;
@@ -263,7 +259,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info.Load(GetFd(profile)));
   ASSERT_TRUE(loaded_info.Equals(saved_info));
 
@@ -279,7 +274,6 @@
 
   // Check that we get back everything we saved.
   ProfileCompilationInfo loaded_info2;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info2.Load(GetFd(profile)));
   ASSERT_TRUE(loaded_info2.Equals(saved_info));
 }
@@ -317,7 +311,6 @@
 
   ASSERT_TRUE(info1.Save(profile.GetFd()));
   ASSERT_EQ(0, profile.GetFile()->Flush());
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
 
   ASSERT_FALSE(info2.Load(profile.GetFd()));
 }
@@ -348,7 +341,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info.Load(GetFd(profile)));
   ASSERT_TRUE(loaded_info.Equals(saved_info));
 }
@@ -362,7 +354,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info.Load(GetFd(profile)));
   ASSERT_TRUE(loaded_info.Equals(saved_info));
 }
@@ -373,7 +364,6 @@
   ProfileCompilationInfo empty_info;
 
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info.Load(GetFd(profile)));
   ASSERT_TRUE(loaded_info.Equals(empty_info));
 }
@@ -383,7 +373,6 @@
   uint8_t buffer[] = { 1, 2, 3, 4 };
   ASSERT_TRUE(profile.GetFile()->WriteFully(buffer, sizeof(buffer)));
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_FALSE(loaded_info.Load(GetFd(profile)));
 }
 
@@ -397,7 +386,6 @@
   ASSERT_EQ(0, profile.GetFile()->Flush());
 
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_FALSE(loaded_info.Load(GetFd(profile)));
 }
 
@@ -413,7 +401,6 @@
   ASSERT_EQ(0, profile.GetFile()->Flush());
 
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_FALSE(loaded_info.Load(GetFd(profile)));
 }
 
@@ -434,7 +421,6 @@
   ASSERT_EQ(0, profile.GetFile()->Flush());
 
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_FALSE(loaded_info.Load(GetFd(profile)));
 }
 
@@ -454,7 +440,6 @@
 
   // Check that we fail because of unexpected data at the end of the file.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_FALSE(loaded_info.Load(GetFd(profile)));
 }
 
@@ -478,7 +463,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info.Load(GetFd(profile)));
 
   ASSERT_TRUE(loaded_info.Equals(saved_info));
@@ -523,7 +507,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(extra_profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info.Load(GetFd(extra_profile)));
 
   ASSERT_TRUE(loaded_info.Equals(saved_info));
@@ -573,7 +556,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(extra_profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info.Load(GetFd(extra_profile)));
 
   ASSERT_TRUE(loaded_info.Equals(saved_info));
@@ -742,7 +724,6 @@
   ScratchFile profile;
   ASSERT_TRUE(test_info.Save(GetFd(profile)));
   ASSERT_EQ(0, profile.GetFile()->Flush());
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
 
   // Load the profile and make sure we can read the data and it matches what we expect.
   ProfileCompilationInfo loaded_info;
@@ -837,9 +818,8 @@
   ASSERT_EQ(0, profile.GetFile()->Flush());
 
   // Prepare the profile content for zipping.
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   std::vector<uint8_t> data(profile.GetFile()->GetLength());
-  ASSERT_TRUE(profile.GetFile()->ReadFully(data.data(), data.size()));
+  ASSERT_TRUE(profile.GetFile()->PreadFully(data.data(), data.size(), /*offset=*/ 0));
 
   // Zip the profile content.
   ScratchFile zip;
@@ -854,7 +834,6 @@
 
   // Check that we failed to load.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(zip.GetFile()->ResetOffset());
   ASSERT_FALSE(loaded_info.Load(GetFd(zip)));
 }
 
@@ -977,7 +956,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
 
   // Filter out dex locations. Keep only dex_location1 and dex_location3.
   ProfileCompilationInfo::ProfileLoadFilterFn filter_fn =
@@ -1067,7 +1045,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
 
   // Remove all elements.
   ProfileCompilationInfo::ProfileLoadFilterFn filter_fn =
@@ -1098,7 +1075,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
 
   // Keep all elements.
   ProfileCompilationInfo::ProfileLoadFilterFn filter_fn =
@@ -1152,7 +1128,6 @@
 
   // Filter out dex locations: keep only `dex2_1000->GetLocation()`.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ProfileCompilationInfo::ProfileLoadFilterFn filter_fn =
       [dex2_1000](const std::string& dex_location, uint32_t checksum) -> bool {
           return dex_location == dex2_1000->GetLocation() &&
@@ -1194,7 +1169,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info.Load(GetFd(profile)));
   ASSERT_TRUE(loaded_info.Equals(info));
 }
@@ -1245,7 +1219,6 @@
   ScratchFile profile;
   ASSERT_TRUE(info.Save(GetFd(profile)));
   ASSERT_EQ(0, profile.GetFile()->Flush());
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
 
   // Load the profile and make sure we can read the data and it matches what we expect.
   ProfileCompilationInfo loaded_info;
@@ -1274,7 +1247,6 @@
   ScratchFile profile;
   ASSERT_TRUE(info.Save(GetFd(profile)));
   ASSERT_EQ(0, profile.GetFile()->Flush());
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
 
   // Load the profile and make sure we can read the data and it matches what we expect.
   ProfileCompilationInfo loaded_info;
@@ -1344,7 +1316,6 @@
   ScratchFile profile;
   ASSERT_TRUE(info1.Save(GetFd(profile)));
   ASSERT_EQ(0, profile.GetFile()->Flush());
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
 
   // Load the profile and make sure we can read the data and it matches what we expect.
   ProfileCompilationInfo loaded_info;
@@ -1483,7 +1454,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info.Load(GetFd(profile)));
   ASSERT_TRUE(loaded_info.Equals(info));
 
@@ -1542,7 +1512,6 @@
 
   // Check that we get back what we saved.
   ProfileCompilationInfo loaded_info;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_TRUE(loaded_info.Load(GetFd(profile)));
   ASSERT_TRUE(loaded_info.Equals(info));
 
diff --git a/runtime/jit/profiling_info_test.cc b/runtime/jit/profiling_info_test.cc
index e502adc..90162fd 100644
--- a/runtime/jit/profiling_info_test.cc
+++ b/runtime/jit/profiling_info_test.cc
@@ -208,7 +208,6 @@
 
   // Check that what we saved is in the profile (methods form Main and Second).
   ProfileCompilationInfo info2;
-  ASSERT_TRUE(profile.GetFile()->ResetOffset());
   ASSERT_TRUE(info2.Load(GetFd(profile)));
   ASSERT_EQ(info2.GetNumberOfMethods(), main_methods.size() + second_methods.size());
   {