Fix OS::GetFileSizeBytes().

Also improve CHECKs in dex2oat_image_test and

    Revert "Disable failing test."
    This reverts commit f0e3d9fc0354dfebb06d6930515c315ecc76fe1d.

Test: m test-art-host-gtest-dex2oat_image_test
Bug: 74375666
Change-Id: Iebeceb5a1cdc9d80a76039f52e826711085a7626
diff --git a/dex2oat/dex2oat_image_test.cc b/dex2oat/dex2oat_image_test.cc
index f542c60..d895282 100644
--- a/dex2oat/dex2oat_image_test.cc
+++ b/dex2oat/dex2oat_image_test.cc
@@ -129,12 +129,15 @@
     std::string art_file = scratch.GetFilename() + ".art";
     std::string oat_file = scratch.GetFilename() + ".oat";
     std::string vdex_file = scratch.GetFilename() + ".vdex";
-    ret.art_size = OS::GetFileSizeBytes(art_file.c_str());
-    ret.oat_size = OS::GetFileSizeBytes(oat_file.c_str());
-    ret.vdex_size = OS::GetFileSizeBytes(vdex_file.c_str());
-    CHECK_GT(ret.art_size, 0u) << art_file;
-    CHECK_GT(ret.oat_size, 0u) << oat_file;
-    CHECK_GT(ret.vdex_size, 0u) << vdex_file;
+    int64_t art_size = OS::GetFileSizeBytes(art_file.c_str());
+    int64_t oat_size = OS::GetFileSizeBytes(oat_file.c_str());
+    int64_t vdex_size = OS::GetFileSizeBytes(vdex_file.c_str());
+    CHECK_GT(art_size, 0u) << art_file;
+    CHECK_GT(oat_size, 0u) << oat_file;
+    CHECK_GT(vdex_size, 0u) << vdex_file;
+    ret.art_size = art_size;
+    ret.oat_size = oat_size;
+    ret.vdex_size = vdex_size;
     scratch.Close();
     // Clear image files since we compile the image multiple times and don't want to leave any
     // artifacts behind.
@@ -228,7 +231,7 @@
   }
 };
 
-TEST_F(Dex2oatImageTest, DISABLED_TestModesAndFilters) {
+TEST_F(Dex2oatImageTest, TestModesAndFilters) {
   if (kIsTargetBuild) {
     // This test is too slow for target builds.
     return;
diff --git a/libartbase/base/os_linux.cc b/libartbase/base/os_linux.cc
index 6b5a604..cb228bd 100644
--- a/libartbase/base/os_linux.cc
+++ b/libartbase/base/os_linux.cc
@@ -89,9 +89,11 @@
 int64_t OS::GetFileSizeBytes(const char* name) {
   struct stat st;
   if (stat(name, &st) == 0) {
-    return -1;  // TODO: Deal with symlinks?
+    return st.st_size;  // TODO: Deal with symlinks? According to the documentation,
+                        // the st_size for a symlink is "the length of the pathname
+                        // it contains, without a terminating null byte."
   } else {
-    return st.st_size;
+    return -1;
   }
 }