ART: Relax failure requirements for dex2oat watchdog test

The watchdog does not clean up any output. It is theoretically
possible (though it should be very unlikely) that with the test
configuration the dex2oat run finishes writing the output before
the watchdog kills dex2oat.

Bug: 63052624
Test: m test-art-host-gtest-dex2oat_test
Change-Id: If5fc8936e18af8219f70de6f01c2ae7a993663a3
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index f176cc2..e98cb74 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -108,6 +108,8 @@
                         [](const OatFile&) {});
   }
 
+  bool test_accepts_odex_file_on_failure = false;
+
   template <typename T>
   void GenerateOdexForTest(
       const std::string& dex_location,
@@ -124,7 +126,7 @@
                                                &error_msg,
                                                extra_args,
                                                use_fd);
-    bool success = (status == 0);
+    bool success = (WIFEXITED(status) && WEXITSTATUS(status) == 0);
     if (expect_success) {
       ASSERT_TRUE(success) << error_msg << std::endl << output_;
 
@@ -146,16 +148,18 @@
 
       error_msg_ = error_msg;
 
-      // Verify there's no loadable odex file.
-      std::unique_ptr<OatFile> odex_file(OatFile::Open(odex_location.c_str(),
-                                                       odex_location.c_str(),
-                                                       nullptr,
-                                                       nullptr,
-                                                       false,
-                                                       /*low_4gb*/false,
-                                                       dex_location.c_str(),
-                                                       &error_msg));
-      ASSERT_TRUE(odex_file.get() == nullptr);
+      if (!test_accepts_odex_file_on_failure) {
+        // Verify there's no loadable odex file.
+        std::unique_ptr<OatFile> odex_file(OatFile::Open(odex_location.c_str(),
+                                                         odex_location.c_str(),
+                                                         nullptr,
+                                                         nullptr,
+                                                         false,
+                                                         /*low_4gb*/false,
+                                                         dex_location.c_str(),
+                                                         &error_msg));
+        ASSERT_TRUE(odex_file.get() == nullptr);
+      }
     }
   }
 
@@ -993,7 +997,12 @@
 
 TEST_F(Dex2oatWatchdogTest, TestWatchdogTrigger) {
   TEST_DISABLED_FOR_MEMORY_TOOL_VALGRIND();  // b/63052624
-  TEST_DISABLED_WITHOUT_BAKER_READ_BARRIERS();  // b/63052624
+
+  // The watchdog is independent of dex2oat and will not delete intermediates. It is possible
+  // that the compilation succeeds and the file is completely written by the time the watchdog
+  // kills dex2oat (but the dex2oat threads must have been scheduled pretty badly).
+  test_accepts_odex_file_on_failure = true;
+
   // Check with ten milliseconds.
   RunTest(false, { "--watchdog-timeout=10" });
 }