]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2860] Added comments to tests per review
authorMarcin Siodelski <marcin@isc.org>
Wed, 24 May 2023 14:42:23 +0000 (16:42 +0200)
committerMarcin Siodelski <marcin@isc.org>
Wed, 24 May 2023 14:42:23 +0000 (16:42 +0200)
src/lib/dhcpsrv/tests/ip_range_permutation_unittest.cc

index 544c63bc775bf7b305f8d097778f6ef3236c49c7..92fbceda6ea24cdda0ca262cefc6467f6f219be1 100644 (file)
@@ -76,6 +76,14 @@ TEST(IPRangePermutationTest, ipv4) {
         iterations.push_back(ordered_addrs);
     }
 
+    // We want to make sure that each new permutation instance produces a different
+    // sequence of addresses. It checks whether or not the random device has been
+    // initialized properly. If the random device uses the same seed for each
+    // new permutation, the output sequence is always the same. The test below
+    // checks that the sequences are different by comparing the respective addresses
+    // for two different permutations. It is ok if some of them are equal because it
+    // is statistically probable. The threshold of 20% should guard against some
+    // of them being equal without a risk of sporadic test failures.
     int overlaps = 0;
     for (auto i = 0; i < iterations[0].size(); ++i) {
         if (iterations[0][i] == iterations[1][i]) {
@@ -130,6 +138,14 @@ TEST(IPRangePermutationTest, ipv6) {
         iterations.push_back(ordered_addrs);
     }
 
+    // We want to make sure that each new permutation instance produces a different
+    // sequence of addresses. It checks whether or not the random device has been
+    // initialized properly. If the random device uses the same seed for each
+    // new permutation, the output sequence is always the same. The test below
+    // checks that the sequences are different by comparing the respective addresses
+    // for two different permutations. It is ok if some of them are equal because it
+    // is statistically probable. The threshold of 20% should guard against some
+    // of them being equal without a risk of sporadic test failures.
     int overlaps = 0;
     for (auto i = 0; i < iterations[0].size(); ++i) {
         if (iterations[0][i] == iterations[1][i]) {
@@ -185,6 +201,14 @@ TEST(IPRangePermutationTest, pd) {
 
     ASSERT_EQ(2, iterations.size());
 
+    // We want to make sure that each new permutation instance produces a different
+    // sequence of prefixes. It checks whether or not the random device has been
+    // initialized properly. If the random device uses the same seed for each
+    // new permutation, the output sequence is always the same. The test below
+    // checks that the sequences are different by comparing the respective prefixes
+    // for two different permutations. It is ok if some of them are equal because it
+    // is statistically probable. The threshold of 20% should guard against some
+    // of them being equal without a risk of sporadic test failures.
     int overlaps = 0;
     for (auto i = 0; i < iterations[0].size(); ++i) {
         if (iterations[0][i] == iterations[1][i]) {