AU: Update Downloader to support our image formats.
The downloader used to be dumb in the sense that it would pipe output
to either a DirectFileWriter or a DirectFileWriter via a
GzipDecompressingFileWriter, depending on if we were downloading an
update that was compressed or not. Sadly, things have gotten more
complex: we need to download to two partitions (kernel + rootfs), and
we may stream data via a DeltaPerformer (a type of FileWriter) to the
disk. Thus, the Downloader streams to either
1. gzip decompress->split_writer->direct to disk OR
2. delta performer
Other misc changes: Change FilesystemCopierAction to support
optionally copying the kernel partition rather than root partition.
InstallPlan struct: add an entry for destiation kernel partition.
Test Utils: a new ScopedTempFile class
Utils: support for getting the booted kernel partition device.
BUG=None
TEST=attached unittests
Review URL: http://codereview.chromium.org/1694025
diff --git a/utils_unittest.cc b/utils_unittest.cc
index 74f349d..5ab78cd 100644
--- a/utils_unittest.cc
+++ b/utils_unittest.cc
@@ -88,6 +88,20 @@
EXPECT_FALSE(utils::BootDevice().empty());
}
+TEST(UtilsTest, BootKernelDeviceTest) {
+ EXPECT_EQ("", utils::BootKernelDevice("foo"));
+ EXPECT_EQ("", utils::BootKernelDevice("/dev/sda0"));
+ EXPECT_EQ("", utils::BootKernelDevice("/dev/sda1"));
+ EXPECT_EQ("", utils::BootKernelDevice("/dev/sda2"));
+ EXPECT_EQ("/dev/sda2", utils::BootKernelDevice("/dev/sda3"));
+ EXPECT_EQ("", utils::BootKernelDevice("/dev/sda4"));
+ EXPECT_EQ("/dev/sda4", utils::BootKernelDevice("/dev/sda5"));
+ EXPECT_EQ("", utils::BootKernelDevice("/dev/sda6"));
+ EXPECT_EQ("/dev/sda6", utils::BootKernelDevice("/dev/sda7"));
+ EXPECT_EQ("", utils::BootKernelDevice("/dev/sda8"));
+ EXPECT_EQ("", utils::BootKernelDevice("/dev/sda9"));
+}
+
TEST(UtilsTest, RecursiveUnlinkDirTest) {
EXPECT_EQ(0, mkdir("RecursiveUnlinkDirTest-a", 0755));
EXPECT_EQ(0, mkdir("RecursiveUnlinkDirTest-b", 0755));