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

Unified Diff: omaha_hash_calculator_unittest.cc

Issue 3712003: AU: Verify source rootfs/kernel hashes before applying delta. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: verify source partitions only for new updates Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « omaha_hash_calculator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: omaha_hash_calculator_unittest.cc
diff --git a/omaha_hash_calculator_unittest.cc b/omaha_hash_calculator_unittest.cc
index 5ba3ac1805c9f82b32c19547a674a932acc0a801..28dc0303113dc7c67092026306a6a7e12f81e1c8 100644
--- a/omaha_hash_calculator_unittest.cc
+++ b/omaha_hash_calculator_unittest.cc
@@ -115,6 +115,25 @@ TEST(OmahaHashCalculatorTest, UpdateFileSimpleTest) {
EXPECT_EQ("qqlAJmTxpB9A67xSyZk+tmrrNmYClY/fqig7ceZNsSM=", calc.hash());
}
+TEST(OmahaHashCalculatorTest, RawHashOfFileSimpleTest) {
+ string data_path;
+ ASSERT_TRUE(
+ utils::MakeTempFile("/tmp/data.XXXXXX", &data_path, NULL));
+ ScopedPathUnlinker data_path_unlinker(data_path);
+ ASSERT_TRUE(utils::WriteFile(data_path.c_str(), "hi", 2));
+
+ static const int kLengths[] = { -1, 2, 10 };
+ for (size_t i = 0; i < arraysize(kLengths); i++) {
+ vector<char> exp_raw_hash(kExpectedRawHash,
+ kExpectedRawHash + arraysize(kExpectedRawHash));
+ vector<char> raw_hash;
+ EXPECT_EQ(2, OmahaHashCalculator::RawHashOfFile(data_path,
+ kLengths[i],
+ &raw_hash));
+ EXPECT_TRUE(exp_raw_hash == raw_hash);
+ }
+}
+
TEST(OmahaHashCalculatorTest, UpdateFileNonexistentTest) {
OmahaHashCalculator calc;
EXPECT_EQ(-1, calc.UpdateFile("/some/non-existent/file", -1));
« no previous file with comments | « omaha_hash_calculator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698