Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "update_engine/test_utils.h" |
| 6 | #include "update_engine/hardware.h" |
| 7 | |
| 8 | using std::string; |
| 9 | using std::vector; |
| 10 | |
| 11 | namespace chromeos_update_engine { |
| 12 | |
| 13 | class HardwareTest : public ::testing::Test { |
| 14 | protected: |
| 15 | void SetUp() { |
| 16 | } |
| 17 | void TearDown() { |
| 18 | } |
| 19 | |
| 20 | // Hardware object under test. |
| 21 | Hardware hwut_; |
| 22 | }; |
| 23 | |
| 24 | TEST_F(HardwareTest, BootDeviceTest) { |
| 25 | // Pretty lame test... |
| 26 | EXPECT_FALSE(hwut_.BootDevice().empty()); |
| 27 | } |
| 28 | |
| 29 | TEST_F(HardwareTest, KernelDeviceOfBootDevice) { |
| 30 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("foo")); |
| 31 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("/dev/sda0")); |
| 32 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("/dev/sda1")); |
| 33 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("/dev/sda2")); |
| 34 | EXPECT_EQ("/dev/sda2", hwut_.KernelDeviceOfBootDevice("/dev/sda3")); |
| 35 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("/dev/sda4")); |
| 36 | EXPECT_EQ("/dev/sda4", hwut_.KernelDeviceOfBootDevice("/dev/sda5")); |
| 37 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("/dev/sda6")); |
| 38 | EXPECT_EQ("/dev/sda6", hwut_.KernelDeviceOfBootDevice("/dev/sda7")); |
| 39 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("/dev/sda8")); |
| 40 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("/dev/sda9")); |
| 41 | |
| 42 | EXPECT_EQ("/dev/mmcblk0p2", hwut_.KernelDeviceOfBootDevice("/dev/mmcblk0p3")); |
| 43 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("/dev/mmcblk0p4")); |
| 44 | |
| 45 | EXPECT_EQ("/dev/ubi2", hwut_.KernelDeviceOfBootDevice("/dev/ubi3")); |
| 46 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("/dev/ubi4")); |
Liam McLoughlin | 049d165 | 2013-07-31 18:47:46 -0700 | [diff] [blame] | 47 | |
| 48 | EXPECT_EQ("/dev/mtdblock2", |
| 49 | hwut_.KernelDeviceOfBootDevice("/dev/ubiblock3_0")); |
| 50 | EXPECT_EQ("/dev/mtdblock4", |
| 51 | hwut_.KernelDeviceOfBootDevice("/dev/ubiblock5_0")); |
| 52 | EXPECT_EQ("/dev/mtdblock6", |
| 53 | hwut_.KernelDeviceOfBootDevice("/dev/ubiblock7_0")); |
| 54 | EXPECT_EQ("", hwut_.KernelDeviceOfBootDevice("/dev/ubiblock4_0")); |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | } // namespace chromeos_update_engine |