Lines Matching refs:utils
45 EXPECT_FALSE(utils::WriteFile("/this/doesn't/exist", "hello", 5)); in TEST()
50 EXPECT_TRUE(utils::WriteFile(file.path().c_str(), "hello", 5)); in TEST()
53 EXPECT_TRUE(utils::ReadFile(file.path().c_str(), &readback)); in TEST()
59 EXPECT_FALSE(utils::ReadFile("/this/doesn't/exist", &empty)); in TEST()
71 EXPECT_TRUE(utils::ReadFileChunk(file.path().c_str(), kSize, 10, &in_data)); in TEST()
73 EXPECT_TRUE(utils::ReadFileChunk(file.path().c_str(), 0, -1, &in_data)); in TEST()
76 EXPECT_TRUE(utils::ReadFileChunk(file.path().c_str(), 10, 20, &in_data)); in TEST()
81 EXPECT_EQ("No such file or directory", utils::ErrnoNumberAsString(ENOENT)); in TEST()
88 EXPECT_TRUE(utils::WriteFile(temp_file.c_str(), "", 0)); in TEST()
91 EXPECT_FALSE(utils::IsSymlink(temp_dir.GetPath().value().c_str())); in TEST()
92 EXPECT_FALSE(utils::IsSymlink(temp_file.c_str())); in TEST()
93 EXPECT_TRUE(utils::IsSymlink(temp_symlink.c_str())); in TEST()
94 EXPECT_FALSE(utils::IsSymlink("/non/existent/path")); in TEST()
101 EXPECT_TRUE(utils::SplitPartitionName("/dev/sda3", &disk, &part_num)); in TEST()
105 EXPECT_TRUE(utils::SplitPartitionName("/dev/sdp1234", &disk, &part_num)); in TEST()
109 EXPECT_TRUE(utils::SplitPartitionName("/dev/mmcblk0p3", &disk, &part_num)); in TEST()
113 EXPECT_TRUE(utils::SplitPartitionName("/dev/loop10", &disk, &part_num)); in TEST()
117 EXPECT_TRUE(utils::SplitPartitionName("/dev/loop28p11", &disk, &part_num)); in TEST()
121 EXPECT_FALSE(utils::SplitPartitionName("/dev/mmcblk0p", &disk, &part_num)); in TEST()
122 EXPECT_FALSE(utils::SplitPartitionName("/dev/sda", &disk, &part_num)); in TEST()
123 EXPECT_FALSE(utils::SplitPartitionName("/dev/foo/bar", &disk, &part_num)); in TEST()
124 EXPECT_FALSE(utils::SplitPartitionName("/", &disk, &part_num)); in TEST()
125 EXPECT_FALSE(utils::SplitPartitionName("", &disk, &part_num)); in TEST()
129 EXPECT_EQ("/dev/sda4", utils::MakePartitionName("/dev/sda", 4)); in TEST()
130 EXPECT_EQ("/dev/sda123", utils::MakePartitionName("/dev/sda", 123)); in TEST()
131 EXPECT_EQ("/dev/mmcblk2", utils::MakePartitionName("/dev/mmcblk", 2)); in TEST()
132 EXPECT_EQ("/dev/mmcblk0p2", utils::MakePartitionName("/dev/mmcblk0", 2)); in TEST()
133 EXPECT_EQ("/dev/loop8", utils::MakePartitionName("/dev/loop", 8)); in TEST()
134 EXPECT_EQ("/dev/loop12p2", utils::MakePartitionName("/dev/loop12", 2)); in TEST()
142 uint32_t value = utils::FuzzInt(kValue, range); in TEST()
153 ASSERT_TRUE(utils::WriteFile(file.path().c_str(), in GetFileFormatTester()
156 EXPECT_EQ(expected, utils::GetFileFormat(file.path())); in GetFileFormatTester()
161 EXPECT_EQ("File not found.", utils::GetFileFormat("/path/to/nowhere")); in TEST()
202 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromMilliseconds(100)), in TEST()
204 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(0)), "0s"); in TEST()
205 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(1)), "1s"); in TEST()
206 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(59)), "59s"); in TEST()
207 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(60)), "1m0s"); in TEST()
208 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(61)), "1m1s"); in TEST()
209 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(90)), "1m30s"); in TEST()
210 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(1205)), in TEST()
212 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(3600)), in TEST()
214 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(3601)), in TEST()
216 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(3661)), in TEST()
218 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(7261)), in TEST()
220 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(86400)), in TEST()
222 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(86401)), in TEST()
224 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(200000)), in TEST()
226 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(200000) + in TEST()
229 EXPECT_EQ(utils::FormatTimeDelta(base::TimeDelta::FromSeconds(-1)), "-1s"); in TEST()
242 EXPECT_TRUE(utils::ConvertToOmahaInstallDate( in TEST()
247 EXPECT_FALSE(utils::ConvertToOmahaInstallDate( in TEST()
249 EXPECT_FALSE(utils::ConvertToOmahaInstallDate( in TEST()
254 EXPECT_TRUE(utils::ConvertToOmahaInstallDate( in TEST()
257 EXPECT_TRUE(utils::ConvertToOmahaInstallDate( in TEST()
262 EXPECT_TRUE(utils::ConvertToOmahaInstallDate( in TEST()
265 EXPECT_TRUE(utils::ConvertToOmahaInstallDate( in TEST()
268 EXPECT_TRUE(utils::ConvertToOmahaInstallDate( in TEST()
271 EXPECT_TRUE(utils::ConvertToOmahaInstallDate( in TEST()
289 EXPECT_TRUE(utils::ConvertToOmahaInstallDate( in TEST()
291 EXPECT_TRUE(utils::ConvertToOmahaInstallDate( in TEST()
302 EXPECT_FALSE(utils::GetMinorVersion(store, &minor_version)); in TEST()
305 EXPECT_FALSE(utils::GetMinorVersion(store, &minor_version)); in TEST()
308 EXPECT_TRUE(utils::GetMinorVersion(store, &minor_version)); in TEST()
357 utils::ParseRollbackKeyVersion(version, &actual_high, &actual_low); in ExpectParseRollbackKeyVersion()
377 EXPECT_FALSE(utils::UnmountFilesystem("/path/to/non-existing-dir")); in TEST()
394 EXPECT_FALSE(utils::IsMountpoint(mnt_dir.GetPath().value())); in TEST()
397 EXPECT_TRUE(utils::MountFilesystem( in TEST()
400 EXPECT_TRUE(utils::IsMountpoint(mnt_dir.GetPath().value())); in TEST()
405 EXPECT_TRUE(utils::UnmountFilesystem(mnt_dir.GetPath().value())); in TEST()
407 EXPECT_FALSE(utils::IsMountpoint(mnt_dir.GetPath().value())); in TEST()
410 EXPECT_FALSE(utils::UnmountFilesystem(mnt_dir.GetPath().value())); in TEST()
414 EXPECT_TRUE(utils::IsMountpoint("/")); in TEST()
415 EXPECT_FALSE(utils::IsMountpoint("/path/to/nowhere")); in TEST()
419 EXPECT_FALSE(utils::IsMountpoint(mnt_dir.GetPath().value())); in TEST()
422 EXPECT_FALSE(utils::IsMountpoint(file.path())); in TEST()
426 EXPECT_EQ(10575, utils::VersionPrefix("10575.39.")); in TEST()
427 EXPECT_EQ(10575, utils::VersionPrefix("10575.39")); in TEST()
428 EXPECT_EQ(10575, utils::VersionPrefix("10575.x")); in TEST()
429 EXPECT_EQ(10575, utils::VersionPrefix("10575.")); in TEST()
430 EXPECT_EQ(10575, utils::VersionPrefix("10575")); in TEST()
431 EXPECT_EQ(0, utils::VersionPrefix("")); in TEST()
432 EXPECT_EQ(-1, utils::VersionPrefix("x")); in TEST()
433 EXPECT_EQ(-1, utils::VersionPrefix("1x")); in TEST()
434 EXPECT_EQ(-1, utils::VersionPrefix("x.1")); in TEST()
466 EXPECT_EQ(file.path(), utils::GetFilePath(fd)); in TEST()
467 EXPECT_EQ("not found", utils::GetFilePath(-1)); in TEST()
473 utils::IsTimestampNewer("10", "5")); in TEST()
474 ASSERT_EQ(ErrorCode::kSuccess, utils::IsTimestampNewer("10", "11")); in TEST()
476 utils::IsTimestampNewer("10", "lol")); in TEST()
477 ASSERT_EQ(ErrorCode::kError, utils::IsTimestampNewer("lol", "ZZZ")); in TEST()
478 ASSERT_EQ(ErrorCode::kSuccess, utils::IsTimestampNewer("10", "")); in TEST()