AU/unittest: fix FileWriterTest to be able to run in parallel

Eliminated use of fixed paths.

BUG=chromium:236465
TEST=Tests successful

Change-Id: I18684e35a9b775a111efc85281d05fdde2511326
Reviewed-on: https://gerrit.chromium.org/gerrit/62953
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/file_writer_unittest.cc b/file_writer_unittest.cc
index 1b7b1e6..35bfb86 100644
--- a/file_writer_unittest.cc
+++ b/file_writer_unittest.cc
@@ -20,8 +20,12 @@
 class FileWriterTest : public ::testing::Test { };
 
 TEST(FileWriterTest, SimpleTest) {
+  // Create a uniquely named file for testing.
+  string path;
+  ASSERT_TRUE(utils::MakeTempFile("/tmp/FileWriterTest-XXXXXX", &path, NULL));
+  ScopedPathUnlinker path_unlinker(path);
+
   DirectFileWriter file_writer;
-  const string path("/tmp/FileWriterTest");
   EXPECT_EQ(0, file_writer.Open(path.c_str(),
                                 O_CREAT | O_LARGEFILE | O_TRUNC | O_WRONLY,
                                 0644));
@@ -31,7 +35,6 @@
 
   EXPECT_FALSE(memcmp("test", &actual_data[0], actual_data.size()));
   EXPECT_EQ(0, file_writer.Close());
-  unlink(path.c_str());
 }
 
 TEST(FileWriterTest, ErrorTest) {
@@ -42,8 +45,12 @@
 }
 
 TEST(FileWriterTest, WriteErrorTest) {
+  // Create a uniquely named file for testing.
+  string path;
+  ASSERT_TRUE(utils::MakeTempFile("/tmp/FileWriterTest-XXXXXX", &path, NULL));
+  ScopedPathUnlinker path_unlinker(path);
+
   DirectFileWriter file_writer;
-  const string path("/tmp/FileWriterTest");
   EXPECT_EQ(0, file_writer.Open(path.c_str(),
                                 O_CREAT | O_LARGEFILE | O_TRUNC | O_RDONLY,
                                 0644));