blob: 2b52b9184d6f6071d9a327a4ec508fe8f5501b29 [file] [log] [blame]
Alex Deymo42432912013-07-12 20:21:15 -07001// 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
8using std::string;
9using std::vector;
10
11namespace chromeos_update_engine {
12
13class 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
24TEST_F(HardwareTest, BootDeviceTest) {
25 // Pretty lame test...
26 EXPECT_FALSE(hwut_.BootDevice().empty());
27}
28
29TEST_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 McLoughlin049d1652013-07-31 18:47:46 -070047
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 Deymo42432912013-07-12 20:21:15 -070055}
56
57} // namespace chromeos_update_engine