summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Orion Hodson <oth@google.com> 2021-05-04 16:04:10 +0100
committer Orion Hodson <oth@google.com> 2021-05-04 18:54:55 +0000
commit59d29bfeda798c9621515f59707af745d431763c (patch)
tree5885c4db89f120fcd5e46586691ee18e548e5cbb
parent680d768b1aec1daf7a8faeb01d04e164afdc07bc (diff)
odrefresh: re-enable OdrFsUtilsTest.GetUsedSpace
Use stat() in test for size in blocks rather than rounding up the written file size to integral number of 512-byte blocks. Bug: 186730164 Test: atest art_odrefresh_tests Test: atest --host art_odrefresh_tests Change-Id: Ic0b3421451f9f8049b30d11ec73761e6871034b8
-rw-r--r--odrefresh/odr_fs_utils_test.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/odrefresh/odr_fs_utils_test.cc b/odrefresh/odr_fs_utils_test.cc
index 6c4326505a..42912d3c8d 100644
--- a/odrefresh/odr_fs_utils_test.cc
+++ b/odrefresh/odr_fs_utils_test.cc
@@ -118,7 +118,7 @@ TEST_F(OdrFsUtilsTest, EnsureDirectoryExistsSubDirs) {
}
}
-TEST_F(OdrFsUtilsTest, DISABLED_GetUsedSpace) {
+TEST_F(OdrFsUtilsTest, GetUsedSpace) {
static constexpr size_t kFirstFileBytes = 1;
static constexpr size_t kSecondFileBytes = 16111;
static constexpr size_t kBytesPerBlock = 512;
@@ -148,7 +148,8 @@ TEST_F(OdrFsUtilsTest, DISABLED_GetUsedSpace) {
for (size_t i = 1; i < 32768; i *= 17) {
const std::string path = android::base::StringPrintf("%s/%zu", sub_dir_path.c_str(), i);
ASSERT_TRUE(CreateFile(path.c_str(), i));
- expected_bytes_used += RoundUp(i, sb.st_blocks * kBytesPerBlock);
+ ASSERT_EQ(0, stat(path.c_str(), &sb));
+ expected_bytes_used += sb.st_blocks * kBytesPerBlock;
ASSERT_TRUE(GetUsedSpace(scratch_dir.GetPath().c_str(), &bytes_used));
ASSERT_EQ(expected_bytes_used, bytes_used);
}