diff options
Diffstat (limited to 'adb/adb_utils_test.cpp')
-rw-r--r-- | adb/adb_utils_test.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/adb/adb_utils_test.cpp b/adb/adb_utils_test.cpp index 9c9f85c7da..34b54e79ed 100644 --- a/adb/adb_utils_test.cpp +++ b/adb/adb_utils_test.cpp @@ -186,10 +186,19 @@ TEST(adb_utils, parse_host_and_port) { EXPECT_FALSE(parse_host_and_port("1.2.3.4:65536", &canonical_address, &host, &port, &error)); } +void test_mkdirs(const std::string basepath) { + EXPECT_TRUE(mkdirs(basepath)); + EXPECT_NE(-1, adb_creat(basepath.c_str(), 0600)); + EXPECT_FALSE(mkdirs(basepath + "/subdir/")); +} + TEST(adb_utils, mkdirs) { TemporaryDir td; - 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/")); + + // Absolute paths. + test_mkdirs(std::string(td.path) + "/dir/subdir/file"); + + // Relative paths. + ASSERT_EQ(0, chdir(td.path)) << strerror(errno); + test_mkdirs(std::string("relative/subrel/file")); } |