#Centipede Use new OSS functions to get test temp & src dirs

PiperOrigin-RevId: 625781448
diff --git a/centipede/BUILD b/centipede/BUILD
index a4cb224..1fca4a2 100644
--- a/centipede/BUILD
+++ b/centipede/BUILD
@@ -1160,6 +1160,7 @@
 
 cc_library(
     name = "test_util",
+    testonly = True,
     srcs = ["test_util.cc"],
     hdrs = ["test_util.h"],
     deps = [
@@ -1170,6 +1171,7 @@
         "@com_google_absl//absl/log:check",
         "@com_google_absl//absl/strings",
         "@com_google_absl//absl/strings:str_format",
+        "@com_google_googletest//:gtest",
     ],
 )
 
diff --git a/centipede/environment_flags.cc b/centipede/environment_flags.cc
index 7e925a8..a571d4c 100644
--- a/centipede/environment_flags.cc
+++ b/centipede/environment_flags.cc
@@ -338,9 +338,7 @@
           " as argv. If two corpora are provided, then analyze differences"
           " between those corpora. If one corpus is provided, then save the"
           " coverage report to a file within workdir with prefix"
-          " 'coverage-report-'."
-          " Used by the Centipede developers to improve the engine. "
-          " TODO(kcc) implement. ");
+          " 'coverage-report-'.");
 ABSL_FLAG(std::vector<std::string>, dictionary, default_env->dictionary,
           "A comma-separated list of paths to dictionary files. The dictionary "
           "file is either in AFL/libFuzzer plain text format or in the binary "
diff --git a/centipede/test_util.cc b/centipede/test_util.cc
index 1096b0a..ecf3e1c 100644
--- a/centipede/test_util.cc
+++ b/centipede/test_util.cc
@@ -18,6 +18,7 @@
 #include <string_view>
 #include <system_error>  // NOLINT
 
+#include "gtest/gtest.h"
 #include "absl/log/check.h"
 #include "absl/log/log.h"
 #include "absl/strings/str_cat.h"
@@ -26,11 +27,10 @@
 namespace centipede {
 
 std::filesystem::path GetTestTempDir(std::string_view subdir) {
-  std::filesystem::path dir;
-  dir = std::getenv("TEST_TMPDIR");
-  if (dir.empty()) dir = std::getenv("TMPDIR");
-  if (dir.empty()) dir = "/tmp";
-  dir.append(subdir);
+  const std::filesystem::path test_tempdir = ::testing::TempDir();
+  CHECK(!test_tempdir.empty())
+      << "testing::TempDir() is expected to always return non-empty path";
+  const auto dir = test_tempdir / subdir;
   if (!std::filesystem::exists(dir)) {
     std::error_code error;
     std::filesystem::create_directories(dir, error);
@@ -44,9 +44,9 @@
 }
 
 std::filesystem::path GetTestRunfilesDir() {
-  const char* test_srcdir = std::getenv("TEST_SRCDIR");
-  CHECK(test_srcdir != nullptr)
-      << "TEST_SRCDIR envvar is expected to be set by build system";
+  const auto test_srcdir = ::testing::SrcDir();
+  CHECK(!test_srcdir.empty())
+      << "testing::SrcDir() is expected to always return non-empty path";
   const char* test_workspace = std::getenv("TEST_WORKSPACE");
   CHECK(test_workspace != nullptr)
       << "TEST_WORKSPACE envvar is expected to be set by build system";