system/corennnnn
Révision | 89b97677765cdc8d99319d85619f551ed5107d25 (tree) |
---|---|
l'heure | 2016-08-04 07:14:59 |
Auteur | Josh Gao <jmgao@goog...> |
Commiter | Josh Gao |
adb: extract Windows bits out of directory_exists test.
Bug: http://b/30481559
Bug: https://code.google.com/p/android/issues/detail?id=214633
Change-Id: I8f20b3cd5aef6a77c2b4f194b914b4295397d73f
(cherry picked from commit 3bdc76025b9b1a8416f00b5f1b57a51c6c9c604d)
@@ -52,25 +52,35 @@ TEST(adb_utils, directory_exists) { | ||
52 | 52 | |
53 | 53 | ASSERT_TRUE(directory_exists(profiles_dir)); |
54 | 54 | |
55 | + ASSERT_FALSE(directory_exists(subdir(profiles_dir, "does-not-exist"))); | |
56 | +#else | |
57 | + ASSERT_TRUE(directory_exists("/proc")); | |
58 | + ASSERT_FALSE(directory_exists("/proc/self")); // Symbolic link. | |
59 | + ASSERT_FALSE(directory_exists("/proc/does-not-exist")); | |
60 | +#endif | |
61 | +} | |
62 | + | |
63 | +#if defined(_WIN32) | |
64 | +TEST(adb_utils, directory_exists_win32_symlink_junction) { | |
65 | + char profiles_dir[MAX_PATH]; | |
66 | + DWORD cch = arraysize(profiles_dir); | |
67 | + | |
68 | + // On typical Windows 7, returns C:\Users | |
69 | + ASSERT_TRUE(GetProfilesDirectoryA(profiles_dir, &cch)); | |
70 | + | |
55 | 71 | // On modern (English?) Windows, this is a directory symbolic link to |
56 | 72 | // C:\ProgramData. Symbolic links are rare on Windows and the user requires |
57 | 73 | // a special permission (by default granted to Administrative users) to |
58 | 74 | // create symbolic links. |
59 | - ASSERT_FALSE(directory_exists(subdir(profiles_dir, "All Users"))); | |
75 | + EXPECT_FALSE(directory_exists(subdir(profiles_dir, "All Users"))); | |
60 | 76 | |
61 | 77 | // On modern (English?) Windows, this is a directory junction to |
62 | 78 | // C:\Users\Default. Junctions are used throughout user profile directories |
63 | 79 | // for backwards compatibility and they don't require any special permissions |
64 | 80 | // to create. |
65 | - ASSERT_FALSE(directory_exists(subdir(profiles_dir, "Default User"))); | |
66 | - | |
67 | - ASSERT_FALSE(directory_exists(subdir(profiles_dir, "does-not-exist"))); | |
68 | -#else | |
69 | - ASSERT_TRUE(directory_exists("/proc")); | |
70 | - ASSERT_FALSE(directory_exists("/proc/self")); // Symbolic link. | |
71 | - ASSERT_FALSE(directory_exists("/proc/does-not-exist")); | |
72 | -#endif | |
81 | + EXPECT_FALSE(directory_exists(subdir(profiles_dir, "Default User"))); | |
73 | 82 | } |
83 | +#endif | |
74 | 84 | |
75 | 85 | TEST(adb_utils, escape_arg) { |
76 | 86 | ASSERT_EQ(R"('')", escape_arg("")); |