summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Low <CompareAndSwap@gmail.com>2015-09-01 14:57:58 -0700
committerSpencer Low <CompareAndSwap@gmail.com>2015-09-01 14:57:58 -0700
commit2fbeb0cc713f47ec699bfed4bc530aa19e08e1a3 (patch)
treefa660894431d56b1c3b1d05f1830191e6a19b24e
parent78ea165ea24e83a979939153ed4d3b075c07a779 (diff)
downloadsystem_core-2fbeb0cc713f47ec699bfed4bc530aa19e08e1a3.tar.gz
system_core-2fbeb0cc713f47ec699bfed4bc530aa19e08e1a3.tar.bz2
system_core-2fbeb0cc713f47ec699bfed4bc530aa19e08e1a3.zip
adb/base win32 tests: fix comment and open() flags
Match base's use of O_BINARY. Change-Id: I930b5c8fddde20966580069f2e681b99cb26f1a3 Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
-rw-r--r--adb/adb_io_test.cpp9
-rw-r--r--base/test_utils.cpp6
2 files changed, 8 insertions, 7 deletions
diff --git a/adb/adb_io_test.cpp b/adb/adb_io_test.cpp
index f637073a7..84e3db6f7 100644
--- a/adb/adb_io_test.cpp
+++ b/adb/adb_io_test.cpp
@@ -31,10 +31,11 @@
#include "base/test_utils.h"
// All of these tests fail on Windows because they use the C Runtime open(),
-// but the adb_io APIs expect file descriptors from adb_open(). Also, the
-// android::base file APIs use the C Runtime which uses CR/LF translation by
-// default (changeable with _setmode()), but the adb_io APIs use adb_read()
-// and adb_write() which do no translation.
+// but the adb_io APIs expect file descriptors from adb_open(). This could
+// theoretically be fixed by making adb_read()/adb_write() fallback to using
+// read()/write() if an unrecognized fd is used, and by making adb_open() return
+// fds far from the range that open() returns. But all of that might defeat the
+// purpose of the tests.
TEST(io, ReadFdExactly_whole) {
const char expected[] = "Foobar";
diff --git a/base/test_utils.cpp b/base/test_utils.cpp
index b0c5a12c0..22641e79d 100644
--- a/base/test_utils.cpp
+++ b/base/test_utils.cpp
@@ -37,9 +37,9 @@ int mkstemp(char* template_name) {
return -1;
}
// Use open() to match the close() that TemporaryFile's destructor does.
- // Note that on Windows, this does CR/LF translation and _setmode() should
- // be used to change that if appropriate.
- return open(template_name, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
+ // Use O_BINARY to match base file APIs.
+ return open(template_name, O_CREAT | O_EXCL | O_RDWR | O_BINARY,
+ S_IRUSR | S_IWUSR);
}
char* mkdtemp(char* template_name) {