summaryrefslogtreecommitdiff
path: root/test/libapt/srvrecs_test.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-08-18 10:02:35 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-18 10:02:35 +0200
commitd1fd09b982f6108dc32ec75330b0535236c48311 (patch)
treec0dce6cf7501c1e0d5e3bad34e9b63c0d6dcd354 /test/libapt/srvrecs_test.cc
parentb5fcba3682581b2a48921cc830dbf3deae6b0ff3 (diff)
parent43670e2ef8b689d9efba633d11d2a5fc6f9968a0 (diff)
Merge tag '1.3_rc2' into ubuntu
apt Debian release 1.3~rc2
Diffstat (limited to 'test/libapt/srvrecs_test.cc')
-rw-r--r--test/libapt/srvrecs_test.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/libapt/srvrecs_test.cc b/test/libapt/srvrecs_test.cc
index b3fa8102d..5253b1c34 100644
--- a/test/libapt/srvrecs_test.cc
+++ b/test/libapt/srvrecs_test.cc
@@ -53,12 +53,19 @@ TEST(SrvRecTest,Randomness)
EXPECT_EQ(testLength*2, base2.size());
std::vector<SrvRec> first_pull;
+ auto const startingClock = clock();
for (unsigned int i = 0; i < testLength; ++i)
first_pull.push_back(PopFromSrvRecs(base1));
EXPECT_TRUE(base1.empty());
EXPECT_FALSE(first_pull.empty());
EXPECT_EQ(testLength, first_pull.size());
+ // busy-wait for a cpu-clock change as we use it as "random" value
+ if (startingClock != -1)
+ for (int i = 0; i < 100000; ++i)
+ if (startingClock != clock())
+ break;
+
std::vector<SrvRec> second_pull;
for (unsigned int i = 0; i < testLength; ++i)
second_pull.push_back(PopFromSrvRecs(base2));
@@ -69,7 +76,8 @@ TEST(SrvRecTest,Randomness)
EXPECT_EQ(first_pull.size(), second_pull.size());
EXPECT_TRUE(std::all_of(first_pull.begin(), first_pull.end(), [](SrvRec const &R) { return R.priority == 20; }));
EXPECT_TRUE(std::all_of(second_pull.begin(), second_pull.end(), [](SrvRec const &R) { return R.priority == 20; }));
- EXPECT_FALSE(std::equal(first_pull.begin(), first_pull.end(), second_pull.begin()));
+ if (startingClock != -1 && startingClock != clock())
+ EXPECT_FALSE(std::equal(first_pull.begin(), first_pull.end(), second_pull.begin()));
EXPECT_TRUE(std::all_of(base2.begin(), base2.end(), [](SrvRec const &R) { return R.priority == 30; }));
}