diff options
author | Elliott Hughes <enh@google.com> | 2015-07-30 17:42:01 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-07-30 17:46:58 -0700 |
commit | 5c74270f95107952a893584d02b33f9a79f6b3c4 (patch) | |
tree | f521b2a61ad3130ccfdab85dbdb21e0c16e41c2f /adb/adb_utils_test.cpp | |
parent | 0cf93dc345cd5e8131009146a3b2767b1c60f77b (diff) |
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
Diffstat (limited to 'adb/adb_utils_test.cpp')
-rw-r--r-- | adb/adb_utils_test.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/adb/adb_utils_test.cpp b/adb/adb_utils_test.cpp index 20dba2771a..309ac02c98 100644 --- a/adb/adb_utils_test.cpp +++ b/adb/adb_utils_test.cpp @@ -58,6 +58,11 @@ TEST(adb_utils, escape_arg) { 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, parse_host_and_port) { 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/")); } |