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

Unified Diff: utils_unittest.cc

Issue 3173041: Add 10 minute random fuzz to automatic update check event schedule. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils_unittest.cc
diff --git a/utils_unittest.cc b/utils_unittest.cc
index 70eb6c7101ccfc88d268f9414bf107002faa6aa8..3514f8a5224a42e29e91603052cbb04cb6c6a14a 100644
--- a/utils_unittest.cc
+++ b/utils_unittest.cc
@@ -5,9 +5,11 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
+
#include <string>
#include <vector>
-#include <gtest/gtest.h>
+
+#include "gtest/gtest.h"
#include "update_engine/utils.h"
using std::string;
@@ -157,7 +159,7 @@ TEST(UtilsTest, PartitionNumberTest) {
EXPECT_EQ("3", utils::PartitionNumber("/dev/mmc0p3"));
}
-TEST(UtilsTest, ComparePriorities) {
+TEST(UtilsTest, ComparePrioritiesTest) {
EXPECT_LT(utils::ComparePriorities(utils::kProcessPriorityLow,
utils::kProcessPriorityNormal), 0);
EXPECT_GT(utils::ComparePriorities(utils::kProcessPriorityNormal,
@@ -168,4 +170,17 @@ TEST(UtilsTest, ComparePriorities) {
utils::kProcessPriorityNormal), 0);
}
+TEST(UtilsTest, FuzzIntTest) {
+ static const unsigned int kRanges[] = { 0, 1, 2, 20 };
+ for (size_t r = 0; r < arraysize(kRanges); ++r) {
+ unsigned int range = kRanges[r];
+ const int kValue = 50;
+ for (int tries = 0; tries < 100; ++tries) {
+ int value = utils::FuzzInt(kValue, range);
+ EXPECT_GE(value, kValue - range / 2);
+ EXPECT_LE(value, kValue + range - range / 2);
+ }
+ }
+}
+
} // namespace chromeos_update_engine
« 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