diff --git a/src/client/linux/minidump_writer/cpu_set_unittest.cc b/src/client/linux/minidump_writer/cpu_set_unittest.cc index 38fbefd3..e2274bd1 100644 --- a/src/client/linux/minidump_writer/cpu_set_unittest.cc +++ b/src/client/linux/minidump_writer/cpu_set_unittest.cc @@ -36,7 +36,7 @@ #include "breakpad_googletest_includes.h" #include "client/linux/minidump_writer/cpu_set.h" -#include "common/tests/auto_testfile.h" +#include "common/linux/tests/auto_testfile.h" using namespace google_breakpad; diff --git a/src/client/linux/minidump_writer/line_reader_unittest.cc b/src/client/linux/minidump_writer/line_reader_unittest.cc index e3d4a83d..29686f04 100644 --- a/src/client/linux/minidump_writer/line_reader_unittest.cc +++ b/src/client/linux/minidump_writer/line_reader_unittest.cc @@ -33,7 +33,7 @@ #include "client/linux/minidump_writer/line_reader.h" #include "breakpad_googletest_includes.h" -#include "common/tests/auto_testfile.h" +#include "common/linux/tests/auto_testfile.h" using namespace google_breakpad; diff --git a/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc b/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc index d127b06f..6037c7e6 100644 --- a/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc +++ b/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc @@ -36,7 +36,7 @@ #include "client/linux/minidump_writer/proc_cpuinfo_reader.h" #include "breakpad_googletest_includes.h" -#include "common/tests/auto_testfile.h" +#include "common/linux/tests/auto_testfile.h" using namespace google_breakpad; diff --git a/src/common/tests/auto_testfile.h b/src/common/linux/tests/auto_testfile.h similarity index 87% rename from src/common/tests/auto_testfile.h rename to src/common/linux/tests/auto_testfile.h index 8fd9b50a..92fe017b 100644 --- a/src/common/tests/auto_testfile.h +++ b/src/common/linux/tests/auto_testfile.h @@ -28,25 +28,24 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Utility class for creating a temporary file for unit tests -// that is deleted in the destructor. Only supported on Posix systems. -#ifndef GOOGLE_BREAKPAD_COMMON_TESTS_AUTO_TESTFILE -#define GOOGLE_BREAKPAD_COMMON_TESTS_AUTO_TESTFILE +// that is deleted in the destructor. + +#ifndef GOOGLE_BREAKPAD_COMMON_LINUX_TESTS_AUTO_TESTFILE +#define GOOGLE_BREAKPAD_COMMON_LINUX_TESTS_AUTO_TESTFILE #include #include + #include #include "breakpad_googletest_includes.h" +#include "common/linux/eintr_wrapper.h" #include "common/tests/auto_tempdir.h" namespace google_breakpad { -#ifdef _WIN32 -#error "This header cannot be used on Windows" -#else - class AutoTestFile { -public: + public: // Create a new empty test file. // test_prefix: (input) test-specific prefix, can't be NULL. explicit AutoTestFile(const char* test_prefix) { @@ -89,13 +88,13 @@ public: return fd_; } -private: + private: void Init(const char* test_prefix) { fd_ = -1; char path_templ[PATH_MAX]; int ret = snprintf(path_templ, sizeof(path_templ), - TEMPDIR "/%s-unittest.XXXXXX", - test_prefix); + TEMPDIR "/%s-unittest.XXXXXX", + test_prefix); if (ret >= static_cast(sizeof(path_templ))) return; @@ -107,8 +106,8 @@ private: } void WriteText(const char* text, size_t text_len) { - int r = HANDLE_EINTR(write(fd_, text, text_len)); - if (r != static_cast(text_len)) { + ssize_t r = HANDLE_EINTR(write(fd_, text, text_len)); + if (r != static_cast(text_len)) { close(fd_); fd_ = -1; return; @@ -120,8 +119,6 @@ private: int fd_; }; -#endif // !_WIN32 - } // namespace google_breakpad -#endif // GOOGLE_BREAKPAD_COMMON_TESTS_AUTO_TESTFILE +#endif // GOOGLE_BREAKPAD_COMMON_LINUX_TESTS_AUTO_TESTFILE