Fail File IO tests on undefined env var

This doesn't fix the tests, but at least it makes the failure a bit more obvious.

Also switched some CHECK_EQ to EXPECT_EQ

Progress on https://github.com/google/iree/issues/731

Closes https://github.com/google/iree/pull/734

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/iree/pull/734 from GMNGeoffrey:ctest-file-io b3e5fb01e84ef4da407d2a667af9fdf68f3753ec
PiperOrigin-RevId: 294458285
diff --git a/iree/base/BUILD b/iree/base/BUILD
index a24a40d..f690e46 100644
--- a/iree/base/BUILD
+++ b/iree/base/BUILD
@@ -145,6 +145,7 @@
     deps = [
         ":file_io",
         ":file_path",
+        ":logging",
         ":status",
         ":status_matchers",
         "//iree/testing:gtest_main",
diff --git a/iree/base/CMakeLists.txt b/iree/base/CMakeLists.txt
index 5b8acdc..b3823e8 100644
--- a/iree/base/CMakeLists.txt
+++ b/iree/base/CMakeLists.txt
@@ -163,6 +163,7 @@
   DEPS
     ::file_io
     ::file_path
+    ::logging
     ::status
     ::status_matchers
     absl::strings
diff --git a/iree/base/file_io_test.cc b/iree/base/file_io_test.cc
index a4597a8..6642141 100644
--- a/iree/base/file_io_test.cc
+++ b/iree/base/file_io_test.cc
@@ -17,6 +17,7 @@
 #include "absl/strings/str_cat.h"
 #include "absl/strings/string_view.h"
 #include "iree/base/file_path.h"
+#include "iree/base/logging.h"
 #include "iree/base/status.h"
 #include "iree/base/status_matchers.h"
 #include "iree/testing/gtest.h"
@@ -28,7 +29,9 @@
 using ::iree::testing::status::StatusIs;
 
 std::string GetUniquePath(absl::string_view unique_name) {
-  return file_path::JoinPaths(getenv("TEST_TMPDIR"),
+  char* test_tmpdir = getenv("TEST_TMPDIR");
+  CHECK(test_tmpdir) << "TEST_TMPDIR not defined";
+  return file_path::JoinPaths(test_tmpdir,
                               absl::StrCat(unique_name, "_test.txt"));
 }
 
@@ -44,7 +47,7 @@
 
   ASSERT_OK(SetFileContents(path, to_write));
   ASSERT_OK_AND_ASSIGN(std::string read, GetFileContents(path));
-  CHECK_EQ(to_write, read);
+  EXPECT_EQ(to_write, read);
 }
 
 TEST(FileIo, SetDeleteExists) {
@@ -72,7 +75,7 @@
   EXPECT_THAT(FileExists(from_path), StatusIs(StatusCode::kNotFound));
   EXPECT_OK(FileExists(to_path));
   ASSERT_OK_AND_ASSIGN(std::string read, GetFileContents(to_path));
-  CHECK_EQ(to_write, read);
+  EXPECT_EQ(to_write, read);
 }
 
 }  // namespace