summaryrefslogtreecommitdiffstats
path: root/adb/adb_io_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-05-01 17:04:38 -0700
committerElliott Hughes <enh@google.com>2015-05-01 17:37:28 -0700
commite1a55004e9fa46055c59f86e952e9e457c36c3f2 (patch)
tree7641d408bf403954720299492240fb4690674214 /adb/adb_io_test.cpp
parent92af733ee202caa3b5475fe27fcc81582f11e7c8 (diff)
downloadsystem_core-e1a55004e9fa46055c59f86e952e9e457c36c3f2.zip
system_core-e1a55004e9fa46055c59f86e952e9e457c36c3f2.tar.gz
system_core-e1a55004e9fa46055c59f86e952e9e457c36c3f2.tar.bz2
Add WriteFdFmt and clean up more code.
Also say *which* device wasn't found. Bug: http://b/20666660 Change-Id: I50e234ad89e39ae0a8995083c0b642c61275c5a3 (cherry picked from commit ab52c181fa4c1c9891644635dc5653cda5b90e2b)
Diffstat (limited to 'adb/adb_io_test.cpp')
-rw-r--r--adb/adb_io_test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/adb/adb_io_test.cpp b/adb/adb_io_test.cpp
index dd09919..8fd5cbf 100644
--- a/adb/adb_io_test.cpp
+++ b/adb/adb_io_test.cpp
@@ -152,3 +152,16 @@ TEST(io, WriteFdExactly_string) {
ASSERT_TRUE(android::base::ReadFdToString(tf.fd, &s));
EXPECT_STREQ(str, s.c_str());
}
+
+TEST(io, WriteFdFmt) {
+ TemporaryFile tf;
+ ASSERT_NE(-1, tf.fd);
+
+ // Test writing a partial string to the file.
+ ASSERT_TRUE(WriteFdFmt(tf.fd, "Foo%s%d", "bar", 123)) << strerror(errno);
+ ASSERT_EQ(0, lseek(tf.fd, SEEK_SET, 0));
+
+ std::string s;
+ ASSERT_TRUE(android::base::ReadFdToString(tf.fd, &s));
+ EXPECT_STREQ("Foobar123", s.c_str());
+}