More adb cleanup.
This removes adb_dirstart and adb_dirstop. It also fixes a couple of memory
leaks by switching to std::string. This also fixes the bug in the previous
change --- mkdirs is given input like "/system/bin/sh" and only expected to
create "/system/bin". In a later change, we should remove mkdirs and only
expose the intended "unlink && mkdirs && create" functionality.
Change-Id: I30289dc1b3dff575cc1b158d993652178f587552
diff --git a/adb_utils_test.cpp b/adb_utils_test.cpp
index 20dba27..309ac02 100644
--- a/adb_utils_test.cpp
+++ b/adb_utils_test.cpp
@@ -58,6 +58,11 @@
ASSERT_EQ(R"('abc)')", escape_arg("abc)"));
}
+TEST(adb_utils, adb_basename) {
+ EXPECT_EQ("sh", adb_basename("/system/bin/sh"));
+ EXPECT_EQ("sh", adb_basename("sh"));
+}
+
TEST(adb_utils, parse_host_and_port) {
std::string canonical_address;
std::string host;
@@ -142,8 +147,8 @@
TEST(adb_utils, mkdirs) {
TemporaryDir td;
- EXPECT_TRUE(mkdirs(std::string(td.path) + "/dir/subdir/file"));
- std::string file = std::string(td.path) + "/file";
- adb_creat(file.c_str(), 0600);
- EXPECT_FALSE(mkdirs(file + "/subdir/"));
+ std::string path = std::string(td.path) + "/dir/subdir/file";
+ EXPECT_TRUE(mkdirs(path));
+ EXPECT_NE(-1, adb_creat(path.c_str(), 0600));
+ EXPECT_FALSE(mkdirs(path + "/subdir/"));
}