OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <pthread.h> | 7 #include <pthread.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 | 10 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 g_StringMap = args; | 276 g_StringMap = args; |
277 if (args.find("false") != args.end()) | 277 if (args.find("false") != args.end()) |
278 return EINVAL; | 278 return EINVAL; |
279 return 0; | 279 return 0; |
280 } | 280 } |
281 | 281 |
282 friend class TypedMountFactory<MountMockInit>; | 282 friend class TypedMountFactory<MountMockInit>; |
283 }; | 283 }; |
284 | 284 |
285 class KernelProxyMountMock : public KernelProxy { | 285 class KernelProxyMountMock : public KernelProxy { |
286 virtual void Init(PepperInterface* ppapi) { | 286 virtual Error Init(PepperInterface* ppapi) { |
287 KernelProxy::Init(NULL); | 287 KernelProxy::Init(NULL); |
288 factories_["initfs"] = new TypedMountFactory<MountMockInit>; | 288 factories_["initfs"] = new TypedMountFactory<MountMockInit>; |
| 289 return 0; |
289 } | 290 } |
290 }; | 291 }; |
291 | 292 |
292 class KernelProxyMountTest : public ::testing::Test { | 293 class KernelProxyMountTest : public ::testing::Test { |
293 public: | 294 public: |
294 KernelProxyMountTest() {} | 295 KernelProxyMountTest() {} |
295 | 296 |
296 void SetUp() { | 297 void SetUp() { |
297 ki_init(&kp_); | 298 ki_init(&kp_); |
298 } | 299 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 } | 372 } |
372 virtual Error Unlink(const Path& path) { return ENOSYS; } | 373 virtual Error Unlink(const Path& path) { return ENOSYS; } |
373 virtual Error Mkdir(const Path& path, int permissions) { return ENOSYS; } | 374 virtual Error Mkdir(const Path& path, int permissions) { return ENOSYS; } |
374 virtual Error Rmdir(const Path& path) { return ENOSYS; } | 375 virtual Error Rmdir(const Path& path) { return ENOSYS; } |
375 virtual Error Remove(const Path& path) { return ENOSYS; } | 376 virtual Error Remove(const Path& path) { return ENOSYS; } |
376 | 377 |
377 friend class TypedMountFactory<MountMockMMap>; | 378 friend class TypedMountFactory<MountMockMMap>; |
378 }; | 379 }; |
379 | 380 |
380 class KernelProxyMockMMap : public KernelProxy { | 381 class KernelProxyMockMMap : public KernelProxy { |
381 virtual void Init(PepperInterface* ppapi) { | 382 virtual Error Init(PepperInterface* ppapi) { |
382 KernelProxy::Init(NULL); | 383 KernelProxy::Init(NULL); |
383 factories_["mmapfs"] = new TypedMountFactory<MountMockMMap>; | 384 factories_["mmapfs"] = new TypedMountFactory<MountMockMMap>; |
| 385 return 0; |
384 } | 386 } |
385 }; | 387 }; |
386 | 388 |
387 class KernelProxyMMapTest : public ::testing::Test { | 389 class KernelProxyMMapTest : public ::testing::Test { |
388 public: | 390 public: |
389 KernelProxyMMapTest() {} | 391 KernelProxyMMapTest() {} |
390 | 392 |
391 void SetUp() { | 393 void SetUp() { |
392 ki_init(&kp_); | 394 ki_init(&kp_); |
393 } | 395 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 } | 445 } |
444 | 446 |
445 private: | 447 private: |
446 ScopedMount mount_; | 448 ScopedMount mount_; |
447 }; | 449 }; |
448 | 450 |
449 class KernelProxyError : public KernelProxy { | 451 class KernelProxyError : public KernelProxy { |
450 public: | 452 public: |
451 KernelProxyError() : mnt_(new MountMock) {} | 453 KernelProxyError() : mnt_(new MountMock) {} |
452 | 454 |
453 virtual void Init(PepperInterface* ppapi) { | 455 virtual Error Init(PepperInterface* ppapi) { |
454 KernelProxy::Init(ppapi); | 456 KernelProxy::Init(ppapi); |
455 factories_["testfs"] = new SingletonMountFactory(mnt_); | 457 factories_["testfs"] = new SingletonMountFactory(mnt_); |
456 | 458 |
457 EXPECT_CALL(*mnt_, Destroy()).Times(1); | 459 EXPECT_CALL(*mnt_, Destroy()).Times(1); |
| 460 return 0; |
458 } | 461 } |
459 | 462 |
460 ScopedRef<MountMock> mnt() { return mnt_; } | 463 ScopedRef<MountMock> mnt() { return mnt_; } |
461 | 464 |
462 private: | 465 private: |
463 ScopedRef<MountMock> mnt_; | 466 ScopedRef<MountMock> mnt_; |
464 }; | 467 }; |
465 | 468 |
466 class KernelProxyErrorTest : public ::testing::Test { | 469 class KernelProxyErrorTest : public ::testing::Test { |
467 public: | 470 public: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 int fd = ki_open("/dummy", O_RDONLY); | 526 int fd = ki_open("/dummy", O_RDONLY); |
524 EXPECT_NE(0, fd); | 527 EXPECT_NE(0, fd); |
525 | 528 |
526 char buf[20]; | 529 char buf[20]; |
527 EXPECT_EQ(-1, ki_read(fd, &buf[0], 20)); | 530 EXPECT_EQ(-1, ki_read(fd, &buf[0], 20)); |
528 // The Mount should be able to return whatever error it wants and have it | 531 // The Mount should be able to return whatever error it wants and have it |
529 // propagate through. | 532 // propagate through. |
530 EXPECT_EQ(1234, errno); | 533 EXPECT_EQ(1234, errno); |
531 } | 534 } |
532 | 535 |
OLD | NEW |