Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: utils_unittest.cc

Issue 2868105: Disable automatic update checks if booting from a removable device. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 <sys/stat.h> 5 #include <sys/stat.h>
6 #include <sys/types.h> 6 #include <sys/types.h>
7 #include <errno.h> 7 #include <errno.h>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include <gtest/gtest.h> 10 #include <gtest/gtest.h>
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const string original = "/foo.XXXXXX"; 126 const string original = "/foo.XXXXXX";
127 const string result = utils::TempFilename(original); 127 const string result = utils::TempFilename(original);
128 EXPECT_EQ(original.size(), result.size()); 128 EXPECT_EQ(original.size(), result.size());
129 EXPECT_TRUE(utils::StringHasPrefix(result, "/foo.")); 129 EXPECT_TRUE(utils::StringHasPrefix(result, "/foo."));
130 EXPECT_FALSE(utils::StringHasSuffix(result, "XXXXXX")); 130 EXPECT_FALSE(utils::StringHasSuffix(result, "XXXXXX"));
131 } 131 }
132 132
133 TEST(UtilsTest, RootDeviceTest) { 133 TEST(UtilsTest, RootDeviceTest) {
134 EXPECT_EQ("/dev/sda", utils::RootDevice("/dev/sda3")); 134 EXPECT_EQ("/dev/sda", utils::RootDevice("/dev/sda3"));
135 EXPECT_EQ("/dev/mmc0", utils::RootDevice("/dev/mmc0p3")); 135 EXPECT_EQ("/dev/mmc0", utils::RootDevice("/dev/mmc0p3"));
136 EXPECT_EQ("", utils::RootDevice("/dev/foo/bar"));
137 EXPECT_EQ("", utils::RootDevice("/"));
138 EXPECT_EQ("", utils::RootDevice(""));
139 }
140
141 TEST(UtilsTest, SysfsBlockDeviceTest) {
142 EXPECT_EQ("/sys/block/sda", utils::SysfsBlockDevice("/dev/sda"));
143 EXPECT_EQ("", utils::SysfsBlockDevice("/foo/sda"));
144 EXPECT_EQ("", utils::SysfsBlockDevice("/dev/foo/bar"));
145 EXPECT_EQ("", utils::SysfsBlockDevice("/"));
146 EXPECT_EQ("", utils::SysfsBlockDevice("./"));
147 EXPECT_EQ("", utils::SysfsBlockDevice(""));
148 }
149
150 TEST(UtilsTest, IsRemovableDeviceTest) {
151 EXPECT_FALSE(utils::IsRemovableDevice(""));
152 EXPECT_FALSE(utils::IsRemovableDevice("/dev/non-existent-device"));
136 } 153 }
137 154
138 TEST(UtilsTest, PartitionNumberTest) { 155 TEST(UtilsTest, PartitionNumberTest) {
139 EXPECT_EQ("3", utils::PartitionNumber("/dev/sda3")); 156 EXPECT_EQ("3", utils::PartitionNumber("/dev/sda3"));
140 EXPECT_EQ("3", utils::PartitionNumber("/dev/mmc0p3")); 157 EXPECT_EQ("3", utils::PartitionNumber("/dev/mmc0p3"));
141 } 158 }
142 159
143 } // namespace chromeos_update_engine 160 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698