blob: 2fe8e816907770f25873ec1cdaab57af94bc6ab2 [file] [log] [blame]
Mike Frysinger38ae98d2012-04-11 12:03:44 -04001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Ben Chan29be9152011-07-25 14:39:48 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "cros-disks/platform.h"
6
Ben Chan8dcede82011-07-25 20:56:13 -07007#include <sys/types.h>
8#include <unistd.h>
9
Ben Chancd8fda42014-09-05 08:21:06 -070010#include <base/files/file_util.h>
Ben Chan97f99ff2013-02-14 14:59:33 -080011#include <base/files/scoped_temp_dir.h>
Ben Chan29be9152011-07-25 14:39:48 -070012#include <gtest/gtest.h>
13
Ben Chan2e8aa6f2013-02-15 11:40:04 -080014using base::FilePath;
Ben Chanf8692882011-08-21 10:15:30 -070015using std::set;
Ben Chan29be9152011-07-25 14:39:48 -070016using std::string;
17
18namespace cros_disks {
19
20class PlatformTest : public ::testing::Test {
Ben Chan8dcede82011-07-25 20:56:13 -070021 public:
22 // Returns true if |path| is owned by |user_id| and |group_id|.
23 static bool CheckOwnership(const string& path,
24 uid_t user_id, gid_t group_id) {
25 struct stat buffer;
26 if (stat(path.c_str(), &buffer) != 0)
27 return false;
28 return buffer.st_uid == user_id && buffer.st_gid == group_id;
29 }
30
31 // Returns true if |path| has its permissions set to |mode|.
32 static bool CheckPermissions(const string& path, mode_t mode) {
33 struct stat buffer;
34 if (stat(path.c_str(), &buffer) != 0)
35 return false;
36 return (buffer.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) == mode;
37 }
38
Ben Chan29be9152011-07-25 14:39:48 -070039 protected:
40 Platform platform_;
41};
42
Ben Chanadc5d002014-03-12 15:02:26 -070043TEST_F(PlatformTest, GetRealPath) {
44 base::ScopedTempDir temp_dir;
45 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
46 FilePath subdir_path;
47 ASSERT_TRUE(
48 base::CreateTemporaryDirInDir(temp_dir.path(), "test", &subdir_path));
49 FilePath file_path;
50 ASSERT_TRUE(base::CreateTemporaryFileInDir(subdir_path, &file_path));
51 FilePath file_symlink = temp_dir.path().Append("file_symlink");
52 ASSERT_TRUE(base::CreateSymbolicLink(file_path, file_symlink));
53 FilePath subdir_symlink = temp_dir.path().Append("subdir_symlink");
54 ASSERT_TRUE(base::CreateSymbolicLink(subdir_path, subdir_symlink));
55
56 string real_path;
57 EXPECT_FALSE(platform_.GetRealPath("", &real_path));
58 EXPECT_FALSE(platform_.GetRealPath("/nonexistent", &real_path));
59
60 EXPECT_TRUE(platform_.GetRealPath(temp_dir.path().value(), &real_path));
61 EXPECT_EQ(temp_dir.path().value(), real_path);
62
63 EXPECT_TRUE(platform_.GetRealPath(file_path.value(), &real_path));
64 EXPECT_EQ(file_path.value(), real_path);
65
66 EXPECT_TRUE(platform_.GetRealPath(file_symlink.value(), &real_path));
67 EXPECT_EQ(file_path.value(), real_path);
68
69 EXPECT_TRUE(platform_.GetRealPath(subdir_symlink.value(), &real_path));
70 EXPECT_EQ(subdir_path.value(), real_path);
71
72 FilePath relative_path = subdir_path.Append("..");
73 EXPECT_TRUE(platform_.GetRealPath(relative_path.value(), &real_path));
74 EXPECT_EQ(temp_dir.path().value(), real_path);
75
76 relative_path = subdir_path.Append("..")
77 .Append(subdir_path.BaseName())
78 .Append(file_path.BaseName());
79 EXPECT_TRUE(platform_.GetRealPath(relative_path.value(), &real_path));
80 EXPECT_EQ(file_path.value(), real_path);
81
82 relative_path = subdir_path.Append("..")
83 .Append(subdir_symlink.BaseName())
84 .Append(file_path.BaseName());
85 EXPECT_TRUE(platform_.GetRealPath(relative_path.value(), &real_path));
86 EXPECT_EQ(file_path.value(), real_path);
87}
88
Ben Chan8dcede82011-07-25 20:56:13 -070089TEST_F(PlatformTest, CreateDirectory) {
Ben Chan97f99ff2013-02-14 14:59:33 -080090 base::ScopedTempDir temp_dir;
Ben Chan8dcede82011-07-25 20:56:13 -070091 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
92
93 // Nonexistent directory
94 FilePath new_dir = temp_dir.path().Append("test");
95 string path = new_dir.value();
96 EXPECT_TRUE(platform_.CreateDirectory(path));
97
98 // Existent but empty directory
99 EXPECT_TRUE(platform_.CreateDirectory(path));
100
101 // Existent and non-empty directory
102 FilePath temp_file;
Ben Chan97e20d42014-02-05 18:38:07 -0800103 ASSERT_TRUE(base::CreateTemporaryFileInDir(new_dir, &temp_file));
Ben Chan8dcede82011-07-25 20:56:13 -0700104 EXPECT_TRUE(platform_.CreateDirectory(path));
105}
106
Ben Chan29be9152011-07-25 14:39:48 -0700107TEST_F(PlatformTest, CreateOrReuseEmptyDirectory) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800108 base::ScopedTempDir temp_dir;
Ben Chan29be9152011-07-25 14:39:48 -0700109 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
110
111 // Nonexistent directory
112 FilePath new_dir = temp_dir.path().Append("test");
113 string path = new_dir.value();
114 EXPECT_TRUE(platform_.CreateOrReuseEmptyDirectory(path));
115
116 // Existent but empty directory
117 EXPECT_TRUE(platform_.CreateOrReuseEmptyDirectory(path));
118
119 // Existent and non-empty directory
120 FilePath temp_file;
Ben Chan97e20d42014-02-05 18:38:07 -0800121 ASSERT_TRUE(base::CreateTemporaryFileInDir(new_dir, &temp_file));
Ben Chan29be9152011-07-25 14:39:48 -0700122 EXPECT_FALSE(platform_.CreateOrReuseEmptyDirectory(path));
123}
124
125TEST_F(PlatformTest, CreateOrReuseEmptyDirectoryWithFallback) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800126 base::ScopedTempDir temp_dir;
Ben Chan29be9152011-07-25 14:39:48 -0700127 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
Ben Chanf8692882011-08-21 10:15:30 -0700128 set<string> reserved_paths;
Ben Chan29be9152011-07-25 14:39:48 -0700129
130 // Nonexistent directory
Ben Chanec4eaab2012-02-05 23:26:58 -0800131 FilePath new_dir = temp_dir.path().Append("test1");
Ben Chan29be9152011-07-25 14:39:48 -0700132 string path = new_dir.value();
Ben Chanf8692882011-08-21 10:15:30 -0700133 EXPECT_TRUE(platform_.CreateOrReuseEmptyDirectoryWithFallback(
134 &path, 10, reserved_paths));
Ben Chan29be9152011-07-25 14:39:48 -0700135 EXPECT_EQ(new_dir.value(), path);
136
137 // Existent but empty directory
138 path = new_dir.value();
Ben Chanf8692882011-08-21 10:15:30 -0700139 EXPECT_TRUE(platform_.CreateOrReuseEmptyDirectoryWithFallback(
140 &path, 10, reserved_paths));
Ben Chan29be9152011-07-25 14:39:48 -0700141 EXPECT_EQ(new_dir.value(), path);
142
143 // Existent and non-empty directory
144 FilePath temp_file;
Ben Chan97e20d42014-02-05 18:38:07 -0800145 ASSERT_TRUE(base::CreateTemporaryFileInDir(new_dir, &temp_file));
Ben Chan29be9152011-07-25 14:39:48 -0700146 path = new_dir.value();
Ben Chanf8692882011-08-21 10:15:30 -0700147 EXPECT_FALSE(platform_.CreateOrReuseEmptyDirectoryWithFallback(
148 &path, 0, reserved_paths));
149 EXPECT_TRUE(platform_.CreateOrReuseEmptyDirectoryWithFallback(
150 &path, 1, reserved_paths));
Ben Chanec4eaab2012-02-05 23:26:58 -0800151 FilePath new_dir1 = temp_dir.path().Append("test1 (1)");
Ben Chan29be9152011-07-25 14:39:48 -0700152 EXPECT_EQ(new_dir1.value(), path);
153
Ben Chan97e20d42014-02-05 18:38:07 -0800154 ASSERT_TRUE(base::CreateTemporaryFileInDir(new_dir1, &temp_file));
Ben Chan29be9152011-07-25 14:39:48 -0700155 path = new_dir.value();
Ben Chanf8692882011-08-21 10:15:30 -0700156 EXPECT_FALSE(platform_.CreateOrReuseEmptyDirectoryWithFallback(
157 &path, 0, reserved_paths));
158 EXPECT_FALSE(platform_.CreateOrReuseEmptyDirectoryWithFallback(
159 &path, 1, reserved_paths));
160 EXPECT_TRUE(platform_.CreateOrReuseEmptyDirectoryWithFallback(
161 &path, 2, reserved_paths));
Ben Chanec4eaab2012-02-05 23:26:58 -0800162 FilePath new_dir2 = temp_dir.path().Append("test1 (2)");
Ben Chan29be9152011-07-25 14:39:48 -0700163 EXPECT_EQ(new_dir2.value(), path);
164}
165
Ben Chanf8692882011-08-21 10:15:30 -0700166TEST_F(PlatformTest, CreateOrReuseEmptyDirectoryWithFallbackAndReservedPaths) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800167 base::ScopedTempDir temp_dir;
Ben Chanf8692882011-08-21 10:15:30 -0700168 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
169 set<string> reserved_paths;
170
171 FilePath new_dir = temp_dir.path().Append("test");
172 string path = new_dir.value();
173 reserved_paths.insert(path);
174 EXPECT_FALSE(platform_.CreateOrReuseEmptyDirectoryWithFallback(
175 &path, 0, reserved_paths));
176 EXPECT_EQ(new_dir.value(), path);
177
Ben Chanec4eaab2012-02-05 23:26:58 -0800178 reserved_paths.insert(temp_dir.path().Append("test 1").value());
179 reserved_paths.insert(temp_dir.path().Append("test 2").value());
Ben Chanf8692882011-08-21 10:15:30 -0700180 EXPECT_FALSE(platform_.CreateOrReuseEmptyDirectoryWithFallback(
181 &path, 2, reserved_paths));
182 EXPECT_EQ(new_dir.value(), path);
183
Ben Chanec4eaab2012-02-05 23:26:58 -0800184 FilePath expected_dir = temp_dir.path().Append("test 3");
Ben Chanf8692882011-08-21 10:15:30 -0700185 EXPECT_TRUE(platform_.CreateOrReuseEmptyDirectoryWithFallback(
186 &path, 3, reserved_paths));
187 EXPECT_EQ(expected_dir.value(), path);
188}
189
Ben Chanec4eaab2012-02-05 23:26:58 -0800190TEST_F(PlatformTest, GetDirectoryFallbackName) {
191 EXPECT_EQ("test 1", platform_.GetDirectoryFallbackName("test", 1));
192 EXPECT_EQ("test1 (1)", platform_.GetDirectoryFallbackName("test1", 1));
193}
194
Ben Chan1d5a8e72011-08-01 15:21:39 -0700195TEST_F(PlatformTest, GetGroupIdOfRoot) {
196 gid_t group_id;
197 EXPECT_TRUE(platform_.GetGroupId("root", &group_id));
198 EXPECT_EQ(0, group_id);
Ben Chan29be9152011-07-25 14:39:48 -0700199}
200
Ben Chan1d5a8e72011-08-01 15:21:39 -0700201TEST_F(PlatformTest, GetGroupIdOfNonExistentGroup) {
202 gid_t group_id;
203 EXPECT_FALSE(platform_.GetGroupId("nonexistent-group", &group_id));
204}
205
206TEST_F(PlatformTest, GetUserAndGroupIdOfRoot) {
207 uid_t user_id;
208 gid_t group_id;
209 EXPECT_TRUE(platform_.GetUserAndGroupId("root", &user_id, &group_id));
210 EXPECT_EQ(0, user_id);
211 EXPECT_EQ(0, group_id);
212}
213
214TEST_F(PlatformTest, GetUserAndGroupIdOfNonExistentUser) {
215 uid_t user_id;
216 gid_t group_id;
217 EXPECT_FALSE(platform_.GetUserAndGroupId("nonexistent-user",
218 &user_id, &group_id));
Ben Chan29be9152011-07-25 14:39:48 -0700219}
220
Ben Chanb1ac5a82011-08-02 17:53:55 -0700221TEST_F(PlatformTest, GetOwnershipOfDirectory) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800222 base::ScopedTempDir temp_dir;
Ben Chanb1ac5a82011-08-02 17:53:55 -0700223 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
224 string path = temp_dir.path().value();
225
226 uid_t user_id;
227 gid_t group_id;
228 EXPECT_TRUE(platform_.GetOwnership(path, &user_id, &group_id));
229 EXPECT_EQ(getuid(), user_id);
230 EXPECT_EQ(getgid(), group_id);
231}
232
233TEST_F(PlatformTest, GetOwnershipOfFile) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800234 base::ScopedTempDir temp_dir;
Ben Chanb1ac5a82011-08-02 17:53:55 -0700235 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
236 FilePath temp_file;
Ben Chan97e20d42014-02-05 18:38:07 -0800237 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.path(), &temp_file));
Ben Chanb1ac5a82011-08-02 17:53:55 -0700238 string path = temp_file.value();
239
240 uid_t user_id;
241 gid_t group_id;
242 EXPECT_TRUE(platform_.GetOwnership(path, &user_id, &group_id));
243 EXPECT_EQ(getuid(), user_id);
244 EXPECT_EQ(getgid(), group_id);
245}
246
247TEST_F(PlatformTest, GetOwnershipOfSymbolicLink) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800248 base::ScopedTempDir temp_dir;
Ben Chanb1ac5a82011-08-02 17:53:55 -0700249 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
250 FilePath temp_file;
Ben Chan97e20d42014-02-05 18:38:07 -0800251 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.path(), &temp_file));
Ben Chanb1ac5a82011-08-02 17:53:55 -0700252 string file_path = temp_file.value();
253 string symlink_path = file_path + "-symlink";
254 FilePath temp_symlink(symlink_path);
Ben Chan97e20d42014-02-05 18:38:07 -0800255 ASSERT_TRUE(base::CreateSymbolicLink(temp_file, temp_symlink));
Ben Chanb1ac5a82011-08-02 17:53:55 -0700256
257 uid_t user_id;
258 gid_t group_id;
259 EXPECT_TRUE(platform_.GetOwnership(symlink_path, &user_id, &group_id));
260 EXPECT_EQ(getuid(), user_id);
261 EXPECT_EQ(getgid(), group_id);
262}
263
264TEST_F(PlatformTest, GetOwnershipOfNonexistentPath) {
265 uid_t user_id;
266 gid_t group_id;
267 EXPECT_FALSE(platform_.GetOwnership("/nonexistent-path",
268 &user_id, &group_id));
269}
270
271TEST_F(PlatformTest, GetPermissionsOfDirectory) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800272 base::ScopedTempDir temp_dir;
Ben Chanb1ac5a82011-08-02 17:53:55 -0700273 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
274 string path = temp_dir.path().value();
275
276 mode_t mode = 0;
277 EXPECT_TRUE(platform_.GetPermissions(path, &mode));
278 mode_t expected_mode = (mode & ~S_IRWXG & ~S_IRWXO) | S_IRWXU;
279 EXPECT_TRUE(platform_.SetPermissions(path, expected_mode));
280 EXPECT_TRUE(platform_.GetPermissions(path, &mode));
281 EXPECT_EQ(expected_mode, mode);
282
283 mode = 0;
284 expected_mode |= S_IRWXG;
285 EXPECT_TRUE(platform_.SetPermissions(path, expected_mode));
286 EXPECT_TRUE(platform_.GetPermissions(path, &mode));
287 EXPECT_EQ(expected_mode, mode);
288}
289
290TEST_F(PlatformTest, GetPermissionsOfFile) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800291 base::ScopedTempDir temp_dir;
Ben Chanb1ac5a82011-08-02 17:53:55 -0700292 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
293 FilePath temp_file;
Ben Chan97e20d42014-02-05 18:38:07 -0800294 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.path(), &temp_file));
Ben Chanb1ac5a82011-08-02 17:53:55 -0700295 string path = temp_file.value();
296
297 mode_t mode = 0;
298 EXPECT_TRUE(platform_.GetPermissions(path, &mode));
299 mode_t expected_mode = (mode & ~S_IRWXG & ~S_IRWXO) | S_IRWXU;
300 EXPECT_TRUE(platform_.SetPermissions(path, expected_mode));
301 EXPECT_TRUE(platform_.GetPermissions(path, &mode));
302 EXPECT_EQ(expected_mode, mode);
303
304 mode = 0;
305 expected_mode |= S_IRWXG;
306 EXPECT_TRUE(platform_.SetPermissions(path, expected_mode));
307 EXPECT_TRUE(platform_.GetPermissions(path, &mode));
308 EXPECT_EQ(expected_mode, mode);
309}
310
311TEST_F(PlatformTest, GetPermissionsOfSymbolicLink) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800312 base::ScopedTempDir temp_dir;
Ben Chanb1ac5a82011-08-02 17:53:55 -0700313 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
314 FilePath temp_file;
Ben Chan97e20d42014-02-05 18:38:07 -0800315 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.path(), &temp_file));
Ben Chanb1ac5a82011-08-02 17:53:55 -0700316 string file_path = temp_file.value();
317 string symlink_path = file_path + "-symlink";
318 FilePath temp_symlink(symlink_path);
Ben Chan97e20d42014-02-05 18:38:07 -0800319 ASSERT_TRUE(base::CreateSymbolicLink(temp_file, temp_symlink));
Ben Chanb1ac5a82011-08-02 17:53:55 -0700320
321 mode_t mode = 0;
322 EXPECT_TRUE(platform_.GetPermissions(file_path, &mode));
323 mode_t expected_mode = (mode & ~S_IRWXG & ~S_IRWXO) | S_IRWXU;
324 EXPECT_TRUE(platform_.SetPermissions(file_path, expected_mode));
325 EXPECT_TRUE(platform_.GetPermissions(symlink_path, &mode));
326 EXPECT_EQ(expected_mode, mode);
327
328 mode = 0;
329 expected_mode |= S_IRWXG;
330 EXPECT_TRUE(platform_.SetPermissions(file_path, expected_mode));
331 EXPECT_TRUE(platform_.GetPermissions(symlink_path, &mode));
332 EXPECT_EQ(expected_mode, mode);
333}
334
335TEST_F(PlatformTest, GetPermissionsOfNonexistentPath) {
336 mode_t mode;
337 EXPECT_FALSE(platform_.GetPermissions("/nonexistent-path", &mode));
338}
339
Ben Chan29be9152011-07-25 14:39:48 -0700340TEST_F(PlatformTest, RemoveEmptyDirectory) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800341 base::ScopedTempDir temp_dir;
Ben Chan29be9152011-07-25 14:39:48 -0700342 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
343
344 // Nonexistent directory
345 FilePath new_dir = temp_dir.path().Append("test");
346 string path = new_dir.value();
347 EXPECT_FALSE(platform_.RemoveEmptyDirectory(path));
348
349 // Existent but empty directory
350 EXPECT_TRUE(platform_.CreateOrReuseEmptyDirectory(path));
351 EXPECT_TRUE(platform_.RemoveEmptyDirectory(path));
352
353 // Existent and non-empty directory
354 EXPECT_TRUE(platform_.CreateOrReuseEmptyDirectory(path));
355 FilePath temp_file;
Ben Chan97e20d42014-02-05 18:38:07 -0800356 ASSERT_TRUE(base::CreateTemporaryFileInDir(new_dir, &temp_file));
Ben Chan29be9152011-07-25 14:39:48 -0700357 EXPECT_FALSE(platform_.RemoveEmptyDirectory(path));
358}
359
Ben Chan93dec932011-08-03 12:57:49 -0700360TEST_F(PlatformTest, SetMountUserToRoot) {
361 EXPECT_TRUE(platform_.SetMountUser("root"));
362 EXPECT_EQ(0, platform_.mount_user_id());
363 EXPECT_EQ(0, platform_.mount_group_id());
Ben Chan98f8ae02011-10-04 16:34:34 -0700364 EXPECT_EQ("root", platform_.mount_user());
Ben Chan93dec932011-08-03 12:57:49 -0700365}
366
367TEST_F(PlatformTest, SetMountUserToNonexistentUser) {
368 uid_t user_id = platform_.mount_user_id();
369 gid_t group_id = platform_.mount_group_id();
Ben Chan98f8ae02011-10-04 16:34:34 -0700370 string user = platform_.mount_user();
Ben Chan93dec932011-08-03 12:57:49 -0700371 EXPECT_FALSE(platform_.SetMountUser("nonexistent-user"));
372 EXPECT_EQ(user_id, platform_.mount_user_id());
373 EXPECT_EQ(group_id, platform_.mount_group_id());
Ben Chan98f8ae02011-10-04 16:34:34 -0700374 EXPECT_EQ(user, platform_.mount_user());
Ben Chan93dec932011-08-03 12:57:49 -0700375}
376
Ben Chan8dcede82011-07-25 20:56:13 -0700377TEST_F(PlatformTest, SetOwnershipOfNonExistentPath) {
378 EXPECT_FALSE(platform_.SetOwnership("/nonexistent-path", getuid(), getgid()));
379}
380
381TEST_F(PlatformTest, SetOwnershipOfExistentPath) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800382 base::ScopedTempDir temp_dir;
Ben Chan8dcede82011-07-25 20:56:13 -0700383 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
384 string path = temp_dir.path().value();
385
386 EXPECT_TRUE(platform_.SetOwnership(path, getuid(), getgid()));
387 EXPECT_TRUE(CheckOwnership(path, getuid(), getgid()));
388}
389
390TEST_F(PlatformTest, SetPermissionsOfNonExistentPath) {
391 EXPECT_FALSE(platform_.SetPermissions("/nonexistent-path", S_IRWXU));
392}
393
394TEST_F(PlatformTest, SetPermissionsOfExistentPath) {
Ben Chan97f99ff2013-02-14 14:59:33 -0800395 base::ScopedTempDir temp_dir;
Ben Chan8dcede82011-07-25 20:56:13 -0700396 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
397 string path = temp_dir.path().value();
398
399 mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
400 EXPECT_TRUE(platform_.SetPermissions(path, mode));
401 EXPECT_TRUE(CheckPermissions(path, mode));
402
403 mode = S_IRWXU | S_IRGRP | S_IXGRP;
404 EXPECT_TRUE(platform_.SetPermissions(path, mode));
405 EXPECT_TRUE(CheckPermissions(path, mode));
406
407 mode = S_IRWXU;
408 EXPECT_TRUE(platform_.SetPermissions(path, mode));
409 EXPECT_TRUE(CheckPermissions(path, mode));
410}
411
Ben Chan29be9152011-07-25 14:39:48 -0700412} // namespace cros_disks